Files
pokerfreak/src/exploit/street_continuation.rs
T
mmintelandClaude Opus 5.5 bc1a622838 Live-Lecks 14.11. als Schalter, Fixture, Spec und Micro-Leiterzeile
Zwei Muster trugen 23 von 996 Micro-Haenden (-579,5 BB):
- MDF_UNREAD=0: MDF-Boden am River verteidigt nur noch gegen gemessene Ueber-Bluffer.
- RAISE_DRAWS=stark: Range einer Erhoehung haelt nur starke Draws statt jeden Gutshot.
- RAISE_PRIOR=0: Erhoehung ohne Populations-Bluff-Prior (gemessen: Verlierer, bleibt aus).
Vorgabe bleibt bei allen Schaltern das alte Verhalten (Replay trifft alle Live-Entscheidungen).

Fixture tests/live_fixture/micro_2026-11-14.jsonl (23 Faelle), Spec tests/live_lecks_spec.py,
Flop-Nachbau lesen/rueckbau.py, Leiterzeile micro-passiv mit @blind/@oracle in ab_zelle.
cargo test --lib, bluff_range, called_range_share gruen.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 17:31:37 +01:00

175 lines
7.0 KiB
Rust

use super::bet_ratio::bet_ratios;
use super::bluff_share::{bluff_share, with_pop_prior_on};
use super::made_ladder::rung;
use super::range_spec::Continuation;
use super::size_notch::size_notch;
use super::style_rung::style_rung;
use crate::game::{ActionRecord, SeenAction, Spot, Street, Villain};
use crate::read::draw::Draw;
use crate::read::made::Made;
/// A call of a bet at least this big (pot fractions) shows a hand with some showdown value.
const BIG_BET: f64 = 0.6;
/// Floor rung of a bet / of a raise (or all-in) per street (flop, turn, river), see `LADDER`
/// in `made_ladder`: middle pair, top pair weak kicker, top pair good kicker for bets;
/// top pair good kicker, overpair, two pair for raises.
const BET_RUNG: [i32; 3] = [2, 3, 4];
const RAISE_RUNG: [i32; 3] = [4, 5, 6];
/// Draws are still in on flop and turn, not on the river.
const DRAWS: [bool; 3] = [true, true, false];
/// Bet = 0, raise (RAISE or ALL_IN) = 1.
fn level(action: SeenAction) -> Option<usize> {
match action {
SeenAction::Bet => Some(0),
SeenAction::Raise | SeenAction::AllIn => Some(1),
_ => None,
}
}
/// The strongest aggression of the villain on `street`: highest level, then biggest ratio.
fn own_aggression(
history: &[ActionRecord],
ratios: &[Option<f64>],
street: Street,
seat: u8,
) -> Option<(usize, Option<f64>)> {
history
.iter()
.zip(ratios)
.filter(|(r, _)| r.street == street && r.seat == seat)
.filter_map(|(r, ratio)| level(r.action).map(|l| (l, *ratio)))
.max_by(|a, b| {
a.0.cmp(&b.0).then(
a.1.unwrap_or(-1.0)
.partial_cmp(&b.1.unwrap_or(-1.0))
.unwrap_or(std::cmp::Ordering::Equal),
)
})
}
/// Did the villain call, on `street`, a bet or raise (by anyone) of at least `BIG_BET` pots?
fn called_big_bet(
history: &[ActionRecord],
ratios: &[Option<f64>],
street: Street,
seat: u8,
) -> bool {
history.iter().enumerate().any(|(i, r)| {
r.street == street
&& r.seat == seat
&& r.action == SeenAction::Call
&& history[..i]
.iter()
.zip(&ratios[..i])
.rev()
.find(|(b, _)| b.street == street && b.action.is_aggressive())
.is_some_and(|(_, ratio)| ratio.is_some_and(|x| x >= BIG_BET))
})
}
/// (floor, draws continue, weakest draw that counts, bluff share)
type Floor = (Made, bool, Draw, f64);
fn merge(a: Option<Floor>, b: Option<Floor>) -> Option<Floor> {
match (a, b) {
(Some((ma, da, wa, ba)), Some((mb, db, wb, bb))) => Some((ma.max(mb), da && db, wa.max(wb), ba.max(bb))),
(one, other) => one.or(other),
}
}
/// Messschalter (einmal gelesen): `RAISE_DRAWS=stark` laesst in der Range einer ERHOEHUNG nur
/// starke Draws (Open-Ender, Flush-Draw, Kombi) als Draws gelten statt jeden Gutshot.
/// Live 14.11.: gegen eine Flop-Erhoehung auf 89J hielt die Range jede Broadway-Hand mit Gutshot,
/// 78 (Bottom Pair + Gutshot) rechnete 0.50 Equity und ging all-in (-100 BB); Bluff-Anteil war dabei
/// fast egal (0.15 -> 0.49, 0.45 -> 0.51). Vorgabe: Gutshot (alt).
fn raise_draw_floor() -> Draw {
use std::sync::OnceLock;
static FLOOR: OnceLock<Draw> = OnceLock::new();
*FLOOR.get_or_init(|| match std::env::var("RAISE_DRAWS").as_deref() {
Ok("stark") => Draw::OpenEnded,
_ => Draw::Gutshot,
})
}
/// 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,
ratios: &[Option<f64>],
villain: &Villain,
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],
if lvl == 1 { raise_draw_floor() } else { Draw::Gutshot },
with_pop_prior_on(villain.profile.as_ref(), street, sustained, lvl == 1, bluff),
)
});
let made_call = called_big_bet(&spot.history, ratios, street, villain.seat).then(|| {
(
if street == Street::River {
Made::MiddlePair
} else {
Made::BottomPair
},
DRAWS[slot],
Draw::Gutshot,
0.0,
)
});
merge(made_bet, made_call).map(|(min_made, draws_continue, min_draw, bluff_share)| Continuation {
board_len: street.board_len(),
min_made,
draws_continue,
min_draw,
bluff_share,
continue_share: None,
})
}
/// Postflop narrowing from the villain own actions, one entry per dealt street
/// (`board_len <= spot.board.len()`), sorted by board length.
///
/// - **Bet** keeps `[middle pair, top pair weak kicker, top pair good kicker]+` on
/// flop/turn/river; **raise or all-in** keeps `[top pair good kicker, overpair, two pair]+`.
/// Flop and turn bets keep draws, the river keeps made hands only. Several actions on
/// one street: the highest level (then the biggest) counts.
/// - The size (chips added / pot before, from the amounts in the history) moves the floor
/// by `size_notch` rungs: bigger is stricter. Unknown sizes or pots: no move.
/// - A calling station or loose-aggressive style (see `style::classify`) lowers the floor
/// one rung, a nit raises it one. The floor never drops below bottom pair.
/// - Bets and raises keep a **bluff fraction** below their floor (`bluff_share`: bet size,
/// street, style or aggression); calls keep none.
/// - **Checks and calls add nothing**: the continuation only expresses a minimum strength,
/// and a check does not say the hand is weak (traps) nor does a call bound it from
/// below in a useful way. One exception, a mild floor: a call of a bet of at least 0.6 pot
/// keeps bottom pair or better (or a draw) on flop/turn, middle pair or better on the river.
/// Combined with the villain own bet on the same street the stricter floor wins.
pub fn continuations(spot: &Spot, villain: &Villain) -> Vec<Continuation> {
let ratios = bet_ratios(&spot.history);
[Street::Flop, Street::Turn, Street::River]
.into_iter()
.filter(|street| street.board_len() <= spot.board.len())
.filter_map(|street| on_street(spot, &ratios, villain, street))
.collect()
}