diff --git a/src/bin/diag_welt.rs b/src/bin/diag_welt.rs index 5491682e..4173623f 100644 --- a/src/bin/diag_welt.rs +++ b/src/bin/diag_welt.rs @@ -130,8 +130,18 @@ fn arm(opp_of: &dyn Fn(u64) -> (Opponent, u64), deals: u32, draws: u64, bot: boo /// `DIAG_SCHALTER=reraise`: the same pairing, but both arms hold the Memory read and differ only in /// `RERAISE_TIEFE` (arm "Read" = on, "blind" = off; labels read `aus -> an`). fn read_arm(opp_of: &dyn Fn(u64) -> (Opponent, u64), deals: u32, draws: u64) { - let schalter = std::env::var("DIAG_SCHALTER").as_deref() == Ok("reraise"); - use rechner::exploit::street_continuation::set_reraise_depth_override as rr; + let modus = std::env::var("DIAG_SCHALTER").unwrap_or_default(); + let schalter = modus == "reraise" || modus == "station"; + // DIAG_SCHALTER=station: the arms differ only in `STATION_POSTFLOP` (Read = on, blind = off). + let rr = |on: Option| { + if modus == "station" { + // DIAG_STATION=schmal: the "on" arm runs the narrow mode. + let an = if std::env::var("DIAG_STATION").as_deref() == Ok("schmal") { 2 } else { 1 }; + rechner::exploit::style::set_station_postflop_override(on.map(|x| if x { an } else { 0 })) + } else { + rechner::exploit::street_continuation::set_reraise_depth_override(on) + } + }; let mut diff: BTreeMap = BTreeMap::new(); let mut moved: BTreeMap = BTreeMap::new(); let (mut hands, mut same, mut total) = (0u32, 0u32, 0.0); @@ -165,7 +175,7 @@ fn read_arm(opp_of: &dyn Fn(u64) -> (Opponent, u64), deals: u32, draws: u64) { let (b, _) = play_hand_tracked_history(&setup(HandRead::Given(if schalter { seen } else { None })), TableCost::FREE, None); if schalter { rr(None); } if schalter && d + 1 == deals && hero_seat == 2 { - eprintln!("read nach {deals}: raise_to_bet {:?} reraise_to_raise {:?} aggression {:?} size_gain {:?}", seen.and_then(|p| p.raise_to_bet), seen.and_then(|p| p.reraise_to_raise), seen.and_then(|p| p.aggression), seen.and_then(|p| p.size_gain)); + eprintln!("read nach {deals}: raise_to_bet {:?} reraise_to_raise {:?} aggression {:?} size_gain {:?} vpip {:?} pfr {:?} fold_to_bet {:?} check_raise {:?} stil {:?}", seen.and_then(|p| p.raise_to_bet), seen.and_then(|p| p.reraise_to_raise), seen.and_then(|p| p.aggression), seen.and_then(|p| p.size_gain), seen.map(|p| p.vpip), seen.map(|p| p.pfr), seen.and_then(|p| p.fold_to_bet), seen.and_then(|p| p.check_raise), seen.map(|p| rechner::exploit::style::classify(&p))); } let why_b = take_hero_why(); let delta = (r.hero_net - r.luck) - (b.hero_net - b.luck); diff --git a/src/engine/decide.rs b/src/engine/decide.rs index 7f605edb..01cab0c9 100644 --- a/src/engine/decide.rs +++ b/src/engine/decide.rs @@ -12,7 +12,7 @@ use crate::exploit::adjust::adjust; use crate::exploit::profile::Profile; use crate::exploit::range_model::range_spec; use crate::exploit::thresholds::Thresholds; -use crate::game::{Decision, SeenAction, Spot, Street}; +use crate::game::{Choice, Decision, SeenAction, Spot, Street}; use crate::guard::enforce::enforce; use crate::icm::lage::Turnierlage; use crate::icm::push_fold::push_fold; @@ -231,6 +231,32 @@ pub fn decide(spot: &Spot) -> Decision { /// `decide` with an optional tournament situation (`icm`). Without one: cash. With one /// that cannot be priced: ABSTAIN. pub fn decide_with(spot: &Spot, lage: Option<&Turnierlage>) -> Decision { + use crate::exploit::style::{set_station_postflop_override as force, station_demoted, station_narrow, station_postflop_override}; + // STATION_POSTFLOP=schmal: against a villain the postflop gate would demote, decide with the + // station read and blind (demoted) and play the less aggressive action (`exploit::style`). + if station_narrow() && spot.live_villains().any(|v| v.profile.as_ref().is_some_and(station_demoted)) { + let before = station_postflop_override(); + force(Some(0)); + let station = decide_one(spot, lage); + force(Some(1)); + let demoted = decide_one(spot, lage); + force(before); + return if aggression_rank(demoted.choice) < aggression_rank(station.choice) { demoted } else { station }; + } + decide_one(spot, lage) +} + +/// Fold < check/call < raise; abstain counts as the most aggressive (never preferred). +fn aggression_rank(c: Choice) -> u8 { + match c { + Choice::Fold => 0, + Choice::Check | Choice::Call => 1, + Choice::Raise { .. } => 2, + Choice::Abstain => 3, + } +} + +fn decide_one(spot: &Spot, lage: Option<&Turnierlage>) -> Decision { // RAKE_LIVE (`rake::live`, off by default): a cash spot prices every pot net of the room's rake; // a tournament pays none, also a chip-linear one that plays the cash path below // (the scope is decided on the original situation). Off: no scope, nothing changes. diff --git a/src/exploit/style.rs b/src/exploit/style.rs index 492f879d..4ead8c17 100644 --- a/src/exploit/style.rs +++ b/src/exploit/style.rs @@ -40,18 +40,60 @@ const STATION_FULL_TRUST_AGGRESSION: f64 = 0.20; /// needs a postflop signal - fold-to-bet at most `STATION_LOOSE_MAX_FOLD` (unknown passes). A reg who /// only opens wider (the learning HUD reg, `sim::lerner`, 15.11.: memory read -7,15 bb/100 against blind, /// all postflop) folds like a reg and is no station, however wide it plays preflop. -fn station_postflop() -> bool { +/// `STATION_POSTFLOP=schmal` (15.11., node diagnosis `diag_welt DIAG_SCHALTER=station`): against a +/// player the switch would demote (`station_demoted`), hero decides both ways - station read and blind +/// (the demoted Regular is gated blind) - and plays the LESS aggressive action (`engine::decide`). The +/// full demotion won only where the station read was the more aggressive one (thin value raises into a +/// frequent folder: cbet-folder +36, nemesis-2 +38, all Raise -> Call/Check/Fold nodes) and lost only +/// where it was the more cautious one (check-raiser −6,7, polar −5,1: Fold -> Call, Call -> Raise). +fn station_mode() -> u8 { use std::sync::OnceLock; - static ON: OnceLock = OnceLock::new(); - *ON.get_or_init(|| std::env::var("STATION_POSTFLOP").as_deref() == Ok("1")) + static MODE: OnceLock = OnceLock::new(); + STATION_OVERRIDE.with(|o| o.get()).unwrap_or_else(|| { + *MODE.get_or_init(|| match std::env::var("STATION_POSTFLOP").as_deref() { + Ok("1") => 1, + Ok("schmal") => 2, + _ => 0, + }) + }) } +fn station_postflop() -> bool { + station_mode() == 1 +} + +/// `STATION_POSTFLOP=schmal` is on (the two-way decision in `engine::decide`). +pub fn station_narrow() -> bool { + station_mode() == 2 +} + +/// A station by the old rule that the postflop gate demotes (it folds more than `STATION_LOOSE_MAX_FOLD`). +pub fn station_demoted(profile: &Profile) -> bool { + classify_with(profile, false) == Style::CallingStation && classify_with(profile, true) != Style::CallingStation +} + +/// The current thread's override (to restore it after a two-way decision). +pub fn station_postflop_override() -> Option { + STATION_OVERRIDE.with(|o| o.get()) +} + +thread_local! { + static STATION_OVERRIDE: std::cell::Cell> = const { std::cell::Cell::new(None) }; +} + +/// Diagnostics only (`diag_welt DIAG_SCHALTER=station`): force the `STATION_POSTFLOP` mode on this +/// thread (0 off, 1 on, 2 schmal), `None` = the environment switch. +pub fn set_station_postflop_override(mode: Option) { + STATION_OVERRIDE.with(|o| o.set(mode)); +} + + /// Fold-to-bet above which a loose-passive player is not a station under `STATION_POSTFLOP` (a reg /// folds ~0,50-0,55, the stations of the ladder 0,20-0,35). const STATION_LOOSE_MAX_FOLD: f64 = 0.45; -fn folds_like_a_station(fold: Option) -> bool { - !station_postflop() || fold.is_none_or(|b| b <= STATION_LOOSE_MAX_FOLD) +fn folds_like_a_station(fold: Option, gate: bool) -> bool { + !gate || fold.is_none_or(|b| b <= STATION_LOOSE_MAX_FOLD) } /// A frequency in `[0, 1]`; NaN means "not known". @@ -74,6 +116,10 @@ fn frequency(x: Option) -> Option { /// and the station exploit it then bled −448 bb/100 to. The `sticky` path (fold ≤ 30 %) is a real /// non-folder and stays a station regardless of aggression. pub fn classify(profile: &Profile) -> Style { + classify_with(profile, station_postflop()) +} + +fn classify_with(profile: &Profile, station_gate: bool) -> Style { let (vpip, pfr, fold, aggr) = ( frequency(profile.vpip), frequency(profile.pfr), @@ -92,7 +138,7 @@ pub fn classify(profile: &Profile) -> Style { Style::Unknown } else if loose && pfr.is_some_and(|f| f >= AGGRESSIVE_PFR) { Style::LooseAggressive - } else if (loose && passive && folds_like_a_station(fold)) || sticky { + } else if (loose && passive && folds_like_a_station(fold, station_gate)) || sticky { Style::CallingStation } else if tight { Style::Nit