Die Welt nannte 'pokerfreak' nur noch in zwei Harness-Zeilen - der Rest waren veraltete Rust-Pruefungen im Pruefordner, die der Aufbau nie auffrischte.
116 lines
3.3 KiB
Rust
116 lines
3.3 KiB
Rust
#![allow(dead_code)]
|
|
//! Shared builders for spots, estimates and plans used by the engine-side tests.
|
|
|
|
use rechner::card::Card;
|
|
use rechner::equity::estimate::Estimate;
|
|
use rechner::game::{ActionKind, Spot, Street, Villain};
|
|
use rechner::preflop::plan::{ChartAction, PreflopPlan};
|
|
use rechner::read::draw::Draw;
|
|
use rechner::read::hand_read::HandRead;
|
|
use rechner::read::made::Made;
|
|
use rechner::read::pairing::Pairing;
|
|
use rechner::read::suit_pattern::SuitPattern;
|
|
use rechner::read::texture::Texture;
|
|
use rechner::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 = match variant {
|
|
Variant::Plo5 => "Ah 5h Kd Qc 9s",
|
|
Variant::Plo4 => "Ah 5h Kd Qc",
|
|
_ => "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() }
|
|
}
|
|
|
|
/// A hand read built from parts (no board analysis involved).
|
|
pub fn read_of(made: Made, draw: Draw, outs: u8, suits: SuitPattern, wetness: f64) -> HandRead {
|
|
HandRead {
|
|
made,
|
|
draw,
|
|
outs,
|
|
nut_draw: false,
|
|
texture: Texture { suits, pairing: Pairing::Unpaired, connectivity: 2, high: None, wetness },
|
|
}
|
|
}
|
|
|
|
/// A monster on a medium board: no texture rule moves any threshold for it.
|
|
pub fn neutral_read() -> HandRead {
|
|
read_of(Made::Straight, Draw::None, 0, SuitPattern::TwoTone, 0.5)
|
|
}
|
|
|
|
/// Air with a flush draw (9 outs) on a two-tone flop.
|
|
pub fn flush_draw_read() -> HandRead {
|
|
read_of(Made::Air, Draw::Flush, 9, SuitPattern::TwoTone, 0.5)
|
|
}
|
|
|
|
/// `n` villains on seats 1..=n.
|
|
pub fn with_villains(spot: Spot, n: u8) -> Spot {
|
|
Spot { villains: (1..=n).map(villain).collect(), ..spot }
|
|
}
|