Files
pokerfreak/tests/line_reads.rs
T
mmintelandClaude Opus 5.5 ff418fe005 River-DBR (Roadmap #1) gemessen: Verlierer, Arm bleibt aus
Data-Biased Robust Counter-Strategy (cfr::dbr) als Heads-up-River-Spieler mit
Read-Konfidenz je Knoten. Leiter gegen zaehl: -32.74 +-2.91 bb/100, alle
gemessenen Profile verlieren, auch balancierte. Arm RIVER_DBR aus, aus = bit-identisch.
Dazu: Zaehlungen je Read (COUNTS=1, eich_sim.py), Session-Memory-API,
geparktes Check-Raise-Modell (RAISE_MODEL, aus).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 22:45:51 +01:00

130 lines
5.8 KiB
Rust

//! The line-specific HUD reads reach hero's decisions: a light 3-bet against a 3-bet folder, the
//! fold-to-c-bet read pricing hero's c-bet.
use rechner::card::Card;
use rechner::exploit::profile::Profile;
use rechner::exploit::table_fold::table_fold;
use rechner::exploit::thresholds::Thresholds;
use rechner::game::{ActionKind, ActionRecord, SeenAction, Spot, Street, Villain};
use rechner::preflop::advise::advise;
use rechner::preflop::plan::ChartAction;
use rechner::variant::Variant;
fn rec(street: Street, seat: u8, action: SeenAction, amount: Option<f64>) -> ActionRecord {
ActionRecord { street, seat, action, amount }
}
/// Heads-up, hero big blind (seat 2), the button/small blind (seat 1) opened to 2.5.
fn bb_vs_open(hole: &str, profile: Option<Profile>) -> Spot {
Spot {
variant: Variant::Nlhe,
big_blind: 1.0,
seats: 2,
hero_seat: 2,
button_seat: Some(1),
hero_cards: Card::parse_list(hole).expect("cards"),
board: vec![],
street: Street::Preflop,
pot: 3.5,
to_call: 1.5,
hero_stack: 99.0,
min_raise_to: Some(4.0),
max_raise_to: Some(100.0),
legal: vec![ActionKind::Fold, ActionKind::Call, ActionKind::Raise],
allowed_sizes: None,
villains: vec![Villain { seat: 1, stack: 97.5, folded: false, profile }],
seed: 1,
history: vec![
rec(Street::Preflop, 1, SeenAction::PostSmallBlind, Some(0.5)),
rec(Street::Preflop, 2, SeenAction::PostBigBlind, Some(1.0)),
rec(Street::Preflop, 1, SeenAction::Raise, Some(2.5)),
],
}
}
#[test]
fn a_three_bet_folder_gets_three_bet_light() {
// Find a hand the chart folds, inside the light band.
let folds = ["Q2o", "J3o", "T4o", "K2o", "94s", "Q4o", "J5o", "T6o", "K3o", "85s", "72o", "83o", "92o", "T2o", "J2o", "64o", "53o", "T3o"];
let to_cards = |h: &str| {
let b = h.as_bytes();
let (r1, r2) = (b[0] as char, b[1] as char);
if b[2] == b's' { format!("{r1}h {r2}h") } else { format!("{r1}h {r2}d") }
};
let folder = Profile { fold_to_three_bet: Some(0.9), ..Profile::default() };
let sticky = Profile { fold_to_three_bet: Some(0.3), ..Profile::default() };
let mut tried = 0;
for h in folds {
let blind = advise(&bb_vs_open(&to_cards(h), None), &Thresholds::BASE);
if blind.action == ChartAction::Raise || (blind.action == ChartAction::Fold && blind.percentile > 0.85) {
continue;
}
tried += 1;
let vs = advise(&bb_vs_open(&to_cards(h), Some(folder)), &Thresholds::BASE);
assert_eq!(vs.action, ChartAction::Raise, "{h}: {}", vs.reason);
assert!(vs.reason.contains("light 3-bet"));
assert_eq!(advise(&bb_vs_open(&to_cards(h), Some(sticky)), &Thresholds::BASE).action, blind.action);
}
assert!(tried > 0, "no folding hand in the band found");
}
/// Heads-up flop, hero (seat 1) raised preflop, the villain (seat 2) checked to hero.
fn flop_checked_to_hero(profile: Profile) -> Spot {
Spot {
variant: Variant::Nlhe,
big_blind: 1.0,
seats: 2,
hero_seat: 1,
button_seat: Some(1),
hero_cards: Card::parse_list("7h 6h").expect("cards"),
board: Card::parse_list("Ks 9d 2c").expect("board"),
street: Street::Flop,
pot: 5.0,
to_call: 0.0,
hero_stack: 97.5,
min_raise_to: Some(1.0),
max_raise_to: Some(97.5),
legal: vec![ActionKind::Check, ActionKind::Raise],
allowed_sizes: None,
villains: vec![Villain { seat: 2, stack: 97.5, folded: false, profile: Some(profile) }],
seed: 1,
history: vec![
rec(Street::Preflop, 1, SeenAction::PostSmallBlind, Some(0.5)),
rec(Street::Preflop, 2, SeenAction::PostBigBlind, Some(1.0)),
rec(Street::Preflop, 1, SeenAction::Raise, Some(2.5)),
rec(Street::Preflop, 2, SeenAction::Call, Some(2.5)),
rec(Street::Flop, 2, SeenAction::Check, None),
],
}
}
#[test]
fn the_cbet_is_priced_by_fold_to_cbet() {
let base = Profile { vpip: Some(0.3), fold_to_bet: Some(0.4), ..Profile::default() };
let pooled = table_fold(&flop_checked_to_hero(base), 3.0, 1.0);
let folder = table_fold(&flop_checked_to_hero(Profile { fold_to_cbet: Some(0.8), ..base }), 3.0, 1.0);
let sticky = table_fold(&flop_checked_to_hero(Profile { fold_to_cbet: Some(0.2), ..base }), 3.0, 1.0);
assert!(folder > pooled + 0.2 && sticky < pooled - 0.1, "{sticky} {pooled} {folder}");
}
#[test]
fn the_check_raise_sits_in_the_tree() {
use rechner::engine::bluff::{branches, branches_vs_raise, raise_response, RaiseKind};
let quiet = flop_checked_to_hero(Profile::default());
// No raise: exactly the two-branch EV.
assert_eq!(branches_vs_raise(&quiet, 3.0, 0.4, 0.3, RaiseKind::Bluff, 0.0, None), branches(&quiet, 3.0, 0.4, 0.3));
// A raise rate scales the fold branch down (the fold read is fold | fold-or-call) and a bluff loses
// its bet to every raise.
let raised = branches_vs_raise(&quiet, 3.0, 0.4, 0.3, RaiseKind::Bluff, 0.2, None);
let plain = branches(&quiet, 3.0, 0.4, 0.3);
assert!((raised.fold - 0.8 * plain.fold).abs() < 1e-12);
assert!(raised.total < plain.total);
assert_eq!(raise_response(&quiet, 3.0, RaiseKind::Bluff, None), -3.0);
// Thin value calls a bluffy raiser and loses less than the bet; a passive raiser is value: fold.
let maniac = Profile { aggression: Some(0.9), ..Profile::default() };
let passive = Profile { aggression: Some(0.05), ..Profile::default() };
let mut river = flop_checked_to_hero(Profile::default());
river.street = Street::River;
assert!(raise_response(&river, 3.0, RaiseKind::ThinValue, Some(&maniac)) > -3.0);
assert_eq!(raise_response(&river, 3.0, RaiseKind::ThinValue, Some(&passive)), -3.0);
}