Files
pokerfreak/tests/preflop_situation_history.rs
mmintel f2650dc3be Cockpit and runner 5.11. late: no ESC stop, hidden tables stay open, gapless tiling, teacher core
- ESC no longer triggers the emergency stop (an ESC in another app stopped the run at 20:29);
  stopping only via ctrl-opt-cmd-S or the stop button
- a table whose program runs counts as open even when its window is not visible (other
  desktop, Cockpit without screen recording): no reopening, no giving up, correct table
  count; teardown and closing a full table work over the channel
- Cockpit checks and requests the screen recording permission
- gapless tiling (sicht/kacheln.py): tables fill the full height, the Cockpit bar takes the
  rest and never goes below its minimum width; own animated resize no longer stored as minimum
- earlier today: top-up safety net, leave after the hand (sit out next hand), tournament lock,
  waitlist left on close, Cockpit start lock, warning throttle, preflop raise-war reading,
  Bomb Pot practice, tournament break and level-up on the stage
- teacher core for the streamer mode (betrieb/lehrer.py, betrieb/grund_lesen.py) and its plan
2026-11-05 22:39:41 +01:00

127 lines
4.4 KiB
Rust

//! The preflop situation comes from the hand history when there is one.
//!
//! The chip counts alone cannot tell a raise war from an open: on 5.11.2026 (practice table, bb
//! 100) a villain min-re-raised again and again; every time hero had 3 bb to call, which the chip
//! heuristic reads as "vs open" - hero held A-K in the small blind and raised three more times
//! before it saw "vs 3-bet+". The history counts the raises themselves.
//!
//! Six-max, button on seat 3: SB is seat 4, BB seat 5, big blind = 1.0.
use rechner::card::Card;
use rechner::exploit::thresholds::Thresholds;
use rechner::game::{ActionKind, ActionRecord, SeenAction, Spot, Street, Villain};
use rechner::preflop::advise::advise;
use rechner::preflop::situation::{classify, Situation};
use rechner::preflop::situation_of::situation_of;
use rechner::variant::Variant;
const SMALL_BLIND: u8 = 4;
const BIG_BLIND: u8 = 5;
const BUTTON: u8 = 3;
fn record(seat: u8, action: SeenAction, amount: f64) -> ActionRecord {
ActionRecord { street: Street::Preflop, seat, action, amount: Some(amount) }
}
fn blinds() -> Vec<ActionRecord> {
vec![record(SMALL_BLIND, SeenAction::PostSmallBlind, 0.5), record(BIG_BLIND, SeenAction::PostBigBlind, 1.0)]
}
fn spot(hero: u8, hole: &str, history: Vec<ActionRecord>, pot: f64, to_call: f64, hero_stack: f64) -> Spot {
Spot {
variant: Variant::Nlhe,
big_blind: 1.0,
seats: 6,
hero_seat: hero,
button_seat: Some(BUTTON),
hero_cards: Card::parse_list(hole).expect("cards"),
board: vec![],
street: Street::Preflop,
pot,
to_call,
hero_stack,
min_raise_to: Some(9.5),
max_raise_to: Some(hero_stack),
legal: vec![ActionKind::Fold, ActionKind::Call, ActionKind::Raise],
allowed_sizes: None,
villains: (0..6)
.filter(|s| *s != hero)
.map(|seat| Villain { seat, stack: 100.0, folded: false, profile: None })
.collect(),
seed: 1,
history,
}
}
/// 5.11. replayed: four limpers, hero (SB) raises to 3.5, the big blind min-re-raises to 6.5 -
/// 3 bb to call into a pot of 14 bb.
fn raise_war() -> Spot {
let mut h = blinds();
for seat in [0, 1, 2, BUTTON] {
h.push(record(seat, SeenAction::Call, 1.0));
}
h.push(record(SMALL_BLIND, SeenAction::Raise, 3.5));
h.push(record(BIG_BLIND, SeenAction::Raise, 6.5));
spot(SMALL_BLIND, "Ad Ks", h, 14.0, 3.0, 96.5)
}
#[test]
fn a_min_reraise_after_our_raise_is_a_three_bet() {
assert_eq!(situation_of(&raise_war()), Situation::FacingThreeBetPlus);
}
#[test]
fn the_advice_names_the_three_bet() {
let reason = advise(&raise_war(), &Thresholds::BASE).reason;
assert!(reason.contains("vs 3-bet+"), "{reason}");
}
#[test]
fn a_single_min_raise_is_an_open_although_it_costs_one_big_blind() {
// The big blind facing a min-raise to 2: the chip counts see a limp (call 1 bb).
let mut h = blinds();
h.push(record(0, SeenAction::Raise, 2.0));
let s = spot(BIG_BLIND, "9h 9c", h, 3.5, 1.0, 99.0);
assert_eq!(situation_of(&s), Situation::FacingOpen);
}
#[test]
fn limpers_without_a_raise_are_a_limped_pot() {
let mut h = blinds();
h.push(record(0, SeenAction::Call, 1.0));
let s = spot(SMALL_BLIND, "7h 6h", h, 2.5, 0.5, 99.5);
assert_eq!(situation_of(&s), Situation::FacingLimp);
}
#[test]
fn only_the_blinds_is_unopened() {
let s = spot(BUTTON, "7h 6h", blinds(), 1.5, 1.0, 100.0);
assert_eq!(situation_of(&s), Situation::Unopened);
}
#[test]
fn a_short_jam_over_an_open_counts_as_a_raise() {
// Open to 2.5, a short stack jams to 4: 4 bb to call into 8 bb looks like an open by chips.
let mut h = blinds();
h.push(record(0, SeenAction::Raise, 2.5));
h.push(record(1, SeenAction::AllIn, 4.0));
let s = spot(BUTTON, "Qs Qd", h, 8.0, 4.0, 100.0);
assert_eq!(situation_of(&s), Situation::FacingThreeBetPlus);
}
#[test]
fn facing_more_than_the_stack_stays_all_in() {
let mut h = blinds();
h.push(record(0, SeenAction::Raise, 2.5));
let s = spot(BIG_BLIND, "Qs Qd", h, 4.0, 1.5, 1.5);
assert_eq!(situation_of(&s), Situation::FacingAllIn);
}
#[test]
fn without_history_the_chip_counts_decide() {
let mut s = raise_war();
s.history.clear();
assert_eq!(situation_of(&s), classify(s.to_call, s.big_blind, s.pot, s.hero_stack));
assert_eq!(situation_of(&s), Situation::FacingOpen);
}