Files
pokerfreak/src/cfr/open_game.rs
T
mmintelandClaude Opus 5.5 09d2014c9e Merge rake-live (c8257b4): Mikro-Rake; chartgen --mikro = ohne Antes + Mikro-Rake, Fold-Rake
Ein Tabellenlauf fuer den Live-Mikro-Tisch (Absprache rake-live, Orchestrator):
- chartgen --mikro: Antes 0 UND ChartRake::Micro, fuer charts, multi, multi-deep
  und teilspiel. --ohne-ante und --rake mikro bleiben einzeln nutzbar.
- ChartRake::fold: ein durch Fold gewonnener Pot zahlt beim Mikro-Rake den
  Rake des gematchten Pots (live: 3-bet/fold 5,5 bb -> 0,5 bb). Gilt in allen
  sechs Spielen (open, open3, push/fold, push/fold3, multi, teilspiel).
  Measured/None: 0, also bit-identisch (eingefrorene Tabellen reproduzieren).
- generated_charts_short.rs: Renderer-Ausgabe zurueck (Leerzeichen).
- tests/chart_fold_rake.rs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 01:18:12 +01:00

92 lines
4.1 KiB
Rust

//! Game (b): open / call / 3-bet, one defender (the big blind). More defenders: `multi_tree`.
//!
//! The first actor at `seat` folds or raises to `OPEN_SIZE` (`SMALL_BLIND_OPEN_SIZE` from the
//! small blind). If the players behind fold the big blind folds, calls or 3-bets to
//! `THREE_BET_SIZE`; otherwise (probability `1 - field_folds`) a hand of the top `WAKE_FRACTION`
//! range calls the open and the opener plays that pot with the equity of his class against the
//! range, out of position unless he is on the button.
//!
//! Versus the 3-bet the opener folds, calls or jams; the big blind then calls or folds the jam.
//! Calls that leave chips behind end in a postflop payoff (pot x realised equity, see
//! `spot_params`); jams are raw all-in equity.
//!
//! Decisions: `open` (P0: fold / raise), `defend` (P1: fold / call / 3-bet),
//! `vs_three_bet` (P0: fold / call / jam), `vs_jam` (P1: fold / call).
use super::environment::Environment;
use super::hand_class::CLASS_COUNT;
use super::payoffs::{all_in, postflop, share};
use super::seat::Seat;
use super::spot_params::{
field_folds, BIG_BLIND, OPEN_SIZE, REALIZATION_OOP_SINGLE_RAISED, REALIZATION_OOP_THREE_BET,
SMALL_BLIND, SMALL_BLIND_OPEN_SIZE, THREE_BET_SIZE, WAKE_FRACTION,
};
use super::tree::{fold_leaf, Node, Payoff, Tree};
use super::wake_range::{equity_against, top_membership};
use crate::fault::Fault;
pub fn open_size(seat: Seat) -> f64 {
if seat == Seat::SmallBlind {
SMALL_BLIND_OPEN_SIZE
} else {
OPEN_SIZE
}
}
pub fn open_tree(env: &Environment, seat: Seat, depth_bb: f64) -> Result<Tree, Fault> {
if !depth_bb.is_finite() || depth_bb <= THREE_BET_SIZE {
return Err(Fault::Invalid {
field: "depth_bb".into(),
detail: "stack must exceed the 3-bet size".into(),
});
}
let (s, x, y) = (depth_bb, open_size(seat), THREE_BET_SIZE);
let dead = seat.dead_money() + env.antes;
let ip = seat.is_in_position_against_big_blind();
let r = field_folds(seat.players_behind());
let wake = equity_against(env, &top_membership(env, WAKE_FRACTION));
let wake_ip = seat == Seat::Button;
let wake_pot = 2.0 * x + SMALL_BLIND + BIG_BLIND + env.antes;
let wake_pot = wake_pot - env.rake.postflop(wake_pot);
let wake_payoff = Payoff::Own(
wake.iter()
.map(|e| wake_pot * share(*e, wake_ip, REALIZATION_OOP_SINGLE_RAISED) - x)
.collect(),
);
let mut nodes: Vec<Node> = Vec::new();
let mut add = |node: Node| -> usize {
nodes.push(node);
nodes.len() - 1
};
let t_open_fold = add(Node::Terminal(Payoff::Flat(-seat.posted_blind())));
// Fold leaves pay the rake of the matched pot (`ChartRake::fold`; only the micro rake has one).
let fold = |p0: f64, pot: f64| fold_leaf(CLASS_COUNT, p0, env.rake.fold(pot));
let t_big_blind_folds = add(Node::Terminal(fold(BIG_BLIND + dead, 2.0 * BIG_BLIND + dead)));
let t_called = add(Node::Terminal(postflop(env, 2.0 * x + dead, x, ip, REALIZATION_OOP_SINGLE_RAISED)));
let t_opener_folds = add(Node::Terminal(fold(-x, 2.0 * x + dead)));
let t_three_bet_called =
add(Node::Terminal(postflop(env, 2.0 * y + dead, y, ip, REALIZATION_OOP_THREE_BET)));
let t_jam_folded = add(Node::Terminal(fold(y + dead, 2.0 * y + dead)));
let t_jam_called = add(Node::Terminal(all_in(env, 2.0 * s + dead, s)));
let vs_jam = add(Node::Decision { player: 1, name: "vs_jam", children: vec![t_jam_folded, t_jam_called] });
let vs_three_bet = add(Node::Decision {
player: 0,
name: "vs_three_bet",
children: vec![t_opener_folds, t_three_bet_called, vs_jam],
});
let defend = add(Node::Decision {
player: 1,
name: "defend",
children: vec![t_big_blind_folds, t_called, vs_three_bet],
});
let raised = if r < 1.0 {
let t_woken = add(Node::Terminal(wake_payoff));
add(Node::Chance(vec![(r, defend), (1.0 - r, t_woken)]))
} else {
defend
};
let root = add(Node::Decision { player: 0, name: "open", children: vec![t_open_fold, raised] });
Ok(Tree { classes: CLASS_COUNT, chance: env.chance.joint(), nodes, root })
}