diff --git a/src/bin/ab_zelle.rs b/src/bin/ab_zelle.rs index 0e20c766..f18fdd13 100644 --- a/src/bin/ab_zelle.rs +++ b/src/bin/ab_zelle.rs @@ -54,6 +54,11 @@ fn apply_arm() { _ => WireRead::Off, }); } + // GEDAECHTNIS_FOLD=a,b: foldToBet as the memory handover decodes it (plan D2), only with LESEN_DRAHT=gezaehlt. + rechner::sim::memory::set_fold_prior(std::env::var("GEDAECHTNIS_FOLD").ok().and_then(|v| { + let mut it = v.split(',').map(|x| x.trim().parse::().ok()); + Some((it.next()??, it.next()??)) + })); // READS=cbet,3bet,xr: the line-specific HUD reads (fold to c-bet / fold to 3-bet / check-raise). use rechner::sim::memory::{set_line_reads, READ_CBET, READ_CHECK_RAISE, READ_THREE_BET}; let reads = std::env::var("READS").unwrap_or_default(); diff --git a/src/sim/memory.rs b/src/sim/memory.rs index ac6d4b2a..ef0b6670 100644 --- a/src/sim/memory.rs +++ b/src/sim/memory.rs @@ -155,6 +155,27 @@ fn wire_read() -> WireRead { } } +/// Memory handover foldToBet (plan D2, gedaechtnis-voll): with `Counted`, the pooled fold-to-bet is the +/// posterior `(k + a) / (n + a + b)` over the true facing-bet counts, exactly as `wire::decode_villain` +/// decodes `profile.reads.foldToBet {n, k, prior: [a, b]}`. Without a delivered prior live decodes the +/// core's anchor at 30 chances (a = 0.45 * 30, b = 0.55 * 30): that is the A arm, the D2 stake prior the +/// B arm. Unset (both 0): the `shrink` path as before (bit-identical). +static FOLD_PRIOR_A: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(0); +static FOLD_PRIOR_B: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(0); + +/// Set (`Some((a, b))`, both > 0) or clear the memory-handover foldToBet prior (see above). +pub fn set_fold_prior(prior: Option<(f64, f64)>) { + let (a, b) = prior.filter(|(a, b)| *a > 0.0 && *b > 0.0).unwrap_or((0.0, 0.0)); + FOLD_PRIOR_A.store(a.to_bits(), std::sync::atomic::Ordering::Relaxed); + FOLD_PRIOR_B.store(b.to_bits(), std::sync::atomic::Ordering::Relaxed); +} + +fn fold_prior() -> Option<(f64, f64)> { + let a = f64::from_bits(FOLD_PRIOR_A.load(std::sync::atomic::Ordering::Relaxed)); + let b = f64::from_bits(FOLD_PRIOR_B.load(std::sync::atomic::Ordering::Relaxed)); + (a > 0.0 && b > 0.0).then_some((a, b)) +} + /// The read a HUD accumulates from watching one fixed opponent archetype play a session. #[derive(Clone, Debug, Default, PartialEq)] pub struct SessionMemory { @@ -379,7 +400,13 @@ impl SessionMemory { ..raw }; let pooled = shrink(&base, cap(self.c.hands, HUD_HANDS)); - let pooled = shrink_aggression(pooled, raw.aggression, cap(postflop_actions, HUD_MOVES)); + let mut pooled = shrink_aggression(pooled, raw.aggression, cap(postflop_actions, HUD_MOVES)); + if let (WireRead::Counted, Some((a, b))) = (mode, fold_prior()) { + let n = (self.c.folded_to_bet + self.c.passive_call) as f64; + if n > 0.0 { + pooled.fold_to_bet = Some(((self.c.folded_to_bet as f64 + a) / (n + a + b)).clamp(0.0, 1.0)); + } + } let rate = |k: u32, n: u32| (n > 0).then(|| k as f64 / n as f64); let street = |k: u32, n: u32, anchor: Option| shrink_street(rate(k, n), cap(n, HUD_STREET), anchor); let (ta, tn) = (self.c.turn_aggressive, self.c.turn_aggressive + self.c.turn_passive);