Replay-Harness, Wurzel-Fix am Equity-Bias, MDF-River-Boden und Stage-0-Blind-Messlatte

Replay-Harness (entscheiden/replay.py, eval7.py, tests/replay_spec.py): rekonstruiert Hero-
Entscheidungen aus echten Hand-Histories, misst Fold-to-bet, den Equity-Bias gegen einen
unabhaengigen Evaluator und den belegten EV-Verlust (Overfold/Overcall). benchmarks/replay_*.txt
frieren Vorher/Nachher ein.

Wurzel am Equity-Bias (exploit/bluff_share.rs, street_continuation.rs): der Micro-Pool barrelt
ueber GTO-Balance, also bekommt eine UNGELESENE Range (profile None, auch blind gegatet) auf dem
ERSTEN Barrel einen Populations-Ueber-Bluff-Prior (with_pop_prior, barrel-bewusst - ein Sustained-
Barrel bleibt value-gewichtet). bluff_share bleibt rein. Overfold im Replay 40.6 -> 7.5 bb,
Bias -0.221 -> -0.186.

MDF-River-Boden (exploit/mdf_floor.rs, engine/decide.rs): ein River-Fold einer verteidigbaren
Made-Hand gegen eine Range, die bluffen kann, wird zum Call (MDF/Break-even), ausser jeder lebende
Gegner ist ein belegter Under-Bluffer. Laeuft auf dem UNGEGATETEN Spot, Kern-EV unangetastet.

