Files
pokerfreak/tests/spot_fixture/mod.rs
T

80 lines
2.2 KiB
Rust

#![allow(dead_code)]
//! Shared builders for spots, estimates and plans used by the engine-side tests.
use pokerfreak::card::Card;
use pokerfreak::equity::estimate::Estimate;
use pokerfreak::game::{ActionKind, Spot, Street, Villain};
use pokerfreak::preflop::plan::{ChartAction, PreflopPlan};
use pokerfreak::variant::Variant;
pub fn cards(text: &str) -> Vec<Card> {
Card::parse_list(text).expect("fixture cards")
}
pub fn villain(seat: u8) -> Villain {
Villain { seat, stack: 10.0, folded: false, profile: None }
}
/// NLHE flop, hero Ah5h on Ac7d2s, pot 1.25, 0.2 to call, stack 2.4.
pub fn flop() -> Spot {
Spot {
variant: Variant::Nlhe,
big_blind: 0.1,
seats: 6,
hero_seat: 5,
button_seat: None,
hero_cards: cards("Ah 5h"),
board: cards("Ac 7d 2s"),
street: Street::Flop,
pot: 1.25,
to_call: 0.2,
hero_stack: 2.4,
min_raise_to: Some(0.5),
max_raise_to: Some(20.0),
legal: vec![ActionKind::Fold, ActionKind::Call, ActionKind::Raise],
allowed_sizes: None,
villains: vec![villain(2)],
seed: 1,
history: Vec::new(),
}
}
/// Round numbers: pot 10, 5 to call, deep stack. Break-even is exactly 1/3.
pub fn round_flop() -> Spot {
Spot {
pot: 10.0,
to_call: 5.0,
hero_stack: 100.0,
min_raise_to: Some(10.0),
max_raise_to: Some(100.0),
..flop()
}
}
/// Preflop NLHE, hero SB-ish: pot 0.15, 0.1 to call, stack 10.
pub fn preflop() -> Spot {
Spot {
board: vec![],
street: Street::Preflop,
pot: 0.15,
to_call: 0.1,
hero_stack: 10.0,
min_raise_to: Some(0.2),
max_raise_to: Some(10.0),
..flop()
}
}
pub fn with_variant(spot: Spot, variant: Variant) -> Spot {
let hole = if variant == Variant::Plo5 { "Ah 5h Kd Qc 9s" } else { "Ah 5h" };
Spot { variant, hero_cards: cards(hole), ..spot }
}
pub fn estimate(share: f64, std_error: f64) -> Estimate {
Estimate { win: share, tie: 0.0, share, trials: 3000, std_error }
}
pub fn plan(action: ChartAction, certainty: f64) -> PreflopPlan {
PreflopPlan { action, percentile: 0.1, certainty, reason: "chart".to_string() }
}