Files
pokerfreak/tests/engine_choose_postflop.rs
T
mmintel 55dff14ac2 Postflop: knappe Fold-oder-Call-Spots entschlossen statt ABSTAIN (Owner 8.11.)
Eine Weltklasse-Engine entscheidet jeden knappen Spot selbst. Das alte
Unsicherheitsband um den Breakpoint gab ABSTAIN zurueck -> live FOLD und
foldete so die rausch-nahe +EV-Call-SEITE weg (Overfold, bes. Flop/Turn
mit grossem std_error; PLO5-Benchmark-Defekt). Der call_margin bleibt die
Call-Schwelle (scored erzwingt sie); nur die Enthaltung faellt weg, der
EV-maximale winner entscheidet. Das marginale Raise-Band (Spew-Schutz)
und der Invalid-Equity-ABSTAIN bleiben.

Verifiziert: Cash-Benchmark +2.06 bb/100 'nicht unterscheidbar' (keine
Regression), PLO5-Benchmark rc 1->0 (Defekt behoben), River-Sonde 0 Leck,
engine_choose_postflop/engine_uncertainty gruen, AoF/Kurzstack 40 gruen.
Pre-existing reds unberuehrt (cfr_multi Chart-Drift; pipeline_tournament +
icm_bubble = ICM-Defense-Verengung flippt auf CFR-FacingJam-Spots 0 Haende,
eigener Hebel).
2026-11-08 09:25:03 +01:00

143 lines
5.3 KiB
Rust

