Files
pokerfreak/src/exploit/adjust.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

64 lines
2.9 KiB
Rust

use super::fold_equity_scale::{MAX_SCALE, MIN_SCALE};
use super::profile::Profile;
use super::style::{classify, station_trust, Style};
use super::style_shift::shift_for;
use super::thresholds::Thresholds;
/// Output ranges: whatever the inputs, the engine never sees thresholds outside these.
const CALL_MARGIN: (f64, f64) = (0.0, 0.15);
const VALUE_RAISE: (f64, f64) = (0.52, 0.85);
const ABSTAIN_BAND: (f64, f64) = (0.0, 0.05);
const RANGE_WIDTH: (f64, f64) = (0.6, 1.4);
fn bounded(x: f64, (low, high): (f64, f64)) -> f64 {
if x.is_nan() {
low
} else {
x.clamp(low, high)
}
}
/// `base` as seen against one profile; `None` when the profile says nothing.
///
/// A `CallingStation` shift is scaled by `station_trust`: a misclassified aggressive "station"
/// (loose width but postflop-aggressive — nemesis-2) gets a fraction of the value-bet-thinner shift,
/// not all of it. Every other style, and a genuine station (trust 1.0), is bit-identical to before.
fn against(base: Thresholds, profile: &Profile) -> Option<Thresholds> {
let style = classify(profile);
let c = if style == Style::CallingStation { station_trust(profile) } else { 1.0 };
shift_for(style).map(|shift| Thresholds {
call_margin: bounded(base.call_margin + shift.call_margin * c, CALL_MARGIN),
value_raise: bounded(base.value_raise + shift.value_raise * c, VALUE_RAISE),
abstain_band: bounded(base.abstain_band, ABSTAIN_BAND),
fold_equity_scale: base.fold_equity_scale.clamp(MIN_SCALE, MAX_SCALE),
range_width_scale: bounded(base.range_width_scale * (1.0 + (shift.range_width - 1.0) * c), RANGE_WIDTH),
})
}
/// Conservative merge of two opponents: keep the harder-to-continue value of each
/// threshold (higher margins, lower fold equity, narrower ranges).
fn conservative(a: Thresholds, b: Thresholds) -> Thresholds {
Thresholds {
call_margin: a.call_margin.max(b.call_margin),
value_raise: a.value_raise.max(b.value_raise),
abstain_band: a.abstain_band.max(b.abstain_band),
fold_equity_scale: a.fold_equity_scale.min(b.fold_equity_scale),
range_width_scale: a.range_width_scale.min(b.range_width_scale),
}
}
/// Shift thresholds for the given opponents' profiles. No profiles → `base` unchanged.
///
/// Each profile is classified (`style::classify`) and moves `base` by its style
/// (`style_shift`). `fold_equity_scale` stays as given: how often each opponent folds is
/// estimated per opponent (`fold_chance`), so the profile is not counted here a second time.
/// Profiles with no usable numbers are ignored; with several informative ones the
/// results are merged conservatively. Outputs are clamped to sane ranges.
pub fn adjust(base: Thresholds, profiles: &[Profile]) -> Thresholds {
profiles
.iter()
.filter_map(|p| against(base, p))
.reduce(conservative)
.unwrap_or(base)
}