//! Probe (ignored, prints only): do the attack reads reach the decision? Bet / steal frequency over a //! fixed hand sample as the villain's fold reads vary. `cargo test --release --test probe_angriff -- --ignored --nocapture` mod spot_fixture; use rechner::card::{deck, Card}; use rechner::engine::decide::decide; use rechner::exploit::profile::Profile; use rechner::game::{ActionKind, ActionRecord, Choice, SeenAction, Spot, Street, Villain}; use rechner::rng::Rng; use rechner::variant::Variant; use spot_fixture::cards; fn rec(street: Street, seat: u8, action: SeenAction, amount: Option) -> ActionRecord { ActionRecord { street, seat, action, amount } } fn hands(board: &[Card], n: usize) -> Vec> { let pool = deck::without(board); let mut rng = Rng::seeded(7); let mut out = Vec::new(); while out.len() < n { let (h, next) = deck::draw(&pool, 2, rng).unwrap(); rng = next; out.push(h); } out } fn base() -> Profile { Profile { vpip: Some(0.25), pfr: Some(0.05), aggression: Some(0.30), aggression_confidence: Some(0.9), confidence: Some(0.9), ..Profile::default() } } fn spot(board: &str, street: Street, to_call: f64, pot: f64, history: Vec, hero: Vec, p: Option, seed: u64) -> Spot { Spot { variant: Variant::Nlhe, big_blind: 1.0, seats: 2, hero_seat: 1, button_seat: Some(1), hero_cards: hero, board: cards(board), street, pot, to_call, hero_stack: 100.0 - (pot - to_call) / 2.0, min_raise_to: Some(if to_call > 0.0 { 2.0 } else { 1.0 }), max_raise_to: Some(100.0), legal: if to_call > 0.0 { vec![ActionKind::Fold, ActionKind::Call, ActionKind::Raise] } else { vec![ActionKind::Fold, ActionKind::Check, ActionKind::Raise] }, allowed_sizes: None, villains: vec![Villain { seat: 2, stack: 97.5, folded: false, profile: p }], seed, history, } } fn freq(label: &str, make: &dyn Fn(Vec, u64) -> Spot, board: &[Card]) { let hs = hands(board, 400); let (mut raise, mut fold, mut size) = (0, 0, 0.0); for (i, h) in hs.into_iter().enumerate() { match decide(&make(h, i as u64 + 1)).choice { Choice::Raise { to } => { raise += 1; size += to; } Choice::Fold => fold += 1, _ => {} } } println!(" {label:<34} raise {:>5.1} % fold {:>5.1} % mean to {:.2}", raise as f64 / 4.0, fold as f64 / 4.0, if raise > 0 { size / raise as f64 } else { 0.0 }); } #[test] #[ignore] fn attack_reads_reach_the_decision() { let board = "Kd 8h 3c"; let pre = 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), ]; println!("C-Bet IP nach Check (Kd8h3c, Topf 5):"); let variants: Vec<(String, Option)> = vec![ ("blind".into(), None), ("base (keine Fold-Reads)".into(), Some(base())), ("foldToBet 0.30".into(), Some(Profile { fold_to_bet: Some(0.30), ..base() })), ("foldToBet 0.45".into(), Some(Profile { fold_to_bet: Some(0.45), ..base() })), ("foldToBet 0.60".into(), Some(Profile { fold_to_bet: Some(0.60), ..base() })), ("foldToBet 0.75".into(), Some(Profile { fold_to_bet: Some(0.75), ..base() })), ("foldToCbet 0.65".into(), Some(Profile { fold_to_cbet: Some(0.65), ..base() })), ("foldToBet 0.60 + foldToCbet 0.65".into(), Some(Profile { fold_to_bet: Some(0.60), fold_to_cbet: Some(0.65), ..base() })), ("foldToBet 0.60 Flop-Strasse 0.60".into(), Some(Profile { fold_to_bet: Some(0.60), street_fold_to_bet: [Some(0.60), None, None], ..base() })), ]; let b = cards(board); for (l, p) in &variants { freq(l, &|h, s| spot(board, Street::Flop, 0.0, 5.0, pre.clone(), h, *p, s), &b); } println!("Steal SB/BTN HU (Topf 1,5, 0,5 zu zahlen):"); let pf = vec![ rec(Street::Preflop, 1, SeenAction::PostSmallBlind, Some(0.5)), rec(Street::Preflop, 2, SeenAction::PostBigBlind, Some(1.0)), ]; let pv: Vec<(String, Option)> = vec![ ("blind".into(), None), ("base".into(), Some(base())), ("foldToSteal 0.80".into(), Some(Profile { fold_to_steal: Some(0.80), ..base() })), ("foldToSteal 0.40".into(), Some(Profile { fold_to_steal: Some(0.40), ..base() })), ("pfr 0.02 vpip 0.20".into(), Some(Profile { pfr: Some(0.02), vpip: Some(0.20), ..base() })), ("threeBet 0.02 foldToSteal 0.75".into(), Some(Profile { three_bet: Some(0.02), fold_to_steal: Some(0.75), ..base() })), ]; for (l, p) in &pv { freq(l, &|h, s| spot("", Street::Preflop, 0.5, 1.5, pf.clone(), h, *p, s), &[]); } } #[test] #[ignore] fn reasons_of_a_few_hands() { let board = "Kd 8h 3c"; let pre = 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), ]; for hand in ["Qs Jh", "7s 6s", "Ah 4h", "9c 9d", "Ks Qc", "5d 4d"] { for p in [None, Some(Profile { fold_to_bet: Some(0.75), fold_to_cbet: Some(0.75), ..base() })] { let d = decide(&spot(board, Street::Flop, 0.0, 5.0, pre.clone(), cards(hand), p, 3)); println!("{hand} {:>5}: {:?} | {}", if p.is_some() { "fold" } else { "blind" }, d.choice, d.reason); } } } #[test] #[ignore] fn fold_chance_of_the_cbet() { use rechner::exploit::table_fold::table_fold; let pre = 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), ]; for p in [None, Some(base()), Some(Profile { fold_to_bet: Some(0.75), fold_to_cbet: Some(0.75), ..base() })] { let s = spot("Kd 8h 3c", Street::Flop, 0.0, 5.0, pre.clone(), cards("Qs Jh"), p, 3); println!("FE {:?}: 1.67 -> {:.3}, 3.33 -> {:.3}", p.map(|x| x.fold_to_cbet), table_fold(&s, 1.67, 1.0), table_fold(&s, 3.33, 1.0)); } } #[test] #[ignore] fn classes_of_the_pool_reads() { use rechner::engine::read_gate::exploit_worthy; use rechner::exploit::style::classify; // Memory reads of pool-nl2 (diag_welt READ k0/k1, 15.11.) and of the counted path. let reads = [ ("pool-nl2 k0", Profile { vpip: Some(0.20), pfr: Some(0.022), fold_to_bet: Some(0.50), aggression: Some(0.34), confidence: Some(0.7), ..Profile::default() }), ("pool-nl2 k1", Profile { vpip: Some(0.32), pfr: Some(0.027), fold_to_bet: Some(0.46), aggression: Some(0.35), confidence: Some(0.75), ..Profile::default() }), ("pool-nl2 gez", Profile { vpip: Some(0.21), pfr: Some(0.029), fold_to_bet: Some(0.50), fold_to_cbet: Some(0.65), aggression: Some(0.34), confidence: Some(0.95), aggression_confidence: Some(0.89), ..Profile::default() }), ("real NL2 foldToBet 0.566", Profile { vpip: Some(0.25), pfr: Some(0.08), fold_to_bet: Some(0.566), fold_to_cbet: Some(0.495), aggression: Some(0.32), confidence: Some(0.9), aggression_confidence: Some(0.9), ..Profile::default() }), ]; for (l, p) in reads { println!("CLASS {l:<26} {:?} trusted {}", classify(&p), exploit_worthy(classify(&p))); } }