Files
pokerfreak/src/exploit/range_model.rs
T
mmintelandClaude Opus 4.8 b360796d2e Soft-Trust: konfidenz-gewichtetes Stations-Trust schliesst den Nemesis-Rest
Leak 2 war mit dem 0.45-Aggressions-Tor grob gefixt (classify liest den
aggressiven Vielfalter als Regular, nicht Station). Die CMA-ES gegen die
reparierte Engine fand aber nemesis-2 knapp unter dem Tor (aggr 0.41) ->
voll getrustete Station -> -87.63 bb/100.

Wurzel: das binaere earned_trust (1.0/0.0) gibt einem Grenzfall den vollen
Exploit oder gar keinen. read_gate nennt die Loesung selbst - ein f64 fuer
"partial, confidence-weighted trust". station_trust() ist jetzt eine Rampe:
1.0 fuer echte passive Station (bit-identisch zu vorher, keine Regression),
linear auf 0 Richtung 0.45-Grenze.

Vier gemessene Kanaele, die das Stations-Profil lesen, je per toward_blind
mit dem Trust skaliert (bit-identisch bei c=1): adjust (Schwellen), style_rung
(Boden-Sprosse), range_model (Band-Stretch), fold_chance (Fold-Equity, der
dominante). nemesis-2 Memory -87.63 -> +83.72 bb/100 (Blind-Decke +114.01).

Beweis: Zwillings-Tor Gate::passes (OFFENSE +50.58, Boden gto -23.93 und
Exploitability 77.03 bit-identisch), Boden-Archetypen unregressiert,
101 Lib-Tests gruen. Der neue Worst-Case nemesis-3 (-26.59) ist read-invariant
(Oracle=Blind=Memory, classify Regular) - ein vorbestehendes River-Overbet-
Defense-Loch fuer den River-Solver, von diesem Fix unberuehrt.

Befunde: BEFUND-nemesis-soft-trust.md, BEFUND-nemesis-station-fehllabel.md.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-11-11 19:58:59 +01:00

77 lines
3.5 KiB
Rust

use super::band_bounds::bounded;
use super::band_stretch::{stretch, stretched};
use super::range_guess::{top_fraction, DEFAULT_VPIP};
use super::range_spec::RangeSpec;
use super::role_band::role_band;
use super::role_from_history::role_of;
use super::street_continuation::continuations;
use super::style::{classify, station_trust, Style};
use crate::game::{Spot, Villain};
use crate::preflop::seat_position::seat_position;
/// Confidence weight for how much this villain's read may widen the modeled range: `1.0` for every
/// non-station and every genuine station (bit-identical to the binary gate), a fraction for a
/// misclassified aggressive "station" (loose width but postflop-aggressive — the CMA-ES nemesis-2,
/// aggr 0.41 → 0.16). A wide `vpip` read only widens the modeled betting range as far as the read is
/// trusted, so a wide-preflop-but-TIGHT-betting opponent is no longer modeled as an over-weak range
/// the engine then over-calls. See `station_trust` and BEFUND-nemesis-soft-trust.
fn range_trust(villain: &Villain) -> f64 {
match villain.profile.as_ref() {
Some(p) if classify(p) == Style::CallingStation => station_trust(p),
_ => 1.0,
}
}
/// Pull a read-driven value `x` toward its blind baseline by trust `c`: full read at `c = 1`, pure
/// blind at `c = 0`.
fn toward_blind(blind: f64, x: f64, c: f64) -> f64 {
blind + c * (x - blind)
}
/// Without a readable preflop role the band is the plain vpip share — trust-blended toward the
/// default (blind) vpip so a low-trust station does not over-widen the band.
fn unknown_role_band(villain: &Villain) -> (f64, f64) {
let vpip = villain
.profile
.and_then(|p| p.vpip)
.filter(|v| !v.is_nan())
.map_or(DEFAULT_VPIP, |v| v.clamp(0.02, 1.0));
(0.0, toward_blind(DEFAULT_VPIP, vpip, range_trust(villain)))
}
fn preflop_band(spot: &Spot, villain: &Villain) -> (f64, f64) {
match role_of(&spot.history, villain.seat) {
Some(role) => {
let (lo, hi) = role_band(spot, role, seat_position(spot, villain.seat));
// The read stretches the band by the villain's looseness; blind stretch is 1.0. Trust
// scales how far the band is stretched, so a misread station's wide vpip barely widens it.
let factor = toward_blind(1.0, stretch(role, villain.profile), range_trust(villain));
stretched(lo, hi, factor)
}
None => unknown_role_band(villain),
}
}
/// Estimated range of `villain`, narrowed by the observed action sequence
/// (`spot.history`).
///
/// - **No record of this seat in the history** (including an empty history): exactly the old
/// `RangeSpec::top(range_guess::top_fraction(spot, villain))`.
/// - Otherwise the **preflop band** comes from the villain role (`role_from_history`,
/// table in `role_band`, position from `seat_position`), stretched by the profile
/// (`band_stretch`), forced well-formed (`band_bounds`); the **postflop continuations**
/// from their bets and raises (`street_continuation`).
///
/// Output: `0 <= lo`, `hi <= 1`, `hi - lo >= 0.03`, continuations sorted, only for dealt
/// streets. Never panics, whatever the history looks like.
pub fn range_spec(spot: &Spot, villain: &Villain) -> RangeSpec {
if spot.history.iter().any(|r| r.seat == villain.seat) {
let (raw_lo, raw_hi) = preflop_band(spot, villain);
let (lo, hi) = bounded(raw_lo, raw_hi);
RangeSpec { lo, hi, continues: continuations(spot, villain) }
} else {
RangeSpec::top(top_fraction(spot, villain))
}
}