//! The stake's measured pool for opponents without their own read (`POOL_STUFE`, off by default; PLAN §8.5, //! 17.11.). Only where the core's built-in anchor is measurably wrong for the stake, never where it fits. //! //! Measured at NL0.01-0.02 (heads-up, villain answering a bet of hero's; `archiv/lauf` 5386 hands since 14.11., //! Rohlogs 2976 hands, `messung/poolruf/ziel-nl2.json`, leak finder `messung/leckfinder/README.md`): //! //! | axis | core today | NL2 measured | used | //! |---|---|---|---| //! | fold at about 2/3 pot | 0.45 | flop 0.40-0.47, turn 0.41-0.48, river 0.44-0.48 | unchanged (fits) | //! | fold to bets over 2/3 pot | rises with size: 0.60 at pot, 0.74 at 1.5x | river pot-plus/all-in 0.30 (n 10), our river all-ins 0.12-0.29 (n 15), NL2 calls 7 of 10 river jams | `groesse` | //! | raise facing a bet (`raiseToBet` anchor) | 0.30 | 0.105 (`lesen/pool.py`, 198 players, κ 105) | `rtb` | //! //! The old `POOL_PRIOR` failed (pool-nl2-echt −8.5) because it put the pooled foldToBet 0.554 in place of 0.45 //! for every street and size: against hero's own bets the pool folds 0.33 (small) to 0.47 (2/3 pot), so it //! over-assumed folds everywhere. Here the reference stays, only the size curve and the raise anchor move. //! //! `groesse`: above `KNEE` pots the fold chance no longer rises with the size; it falls linearly from its //! value at `KNEE` to `BIG_FOLD` at `FULL` pots and stays there. Only lowered, never raised, and only for a //! bet into nothing (`facing_raise` keeps the core's curve). //! Gate 17.11. (`messung/pool_stufe/TOR.md`): a measured LOSER (ladder −1.73, pool-nl2-echt −1.05, SIM_POOLRUF //! pool-nl2 −1.93), it lowers the fold of every big bet, semi-bluffs and protection too. Kept off; live is `rtb`. //! `rtb`: the counted `raiseToBet` / `reraiseToRaise` reads shrink toward `RTB_MU` instead of 0.30, on the //! wire and in the sim memory alike, so an unread opponent is the stake's rare raiser until his own count //! says otherwise. //! //! Stake: `exploit::pool::stage_for` (forced by `GEGNER_POOL_STUFE` on the ladder, else 0.02 → NL0.01-0.02); //! any other stake: off, bit-identical. `POOL_STUFE=` (`groesse`, `rtb`), anything else: off. use std::cell::Cell; pub const STAGE: &str = "NL0.01-0.02"; /// Pot fraction up to which the core's size curve stands (the reference size of `fold_chance`). pub const KNEE: f64 = 0.66; /// Pot fraction (and all-ins beyond) at which the stake's big-bet fold is reached. pub const FULL: f64 = 1.5; /// NL2 fold to a bet of `FULL` pots or more, heads-up. pub const BIG_FOLD: f64 = 0.30; /// NL2 pool mean of raises facing a bet. pub const RTB_MU: f64 = 0.105; /// The core's own anchor of the counted raise reads. pub const RTB_CORE: f64 = 0.30; #[derive(Clone, Copy, Debug, PartialEq, Default)] pub struct Mode { pub size: bool, pub rtb: bool, } thread_local! { static OVERRIDE: Cell>> = const { Cell::new(None) }; /// The stake of the request being decoded (`set_big_blind`), for the wire's raise anchor. static BB: Cell = const { Cell::new(f64::NAN) }; } pub fn parse(s: &str) -> Option { let mut m = Mode::default(); for t in s.split(',').map(str::trim).filter(|t| !t.is_empty()) { match t { "groesse" => m.size = true, "rtb" => m.rtb = true, _ => return None, } } (m.size || m.rtb).then_some(m) } pub fn mode() -> Option { use std::sync::OnceLock; static MODE: OnceLock> = OnceLock::new(); OVERRIDE.with(|o| o.get()).unwrap_or_else(|| *MODE.get_or_init(|| std::env::var("POOL_STUFE").ok().and_then(|s| parse(&s)))) } pub fn set_override(mode: Option>) { OVERRIDE.with(|o| o.set(mode)); } fn at_stage(big_blind: f64) -> bool { crate::exploit::pool::stage_for(big_blind).as_deref() == Some(STAGE) } /// The switch at this big blind's stake, `None` elsewhere. pub fn mode_at(big_blind: f64) -> Option { mode().filter(|_| at_stage(big_blind)) } /// `groesse`: the fold chance `f` (the core's, at pressure `ratio`) with the stake's big-bet curve. `f_knee` is /// the same villain's fold chance at `KNEE`. pub fn big_bet_fold(f: f64, f_knee: f64, ratio: f64) -> f64 { if !(ratio > KNEE) || !f.is_finite() || !f_knee.is_finite() { return f; } let t = ((ratio - KNEE) / (FULL - KNEE)).clamp(0.0, 1.0); let target = f_knee - t * (f_knee - BIG_FOLD.min(f_knee)); f.min(target) } /// Remember the request's big blind for the wire's raise anchor (`rtb_anchor`). pub fn set_big_blind(big_blind: f64) { BB.with(|b| b.set(big_blind)); } /// Anchor of the counted raise reads on the wire: `RTB_MU` under `rtb` at the stake, else the core's 0.30. pub fn rtb_anchor() -> f64 { let bb = BB.with(Cell::get); if mode_at(bb).is_some_and(|m| m.rtb) { RTB_MU } else { RTB_CORE } } /// The same anchor for the sim memory: the stake must be forced (`GEGNER_POOL_STUFE`), the sim has no stake. pub fn rtb_anchor_sim() -> f64 { if mode_at(f64::NAN).is_some_and(|m| m.rtb) { RTB_MU } else { RTB_CORE } } #[cfg(test)] mod tests { use super::*; #[test] fn parses() { assert_eq!(parse("groesse"), Some(Mode { size: true, rtb: false })); assert_eq!(parse("groesse,rtb"), Some(Mode { size: true, rtb: true })); assert_eq!(parse("rtb"), Some(Mode { size: false, rtb: true })); assert_eq!(parse("fold"), None); assert_eq!(parse(""), None); } #[test] fn big_bets_fold_less_never_more() { // at or below the knee: untouched assert_eq!(big_bet_fold(0.30, 0.45, 0.5), 0.30); assert_eq!(big_bet_fold(0.45, 0.45, 0.66), 0.45); // pot: between the knee value and the big-bet fold let pot = big_bet_fold(0.60, 0.45, 1.0); assert!(pot < 0.45 && pot > BIG_FOLD, "{pot}"); // 1.5x and beyond: the big-bet fold assert!((big_bet_fold(0.74, 0.45, 1.5) - BIG_FOLD).abs() < 1e-12); assert!((big_bet_fold(0.90, 0.45, 4.0) - BIG_FOLD).abs() < 1e-12); // a villain who folds less than the stake at the knee is never raised assert_eq!(big_bet_fold(0.25, 0.20, 2.0), 0.20_f64.min(0.25)); } }