Stage 0 - Blind-Messlatte (sim/session.rs, table.rs, benchmark.rs, tests/sim_blind.rs): ein neues
blind-Feld haelt den HUD-Read zurueck; zwei Blind-Szenarien (Fisch, Calling Station) beziffern den
Sitzungsertrag eines Reads (Fisch +53.8, Station +26.3 bb/100). Die 10 alten Szenarien bleiben Bit
fuer Bit gleich; baseline.txt neu mit 12 Szenarien. Kein Rueckschritt auf der Messlatte.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-11-10 13:56:45 +01:00
co-authored by Claude Opus 4.8
parent 5f68c71d5a
commit b0aee07076
18 changed files with 1079 additions and 37 deletions
+20
View File
@@ -17,6 +17,12 @@ pub const MAX_BLUFF_SHARE: f64 = 0.6;
const AVERAGE_AGGRESSION: f64 = 0.45;
const MAX_FACTOR: f64 = 2.0;
/// Populations-Ueber-Bluff-Prior gegen einen UNGELESENEN Gegner: der Micro-Pool c-bettet/barrelt
/// weit ueber GTO-Balance, also bekommt eine unbekannte (auch auf blind gegatete) Range auf
/// Flop/Turn mindestens diesen Bluff-Anteil. River bleibt dem MDF-Boden ueberlassen.
/// Micro-Prior; spaeter stake-skaliert.
const POP_BLUFF_PRIOR: [f64; 4] = [0.0, 0.40, 0.35, 0.0]; // preflop, flop, turn, river
fn street_factor(street: Street) -> f64 {
match street {
Street::Preflop => 0.0,
@@ -45,3 +51,17 @@ pub fn bluff_share(profile: Option<&Profile>, ratio: Option<f64>, street: Street
let balanced = s / (1.0 + 2.0 * s);
(balanced * street_factor(street) * style_factor(profile)).clamp(0.0, MAX_BLUFF_SHARE)
}
/// Lift the population over-bluff prior onto a base bluff share. It applies ONLY to an UNREAD
/// villain (`profile` None - including a read gated to blind) on a FIRST barrel: a sustained
/// multi-street line (`sustained`, the villain already bet/raised an earlier street) is
/// value-weighted even in the micro pool, so it gets no bump. River and preflop carry no prior
/// (the river is the MDF floor's job). Never exceeds `MAX_BLUFF_SHARE`.
pub fn with_pop_prior(profile: Option<&Profile>, street: Street, sustained: bool, base: f64) -> f64 {
let prior = if profile.is_none() && !sustained {
POP_BLUFF_PRIOR[street as usize]
} else {
0.0
};
base.max(prior).min(MAX_BLUFF_SHARE)
}
+201
View File
@@ -0,0 +1,201 @@
//! Minimum-defence-frequency floor: on the river, a made hand in the top `1 - alpha` of a
//! defensible range is never folded to a bet, whatever the opponent range model says.
//!
//! This is the GTO floor UNDER the exploit deviation. Facing a bet of break-even `alpha`
//! (`to_call / (pot + to_call)`), a defender who folds more than `1 - alpha` of the hands that
//! beat a bluff lets the bettor print with any air (MDF). The engine's villain range model is
//! measured to be too value-heavy (replay benchmark: mean equity bias ~-0.22, river fold-to-bet
//! ~86 %), so equity-against-the-model folds bluff-catchers that MDF says must defend. This floor
//! reads HERO's own made hand - not the (untrusted) villain range - so it can never be moved by a
//! miscalibrated read: it only ever turns a model-driven fold into the call MDF requires.
//!
//! River only: there the bet is terminal and MDF is exact (no draws, no future streets, realisation
//! 1.0). Flop and turn defence couples with realisation and is left to the equity line.
use crate::exploit::profile::Profile;
use crate::exploit::style::{classify, Style};
use crate::game::{ActionKind, Choice, Decision, Spot, Street};
use crate::odds::break_even::break_even;
use crate::read::made::Made;
/// Below this observed postflop aggression frequency the bettor's range is treated as bluff-light.
const BLUFF_LIGHT_AGGRESSION: f64 = 0.25;
/// Fraction of random hands hero's made class beats by showdown - the MDF yardstick (rough,
/// monotone in `Made`). Not an equity: only its order and rough level matter, to place the hand
/// in hero's range (`strength >= alpha` ⇔ top `1 - alpha`).
fn strength(made: Made) -> f64 {
match made {
Made::Air => 0.15,
Made::BoardOnly => 0.18,
Made::Underpair => 0.42,
Made::BottomPair => 0.50,
Made::MiddlePair => 0.60,
Made::TopPairWeakKicker => 0.70,
Made::TopPairGoodKicker => 0.80,
Made::Overpair => 0.85,
Made::TwoPair => 0.90,
Made::Set | Made::Trips => 0.95,
Made::Straight => 0.97,
Made::Flush => 0.98,
Made::FullHouse => 0.99,
Made::Quads => 0.995,
Made::StraightFlush => 1.0,
}
}
/// A hand with real showdown value: at least a pair, so it beats a pure bluff. `BoardOnly`
/// (hero plays the board, chops at best) and `Air` are not bluff-catchers and are excluded -
/// their MDF defence, if any, is a raise, never a call.
fn beats_bluffs(made: Made) -> bool {
made >= Made::Underpair
}
/// Positive, directly observed evidence that this bettor's range is bluff-light, so MDF does not
/// require defence against it: a low postflop aggression frequency, or the nit style. Reads the
/// robust observed FREQUENCY (`aggression`, vpip/pfr/fold), never the miscalibrated range model -
/// the only thing allowed to switch the floor off is a bettor we have *seen* under-bluff.
fn under_bluffs(profile: &Profile) -> bool {
profile.aggression.is_some_and(|a| a < BLUFF_LIGHT_AGGRESSION) || classify(profile) == Style::Nit
}
/// Could the bet contain bluffs? Yes unless every live villain is a confirmed under-bluffer. An
/// unknown villain (no profile) counts as a possible bluffer, so the floor still defends against
/// the (bluff-heavy) unread micro population; only a read that says "this bettor doesn't bluff"
/// turns it off.
fn range_may_bluff(spot: &Spot) -> bool {
let mut live = spot.villains.iter().filter(|v| !v.folded).peekable();
live.peek().is_none()
|| live.any(|v| v.profile.as_ref().is_none_or(|p| !under_bluffs(p)))
}
/// True when hero must defend `made` against the bet he faces (never fold): on the river, with
/// a bluff-catcher or better, whose strength puts it in the top `1 - alpha` of the range, and the
/// bettor is not a confirmed under-bluffer.
pub fn defends(spot: &Spot, made: Made) -> bool {
spot.street == Street::River
&& spot.to_call > 0.0
&& beats_bluffs(made)
&& strength(made) >= break_even(spot.pot, spot.to_call)
&& range_may_bluff(spot)
}
/// Overlay the floor on a finished postflop decision: a model-driven river fold of a defensible
/// made hand becomes the call MDF requires. `spot` must carry the UNGATED villain reads - the
/// floor's defensive use of a read (fold more against a confirmed non-bluffer, never fold a
/// bluff-catcher the model mis-prices) is always safe, unlike the range model that `read_gate`
/// keeps blind. The base decision's EV annotations are kept; anything but a floorable river fold
/// is returned unchanged.
pub fn floor(spot: &Spot, made: Made, decision: Decision) -> Decision {
if decision.choice == Choice::Fold && spot.is_legal(ActionKind::Call) && defends(spot, made) {
let be = break_even(spot.pot, spot.to_call);
return Decision::new(
Choice::Call,
0.5,
format!("MDF-Boden: Made-Hand verteidigt - Modell-Fold uebersteuert (break-even {be:.2})"),
)
.with_evs(decision.evs);
}
decision
}
#[cfg(test)]
mod tests {
use super::*;
fn river(pot: f64, to_call: f64) -> Spot {
Spot {
variant: crate::variant::Variant::Nlhe,
big_blind: 0.1,
seats: 2,
hero_seat: 1,
button_seat: None,
hero_cards: crate::card::Card::parse_list("Kd 7d").unwrap(),
board: crate::card::Card::parse_list("9c Tc Kc Qd 2h").unwrap(),
street: Street::River,
pot,
to_call,
hero_stack: 100.0,
min_raise_to: None,
max_raise_to: None,
legal: vec![],
allowed_sizes: None,
villains: vec![],
seed: 1,
history: Vec::new(),
}
}
#[test]
fn top_pair_defends_a_half_pot_river_bet() {
// alpha = 0.26 / 0.83 = 0.31; top pair weak kicker strength 0.70 >= 0.31 -> defend
assert!(defends(&river(0.57, 0.26), Made::TopPairWeakKicker));
}
#[test]
fn weak_pair_folds_to_an_overbet() {
// alpha = 15 / 25 = 0.60; underpair strength 0.42 < 0.60 -> no floor
assert!(!defends(&river(10.0, 15.0), Made::Underpair));
}
#[test]
fn air_is_never_floored() {
assert!(!defends(&river(10.0, 3.0), Made::Air));
assert!(!defends(&river(10.0, 3.0), Made::BoardOnly));
}
#[test]
fn only_on_the_river() {
let flop = Spot { street: Street::Flop, ..river(10.0, 3.0) };
assert!(!defends(&flop, Made::TopPairGoodKicker));
}
#[test]
fn no_floor_without_a_bet() {
assert!(!defends(&river(10.0, 0.0), Made::Overpair));
}
fn villain(profile: Option<Profile>) -> crate::game::Villain {
crate::game::Villain { seat: 1, stack: 100.0, folded: false, profile }
}
fn prof(aggression: f64, vpip: f64, fold_to_bet: f64) -> Profile {
Profile {
aggression: Some(aggression),
vpip: Some(vpip),
fold_to_bet: Some(fold_to_bet),
..Profile::default()
}
}
#[test]
fn an_aggressive_bettor_is_defended() {
// alpha 0.33, middle pair 0.60 >= 0.33, and the maniac bets bluffs -> defend.
let spot = Spot { villains: vec![villain(Some(prof(0.8, 0.55, 0.35)))], ..river(12.0, 6.0) };
assert!(defends(&spot, Made::MiddlePair));
}
#[test]
fn an_unread_bettor_is_defended() {
// No profile: the unread micro population bluffs, so the floor still holds.
let spot = Spot { villains: vec![villain(None)], ..river(12.0, 6.0) };
assert!(defends(&spot, Made::MiddlePair));
}
#[test]
fn a_confirmed_under_bluffer_is_not_floored() {
// Low observed aggression (0.0) and a nit: no bluffs to catch, the fold stands.
let honest = Spot { villains: vec![villain(Some(prof(0.0, 0.25, 0.5)))], ..river(12.0, 6.0) };
assert!(!defends(&honest, Made::MiddlePair));
let nit = Spot { villains: vec![villain(Some(prof(0.15, 0.11, 0.8)))], ..river(12.0, 6.0) };
assert!(!defends(&nit, Made::MiddlePair));
}
#[test]
fn a_folded_under_bluffer_does_not_suppress_the_live_bettor() {
// The nit folded; the live bettor is unread -> still defended.
let nit = crate::game::Villain { folded: true, ..villain(Some(prof(0.15, 0.11, 0.8))) };
let spot = Spot { villains: vec![nit, villain(None)], ..river(12.0, 6.0) };
assert!(defends(&spot, Made::MiddlePair));
}
}
+1
View File
@@ -10,6 +10,7 @@ pub mod fold_chance;
pub mod fold_equity_scale;
pub mod made_ladder;
pub mod mark;
pub mod mdf_floor;
pub mod pot_trace;
pub mod preflop_role;
pub mod profile;
+15 -2
View File
@@ -1,5 +1,5 @@
use super::bet_ratio::bet_ratios;
use super::bluff_share::bluff_share;
use super::bluff_share::{bluff_share, with_pop_prior};
use super::made_ladder::rung;
use super::range_spec::Continuation;
use super::size_notch::size_notch;
@@ -78,6 +78,17 @@ fn merge(a: Option<Floor>, b: Option<Floor>) -> Option<Floor> {
}
}
/// Did the villain already bet or raise on an earlier postflop street? Such a line is a sustained
/// barrel - value-weighted even in the micro pool - so it earns no population over-bluff prior.
fn aggressed_earlier(history: &[ActionRecord], street: Street, seat: u8) -> bool {
history.iter().any(|r| {
r.seat == seat
&& r.street != Street::Preflop
&& (r.street as usize) < (street as usize)
&& r.action.is_aggressive()
})
}
/// One continuation for the villain on `street`, if their actions there say anything.
fn on_street(
spot: &Spot,
@@ -86,13 +97,15 @@ fn on_street(
street: Street,
) -> Option<Continuation> {
let slot = street as usize - 1;
let sustained = aggressed_earlier(&spot.history, street, villain.seat);
let made_bet =
own_aggression(&spot.history, ratios, street, villain.seat).map(|(lvl, ratio)| {
let base = [BET_RUNG, RAISE_RUNG][lvl][slot];
let bluff = bluff_share(villain.profile.as_ref(), ratio, street);
(
rung(base, size_notch(ratio) + style_rung(villain)),
DRAWS[slot],
bluff_share(villain.profile.as_ref(), ratio, street),
with_pop_prior(villain.profile.as_ref(), street, sustained, bluff),
)
});
let made_call = called_big_bet(&spot.history, ratios, street, villain.seat).then(|| {