Secures the worktree's uncommitted state before merging into main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
56 lines
2.6 KiB
Rust
56 lines
2.6 KiB
Rust
//! Game (a): push / fold, one caller.
|
|
//!
|
|
//! The first actor at `seat` jams `depth_bb` (effective stack, blinds 0.5 / 1) or folds. If the
|
|
//! players behind fold -- probability `field_folds(players_behind)` -- the big blind calls or
|
|
//! folds. Otherwise somebody behind wakes up with a hand of the top `WAKE_FRACTION` range and
|
|
//! calls: the jam then runs into that range at raw equity (blinds are dead money, pot
|
|
//! `2 * depth + 1.5`) and nobody decides anything.
|
|
//!
|
|
//! Decisions: `push` (player 0: fold / push) and `call` (player 1, the big blind: fold / call).
|
|
//! The same tree is the complete all-in-or-fold game (variant AOF): there every action is a jam.
|
|
|
|
use super::environment::Environment;
|
|
use super::hand_class::CLASS_COUNT;
|
|
use super::payoffs::all_in;
|
|
use super::seat::Seat;
|
|
use super::spot_params::{field_folds, BIG_BLIND, SMALL_BLIND};
|
|
use super::tree::{Node, Payoff, Tree};
|
|
use super::wake_range::{equity_against, top_membership};
|
|
use super::spot_params::WAKE_FRACTION;
|
|
use crate::fault::Fault;
|
|
|
|
/// Smallest stack for which a jam is a raise at all.
|
|
const MIN_DEPTH: f64 = 1.5;
|
|
|
|
pub fn push_fold_tree(env: &Environment, seat: Seat, depth_bb: f64) -> Result<Tree, Fault> {
|
|
if !depth_bb.is_finite() || depth_bb < MIN_DEPTH {
|
|
return Err(Fault::Invalid { field: "depth_bb".into(), detail: "stack must be at least 1.5 bb".into() });
|
|
}
|
|
let s = depth_bb;
|
|
let dead = seat.dead_money() + env.antes;
|
|
let wake = equity_against(env, &top_membership(env, WAKE_FRACTION));
|
|
let wake_pot = 2.0 * s + SMALL_BLIND + BIG_BLIND + env.antes;
|
|
let wake_pot = wake_pot - env.rake.all_in(wake_pot);
|
|
let wake_payoff = Payoff::Own(wake.iter().map(|e| e * wake_pot - s).collect());
|
|
let r = field_folds(seat.players_behind());
|
|
|
|
// Built bottom-up; indices are fixed by push order.
|
|
let mut nodes: Vec<Node> = Vec::new();
|
|
let mut add = |node: Node| -> usize {
|
|
nodes.push(node);
|
|
nodes.len() - 1
|
|
};
|
|
let t_fold = add(Node::Terminal(Payoff::Flat(-seat.posted_blind())));
|
|
let t_big_blind_folds = add(Node::Terminal(Payoff::Flat(BIG_BLIND + dead)));
|
|
let t_called = add(Node::Terminal(all_in(env, 2.0 * s + dead, s)));
|
|
let call = add(Node::Decision { player: 1, name: "call", children: vec![t_big_blind_folds, t_called] });
|
|
let pushed = if r < 1.0 {
|
|
let t_woken = add(Node::Terminal(wake_payoff));
|
|
add(Node::Chance(vec![(r, call), (1.0 - r, t_woken)]))
|
|
} else {
|
|
call
|
|
};
|
|
let root = add(Node::Decision { player: 0, name: "push", children: vec![t_fold, pushed] });
|
|
Ok(Tree { classes: CLASS_COUNT, chance: env.chance.joint(), nodes, root })
|
|
}
|