mod spot_fixture;
use rechner::engine::postflop::choose_postflop;
use rechner::exploit::thresholds::Thresholds;
use rechner::game::{ActionKind, Choice, Spot};
use rechner::sizing::candidates::candidates;
use spot_fixture::*;
const BASE: Thresholds = Thresholds::BASE;
// round_flop: pot 10, 5 to call -> break-even exactly 1/3.
#[test]
fn clear_call_when_equity_beats_the_price() {
let d = choose_postflop(&round_flop(), &estimate(0.45, 0.005), &BASE, &neutral_read());
assert_eq!(d.choice, Choice::Call);
assert!(d.reason.contains("equity 0.45"), "{}", d.reason);
assert!(d.reason.contains("break-even 0.33"), "{}", d.reason);
assert!(d.reason.contains("EV"), "{}", d.reason);
}
#[test]
fn clear_fold_when_equity_is_far_below_the_price() {
let d = choose_postflop(&round_flop(), &estimate(0.15, 0.005), &BASE, &neutral_read());
assert_eq!(d.choice, Choice::Fold);
}
#[test]
fn decides_just_below_the_breakpoint() {
// Weltklasse-Linie (Owner 8.11.): knapp unter dem Breakpoint (0.3533) wird entschlossen
// gefoldet, nicht enthalten - die Engine spielt jeden knappen Spot selbst.
let d = choose_postflop(&round_flop(), &estimate(0.34, 0.005), &BASE, &neutral_read());
assert_eq!(d.choice, Choice::Fold);
}
#[test]
fn a_plus_ev_call_is_taken_despite_noise() {
// Over the breakpoint (0.3533) the call is +EV and is TAKEN even with a noisy estimate - the
// old uncertainty band abstained (-> live fold) the +EV call side away (Owner 8.11., leak fix).
let noisy = choose_postflop(&round_flop(), &estimate(0.38, 0.02), &BASE, &neutral_read());
assert_eq!(noisy.choice, Choice::Call);
let tight = choose_postflop(&round_flop(), &estimate(0.38, 0.001), &BASE, &neutral_read());
assert_eq!(tight.choice, Choice::Call);
}
#[test]
fn call_margin_is_required_above_break_even() {
let thresholds = Thresholds { abstain_band: 0.0, call_margin: 0.05, ..BASE };
// 0.36 is above break-even (0.333) but below break-even + margin (0.383)
let d = choose_postflop(&round_flop(), &estimate(0.36, 0.0), &thresholds, &neutral_read());
assert_eq!(d.choice, Choice::Fold);
}
#[test]
fn value_raise_when_equity_is_high() {
let spot = round_flop();
let d = choose_postflop(&spot, &estimate(0.80, 0.005), &BASE, &neutral_read());
match d.choice {
Choice::Raise { to } => assert!(candidates(&spot).contains(&to), "{to}"),
other => panic!("expected a raise, got {other:?}"),
}
}
#[test]
fn no_raise_below_the_value_threshold() {
let d = choose_postflop(&round_flop(), &estimate(0.50, 0.005), &BASE, &neutral_read());
assert_eq!(d.choice, Choice::Call);
}
#[test]
fn value_threshold_comes_from_the_thresholds() {
let eager = Thresholds { value_raise: 0.45, ..BASE };
let d = choose_postflop(&round_flop(), &estimate(0.50, 0.005), &eager, &neutral_read());
assert!(matches!(d.choice, Choice::Raise { .. }), "{d:?}");
}
#[test]
fn checks_when_free_and_weak() {
let spot = Spot { to_call: 0.0, legal: vec![ActionKind::Check, ActionKind::Raise], ..round_flop() };
let d = choose_postflop(&spot, &estimate(0.30, 0.005), &BASE, &neutral_read());
assert_eq!(d.choice, Choice::Check);
}
#[test]
fn raises_when_free_and_strong() {
let spot = Spot { to_call: 0.0, legal: vec![ActionKind::Check, ActionKind::Raise], ..round_flop() };
let d = choose_postflop(&spot, &estimate(0.90, 0.005), &BASE, &neutral_read());
assert!(matches!(d.choice, Choice::Raise { .. }), "{d:?}");
}
#[test]
fn never_folds_when_check_is_legal() {
let spot = Spot {
to_call: 0.0,
legal: vec![ActionKind::Fold, ActionKind::Check],
..round_flop()
};
for share in [0.0, 0.05, 0.3, 0.9] {
let d = choose_postflop(&spot, &estimate(share, 0.005), &BASE, &neutral_read());
assert_eq!(d.choice, Choice::Check, "share {share}");
}
}
#[test]
fn call_when_fold_and_check_are_not_available() {
let spot = Spot { legal: vec![ActionKind::Call], ..round_flop() };
let d = choose_postflop(&spot, &estimate(0.10, 0.005), &BASE, &neutral_read());
assert_eq!(d.choice, Choice::Call);
}
#[test]
fn raises_come_from_allowed_sizes_verbatim() {
let spot = Spot { allowed_sizes: Some(vec![20.0, 40.0]), ..round_flop() };
let d = choose_postflop(&spot, &estimate(0.85, 0.005), &BASE, &neutral_read());
match d.choice {
Choice::Raise { to } => assert!(to == 20.0 || to == 40.0, "{to}"),
other => panic!("expected a raise, got {other:?}"),
}
}
#[test]
fn raise_without_candidates_falls_back_to_the_passive_line() {
let spot = Spot { allowed_sizes: Some(vec![500.0]), ..round_flop() };
let d = choose_postflop(&spot, &estimate(0.85, 0.005), &BASE, &neutral_read());
assert_eq!(d.choice, Choice::Call);
}
#[test]
fn non_finite_equity_abstains() {
let d = choose_postflop(&round_flop(), &estimate(f64::NAN, 0.0), &BASE, &neutral_read());
assert_eq!(d.choice, Choice::Abstain);
}
#[test]
fn confidence_grows_with_distance_from_the_breakpoint() {
let near = choose_postflop(&round_flop(), &estimate(0.40, 0.001), &BASE, &neutral_read());
let far = choose_postflop(&round_flop(), &estimate(0.55, 0.001), &BASE, &neutral_read());
assert_eq!(near.choice, Choice::Call);
assert_eq!(far.choice, Choice::Call);
assert!(far.confidence > near.confidence);
assert!(far.confidence.value() <= 1.0 && near.confidence.value() > 0.0);
}