Expand description
Find near-equilibrium strategies for heads-up postflop No-Limit Hold’em spots, and measure how exploitable they are.
Give it a board, both players’ ranges, the pot, the stacks, and the bet sizes to consider; it trains a strategy with counterfactual regret minimization (CFR, CFR+, or DCFR) and reports per-hand strategies, EVs, and exploitability: how much a perfect opponent could still win against the result. Chip amounts are exact integers, invalid inputs are reported as errors, and an independent reference evaluator can check results on small trees.
card:Cards andCardSets.eval: five- and seven-card hand evaluation.range: weighted preflop ranges and their expansion intoCombos.solver: the betting tree (GameConfig,build_tree) and the combo-vectorized CFRTrainer, with exploitability and node EVs.
Only heads-up postflop play is modeled: no preflop, no side pots, no multiway pots. All values are in input chips unless a doc says otherwise.
§Example
Solve a river spot and check how close the result is to equilibrium:
use native_solver::{build_tree, Card, CardSet, Chips, GameConfig, Range, Trainer, TrainerOptions};
let board = ["Ks", "Th", "7s", "4d", "2s"]
.iter()
.map(|card| card.parse())
.collect::<Result<Vec<Card>, _>>()?;
let config = GameConfig::new(board.clone(), Chips::whole(100), Chips::whole(100))
.with_bet_sizes([0.5, 1.0]);
// Remove combos that share a card with the board.
let dead = CardSet::from_cards(&board);
let oop = "AA,KK,KQs,QJs,JTs:0.5".parse::<Range>()?.combos(dead);
let ip = "AKs,KJs,TT,99,A5s:0.5".parse::<Range>()?.combos(dead);
let mut trainer = Trainer::new(build_tree(&config)?, [oop, ip], TrainerOptions::default())?;
trainer.train(500);
// How much a best response could still gain, in chips.
assert!(trainer.exploitability().total < 1.0);See conventions for units and value normalization, and
algorithms for the update rules.
Re-exports§
pub use card::Card;pub use card::CardParseError;pub use card::CardSet;pub use eval::evaluate_5;pub use eval::evaluate_7;pub use eval::HandCategory;pub use eval::HandStrength;pub use range::all_canonical_hands;pub use range::Combo;pub use range::Range;pub use range::RangeError;pub use solver::build_tree;pub use solver::build_tree_bounded;pub use solver::Action;pub use solver::BoardError;pub use solver::CardAbstraction;pub use solver::Chips;pub use solver::Evaluation;pub use solver::Exploitability;pub use solver::GameConfig;pub use solver::Node;pub use solver::NodeEvaluation;pub use solver::Player;pub use solver::Policy;pub use solver::PolicyError;pub use solver::SolverAlgorithm;pub use solver::SolverGame;pub use solver::Terminal;pub use solver::Trainer;pub use solver::TrainerError;pub use solver::TrainerOptions;pub use solver::Tree;pub use solver::TreeError;pub use solver::UpdateSchedule;pub use solver::CHIP_SCALE;
Modules§
- algorithms
- Algorithms
- card
- Cards and card sets. A
Cardis one of the 52 cards of a standard deck; aCardSetis a set of cards packed into a bitmask for fast membership and removal checks. - conventions
- Conventions
- eval
- Poker hand strength:
evaluate_5for exactly five cards andevaluate_7for the best five of seven (two hole cards and a board). - range
- Hand ranges: the standard 169 canonical starting hands (e.g. “AKs”,
“AKo”, “AA”), each with a weight in
0.0..=1.0, expandable into concrete card-pair combos with dead-card removal applied. - solver
- Heads-up postflop NLHE: a multi-street betting tree and combo-vectorized CFR trainer. No side pots or multiway games.