EP, MP, CO and BTN now play three-player games against small and big blind (push/fold and open/call/3-bet trees, CFR+ for three players, exploitability summed over all three best responses). Deal weights and three-way shares are documented approximations. Short deck gets its own equity table and charts from the same generator (--deck short). Open width shrinks in EP/MP (e.g. EP 100bb 0.291 -> 0.249, MP 40bb 0.357 -> 0.293); frozen exploitability stays at 0-4 micro-bb (full) and 0-9 micro-bb (short). Lookup and advice cover SB vs open/jam, BB after an SB call and the opener vs an SB 3-bet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
62 lines
2.0 KiB
Rust
62 lines
2.0 KiB
Rust
//! What the solver needs from a game, whatever the number of players: the shape of the
|
|
//! decision nodes, one CFR+ step and the exploitability of a strategy.
|
|
//!
|
|
//! `Tree` (two players, zero-sum) and `Tree3` (three players) implement it, so `Strategy`,
|
|
//! `SolverState` and `solve` work on both.
|
|
|
|
use super::exploitability::exploitability;
|
|
use super::iterate::iterate;
|
|
use super::solver_state::SolverState;
|
|
use super::strategy::Strategy;
|
|
use super::tree::{Node, Tree};
|
|
use crate::rng::Rng;
|
|
|
|
pub trait Game {
|
|
/// Hand classes per player.
|
|
fn classes(&self) -> usize;
|
|
/// Actions per node, 0 for nodes that are not decisions.
|
|
fn action_counts(&self) -> Vec<usize>;
|
|
/// Name of a decision node, `None` for other nodes and unknown indices.
|
|
fn decision_name(&self, node: usize) -> Option<&'static str>;
|
|
/// One CFR+ iteration.
|
|
fn step(&self, state: SolverState, rng: Rng) -> (SolverState, Rng);
|
|
/// Sum of every player's best-response gain against the others' fixed strategy.
|
|
fn exploitability(&self, strategy: &Strategy) -> f64;
|
|
|
|
/// Index of the decision node with this name.
|
|
fn decision(&self, name: &str) -> Option<usize> {
|
|
(0..self.action_counts().len()).find(|n| self.decision_name(*n) == Some(name))
|
|
}
|
|
}
|
|
|
|
impl Game for Tree {
|
|
fn classes(&self) -> usize {
|
|
self.classes
|
|
}
|
|
|
|
fn action_counts(&self) -> Vec<usize> {
|
|
self.nodes
|
|
.iter()
|
|
.map(|n| match n {
|
|
Node::Decision { children, .. } => children.len(),
|
|
_ => 0,
|
|
})
|
|
.collect()
|
|
}
|
|
|
|
fn decision_name(&self, node: usize) -> Option<&'static str> {
|
|
match self.nodes.get(node) {
|
|
Some(Node::Decision { name, .. }) => Some(name),
|
|
_ => None,
|
|
}
|
|
}
|
|
|
|
fn step(&self, state: SolverState, rng: Rng) -> (SolverState, Rng) {
|
|
iterate(self, state, rng)
|
|
}
|
|
|
|
fn exploitability(&self, strategy: &Strategy) -> f64 {
|
|
exploitability(self, strategy)
|
|
}
|
|
}
|