Sonde Memory: aggression trennt verkehrt (nemesis-2 0,36 < nemesis-3 0,49), checkRaise trennt sauber (nemesis-2 0,286 erhoeht weit, nemesis-3 0,075, maniac 0,029). Tor xr:0.15 mit READS=xr in Basis und Arm eingereiht (Leiter all, micro, pool-nl2, LBR 200). Ungesetzt bitgleich. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
245 lines
10 KiB
Rust
245 lines
10 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,
|
|
})
|
|
}
|
|
|
|
/// Messschalter (einmal gelesen): `TURN_RAISE_BLUFF=<f>` macht die Range einer TURN-ERHOEHUNG enger:
|
|
/// nur starke Draws (Open-Ender, Flush, Kombi) zaehlen als Draws, und der Bluff-Anteil wird mit `f`
|
|
/// multipliziert (0 = keine reinen Bluffs; die Semi-Bluffs sind die Draws). Nemesis-3 15.11.: Hero setzt
|
|
/// den Turn, der Gegner erhoeht (Overbet), Hero callt Middle Pair / Two Pair mit Engine-Equity 59 %, echt
|
|
/// 2,4 % (41 Calls) - die Range hielt jeden Gutshot plus 24 % Bluffs. Ungesetzt: bit-identisch (alt).
|
|
fn turn_raise_bluff() -> Option<f64> {
|
|
use std::sync::OnceLock;
|
|
static F: OnceLock<Option<f64>> = OnceLock::new();
|
|
*F.get_or_init(|| std::env::var("TURN_RAISE_BLUFF").ok().and_then(|v| v.parse::<f64>().ok()).filter(|f| f.is_finite() && *f >= 0.0))
|
|
}
|
|
|
|
/// Messschalter (einmal gelesen): `TURN_RAISE_NUR=gelesen` beschraenkt `TURN_RAISE_BLUFF` auf GELESENE
|
|
/// Gegner (Profil vorhanden). Ungelesen (auch auf blind gegatet) bleibt die alte Range samt Pop-Prior:
|
|
/// Tor 15.11. mit TURN_RAISE_BLUFF=0 fuer alle verlor nemesis-2@blind -11,02 +-7,65, LBR +36,5 +-39,8.
|
|
/// `TURN_RAISE_NUR=roh`: wie `gelesen`, aber gegen den UNGEGATETEN Read (der Gate streift Regular/Unknown
|
|
/// ab, Nemesis-3 ist Regular). `decide_with` merkt sich je Entscheidung, welche Sitze einen rohen Read haben.
|
|
#[derive(Clone, Copy, PartialEq)]
|
|
enum NurModus {
|
|
Alle,
|
|
Gelesen,
|
|
Roh,
|
|
/// `TURN_RAISE_NUR=xr:<s>`: nur wenn der ROHE Check-Raise-Read unter `s` liegt (ein seltener Raiser
|
|
/// erhoeht eng; Sonde 15.11. Memory: nemesis-2 0,286 erhoeht weit, nemesis-3 0,075, maniac 0,029).
|
|
Xr(f64),
|
|
}
|
|
|
|
fn nur_modus() -> NurModus {
|
|
use std::sync::OnceLock;
|
|
static M: OnceLock<NurModus> = OnceLock::new();
|
|
*M.get_or_init(|| match std::env::var("TURN_RAISE_NUR").as_deref() {
|
|
Ok("gelesen") => NurModus::Gelesen,
|
|
Ok("roh") => NurModus::Roh,
|
|
Ok(v) if v.starts_with("xr:") => v[3..].parse::<f64>().ok().filter(|x| x.is_finite()).map_or(NurModus::Alle, NurModus::Xr),
|
|
_ => NurModus::Alle,
|
|
})
|
|
}
|
|
|
|
thread_local! {
|
|
/// Sitze (Bitmaske) mit rohem Read in der laufenden Entscheidung; nur fuer `TURN_RAISE_NUR=roh`.
|
|
static ROH: std::cell::Cell<u64> = const { std::cell::Cell::new(0) };
|
|
}
|
|
|
|
/// Von `decide_with` vor dem Gate aufgerufen: merkt die Sitze mit rohem (ungegatetem) Read. Ohne
|
|
/// `TURN_RAISE_NUR=roh` ein No-op.
|
|
pub fn note_raw_reads(spot: &Spot) {
|
|
let pass: Box<dyn Fn(&crate::exploit::profile::Profile) -> bool> = match nur_modus() {
|
|
NurModus::Roh => Box::new(|_| true),
|
|
NurModus::Xr(s) => Box::new(move |p| p.check_raise.is_some_and(|x| !x.is_nan() && x < s)),
|
|
_ => return,
|
|
};
|
|
let mask = spot.villains.iter().filter(|v| v.seat < 64 && v.profile.as_ref().is_some_and(|p| pass(p))).fold(0u64, |m, v| m | 1 << v.seat);
|
|
ROH.with(|r| r.set(mask));
|
|
}
|
|
|
|
fn tighten_for(villain: &Villain) -> bool {
|
|
match nur_modus() {
|
|
NurModus::Alle => true,
|
|
NurModus::Gelesen => villain.profile.is_some(),
|
|
NurModus::Roh | NurModus::Xr(_) => villain.seat < 64 && ROH.with(|r| r.get()) >> villain.seat & 1 == 1,
|
|
}
|
|
}
|
|
|
|
/// 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);
|
|
let tight = (lvl == 1 && street == Street::Turn && tighten_for(villain))
|
|
.then(turn_raise_bluff)
|
|
.flatten();
|
|
let bluff = with_pop_prior_on(villain.profile.as_ref(), street, sustained, lvl == 1, bluff);
|
|
(
|
|
rung(base, size_notch(ratio) + style_rung(villain)),
|
|
DRAWS[slot],
|
|
match (lvl, tight) {
|
|
(1, Some(_)) => Draw::OpenEnded,
|
|
(1, None) => raise_draw_floor(),
|
|
_ => Draw::Gutshot,
|
|
},
|
|
tight.map_or(bluff, |f| (bluff * f).min(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()
|
|
}
|