Merge exploit-live a901b406: CBET_LUFT=flop,gross,beleg live

Luft-C-Bet heads-up als Vorflop-Aggressor gegen gelesene Selten-Raiser; volles Tor ohne Verlierer, Pflichtfaelle 19 von 25.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 11:55:07 +01:00
co-authored by Claude Opus 5.5
11 changed files with 349 additions and 2 deletions
+120
View File
@@ -0,0 +1,120 @@
//! C-bet and stab with air (`CBET_LUFT`, off by default; live analysis 17.11.).
//!
//! Live (NL2, 5386 hands since 14.11.): as the preflop aggressor heads-up, hero c-bets 31 % and air
//! almost never. The cause is structural. A pure bluff needs `P(fold) >= PURE_BLUFF_MIN_FOLD` (0.45),
//! but its size band (`size_policy::BLUFF_BAND`, 33-50 % pot, flop x 0.8) only allows 0.26-0.40 pot,
//! where the fold model gives about 0.28 (base 0.45, `fold_chance::sized_fold`). So a flop bluff
//! passes only against a read folder. The real pool folds 33 % to our bets under 0.4 pot and 47 % to
//! 0.6-0.8 pot heads-up; the model (0.28 / 0.45) is right, and so is the EV: an air c-bet at 2/3 pot
//! wins `0.47 pot` uncalled against a check that realises about `0.2 pot`.
//!
//! The switch lifts that gate where it is a c-bet or a stab: hero bets first heads-up with nothing in
//! front, on the flop as the preflop aggressor, and with `turn` also on the turn after a flop checked
//! through. There a pure bluff needs only `min_fold` (and still its EV edge over checking,
//! `PURE_BLUFF_EDGE`), and with `gross` it may use the value sizes, so the EV picks the size.
//!
//! `beleg`: only as far as the counted read shows a villain who rarely raises against bets
//! (`glaube::evidence_weight` on the ungated `raise_to_bet`, full at 0,25, none at the anchor 0,30 or
//! without a read; needs `POSTERIOR=bluff`, which keeps the ungated profile). The least fold chance
//! slides from `PURE_BLUFF_MIN_FOLD` to `min_fold` with that weight, the value sizes need a weight
//! above 0. Gate 17.11. without it: nemesis-2 (light raiser) −1,64 on the ladder, −3,26 @blind.
//!
//! `CBET_LUFT=<tokens>`, comma separated: `flop` (on), `turn` (also the turn stab), `min:<x>` (least
//! fold chance, default `MIN_FOLD_DEFAULT`), `gross` (value sizes allowed), `beleg` (see above).
//! Anything unparsable: off.
use crate::game::{line, Spot, Street};
use std::cell::Cell;
/// Least P(fold) of a c-bet/stab bluff when the switch names none.
pub const MIN_FOLD_DEFAULT: f64 = 0.30;
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct Mode {
pub turn: bool,
pub min_fold: f64,
pub wide: bool,
pub evidence: bool,
}
thread_local! {
static OVERRIDE: Cell<Option<Option<Mode>>> = const { Cell::new(None) };
}
pub fn parse(s: &str) -> Option<Mode> {
let mut m = Mode { turn: false, min_fold: MIN_FOLD_DEFAULT, wide: false, evidence: false };
let mut on = false;
for t in s.split(',').map(str::trim).filter(|t| !t.is_empty()) {
match t {
"flop" | "1" => on = true,
"turn" => {
on = true;
m.turn = true;
}
"gross" => m.wide = true,
"beleg" => m.evidence = true,
_ => {
let x = t.strip_prefix("min:")?.parse::<f64>().ok().filter(|x| (0.0..=1.0).contains(x))?;
m.min_fold = x;
}
}
}
on.then_some(m)
}
/// The switch, `None` when off.
pub fn mode() -> Option<Mode> {
use std::sync::OnceLock;
static MODE: OnceLock<Option<Mode>> = OnceLock::new();
OVERRIDE.with(|o| o.get()).unwrap_or_else(|| *MODE.get_or_init(|| std::env::var("CBET_LUFT").ok().and_then(|s| parse(&s))))
}
/// Force the switch for this thread (`Some(None)` = off), `None` = back to the environment.
pub fn set_override(mode: Option<Option<Mode>>) {
OVERRIDE.with(|o| o.set(mode));
}
/// The switch when this spot is a c-bet or stab it covers: heads-up, nothing to call, and on the flop
/// hero is the preflop aggressor with no flop bet yet, on the turn (`turn`) nobody bet the flop or
/// the turn yet.
pub fn applies(spot: &Spot) -> Option<Mode> {
let m = mode()?;
if spot.to_call > 0.0 || spot.live_villains().count() != 1 {
return None;
}
let quiet = |s: Street| !spot.history.iter().any(|r| r.street == s && r.action.is_aggressive());
let hit = match spot.street {
Street::Flop => line::cbet_spot(&spot.history, spot.hero_seat, Street::Flop),
Street::Turn => m.turn && quiet(Street::Flop) && quiet(Street::Turn),
_ => false,
};
if !hit {
return None;
}
if !m.evidence {
return Some(m);
}
let seat = spot.live_villains().next()?.seat;
let w = super::glaube::raw_profile(seat).as_ref().map_or(0.0, super::glaube::evidence_weight);
(w > 0.0).then(|| {
let top = super::bluff::PURE_BLUFF_MIN_FOLD;
Mode { min_fold: top - w * (top - m.min_fold.min(top)), ..m }
})
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn parses_the_tokens() {
assert_eq!(parse("flop"), Some(Mode { turn: false, min_fold: 0.30, wide: false, evidence: false }));
assert_eq!(parse("flop,turn,min:0.35,gross"), Some(Mode { turn: true, min_fold: 0.35, wide: true, evidence: false }));
assert_eq!(parse("turn"), Some(Mode { turn: true, min_fold: 0.30, wide: false, evidence: false }));
assert_eq!(parse("flop,gross,beleg").map(|m| m.evidence), Some(true));
assert_eq!(parse("gross"), None);
assert_eq!(parse("flop,min:x"), None);
assert_eq!(parse("0"), None);
assert_eq!(parse(""), None);
}
}
+5
View File
@@ -94,6 +94,11 @@ pub fn note_raw(raw: &Spot) {
RAW.with(|x| *x.borrow_mut() = kept);
}
/// The ungated profile of `seat` kept by `note_raw` for the current decision (only under S2).
pub fn raw_profile(seat: u8) -> Option<Profile> {
RAW.with(|x| x.borrow().iter().find(|(s, _)| *s == seat).map(|(_, p)| *p))
}
/// `POSTERIOR=fold` or `fold:<w>` (comma list of stages; unknown stages are ignored). Else off.
pub fn mode() -> Option<Mode> {
use std::sync::OnceLock;
+1
View File
@@ -6,6 +6,7 @@ pub mod audit_turn;
pub mod bluff;
pub mod called;
pub mod called_equity;
pub mod cbet_luft;
pub mod decide;
pub mod double_board;
pub mod effective;
+1 -1
View File
@@ -312,7 +312,7 @@ pub fn scored(
RaiseKind::Value | RaiseKind::ThinValue => true,
RaiseKind::Semibluff => b.fold > 0.0 && b.total > 0.0 && b.total > floor,
RaiseKind::Bluff => {
fe >= PURE_BLUFF_MIN_FOLD
fe >= super::cbet_luft::applies(spot).map_or(PURE_BLUFF_MIN_FOLD, |m| m.min_fold.min(PURE_BLUFF_MIN_FOLD))
&& b.total > 0.0
&& b.total >= floor + PURE_BLUFF_EDGE * crate::rake::live::net(spot.pot)
}
+2
View File
@@ -118,6 +118,8 @@ fn band(spot: &Spot, kind: RaiseKind, share: f64, read: &HandRead) -> (f64, f64)
&& spot.live_villains().any(|v| v.profile.is_some_and(|p| p.fold_only));
let base = match kind {
RaiseKind::Semibluff | RaiseKind::Bluff if fold_read => (BLUFF_BAND.0, VALUE_BAND.1),
// CBET_LUFT=..,gross: a c-bet/stab bluff may take the value sizes, the EV picks.
RaiseKind::Bluff if super::cbet_luft::applies(spot).is_some_and(|m| m.wide) => (BLUFF_BAND.0, VALUE_BAND.1),
RaiseKind::Semibluff | RaiseKind::Bluff | RaiseKind::ThinValue => BLUFF_BAND,
RaiseKind::Value if t == Tier::Medium => BLUFF_BAND,
RaiseKind::Value if t == Tier::Monster && late && share >= NUT_SHARE => NUT_BAND,