lbr-veto: LBR-Spur (LBR_SPUR=1), Knotensonde, JAM_VETO und FLOP_VETO (aus = bitgleich)

LBR-Knotenaufschluesselung auf Live eb6275a6: groesster Einzelposten ist der Flop-Jam
(LBR jammt 19,5x Pot in 28 % der Haende, Engine foldet 97 % ihrer Range, MDF 5 %).
JAM_VETO=1: gegen ein Flop-/Turn-All-in callt die Engine, wenn ihre exakte Equity gegen
die Blueprint-Range des All-ins den Preis nach Rake erreicht (nur erkannte Spots, nur Folds).
FLOP_VETO: Flop-Fold -> Call, wenn der Flop-Solver weitermacht (ungemessen, teuer).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-15 23:20:30 +01:00
co-authored by Claude Opus 5.5
parent 1d15019031
commit 5029ed5c8c
8 changed files with 469 additions and 7 deletions
+30
View File
@@ -0,0 +1,30 @@
node 3931, player 0 (BB), children ["f", "c"]
fold share 0.9717 of chart weight 670.5
2d2h w=0.33 c set on dry board: equity 0.86 vs break-even 0.51, EV call +66.14
2d2s w=0.33 c set on dry board: equity 0.88 vs break-even 0.51, EV call +69.25
2h2s w=0.33 c set on dry board: equity 0.87 vs break-even 0.51, EV call +68.36
7cKc w=1.00 c two pair on dry board: equity 0.83 vs break-even 0.51, EV call +60.81
7cKd w=1.00 c two pair on dry board: equity 0.82 vs break-even 0.51, EV call +59.41
7cKs w=1.00 c two pair on dry board: equity 0.82 vs break-even 0.51, EV call +59.31
Kc7h w=1.00 c two pair on dry board: equity 0.83 vs break-even 0.51, EV call +60.42
Kc7s w=1.00 c two pair on dry board: equity 0.82 vs break-even 0.51, EV call +59.34
Kd7h w=1.00 c two pair on dry board: equity 0.82 vs break-even 0.51, EV call +59.50
Kd7s w=1.00 c two pair on dry board: equity 0.84 vs break-even 0.51, EV call +62.01
7hKs w=1.00 c two pair on dry board: equity 0.81 vs break-even 0.51, EV call +57.12
7sKs w=1.00 c two pair on dry board: equity 0.82 vs break-even 0.51, EV call +58.17
Kc2d w=1.00 c two pair on dry board: equity 0.70 vs break-even 0.51, EV call +35.15
Kc2h w=1.00 c two pair on dry board: equity 0.71 vs break-even 0.51, EV call +37.12
Kc2s w=1.00 c two pair on dry board: equity 0.71 vs break-even 0.51, EV call +37.22
2dKd w=1.00 c two pair on dry board: equity 0.70 vs break-even 0.51, EV call +35.69
2dKs w=1.00 c two pair on dry board: equity 0.71 vs break-even 0.51, EV call +36.96
Kd2h w=1.00 c two pair on dry board: equity 0.70 vs break-even 0.51, EV call +35.34
Kd2s w=1.00 c two pair on dry board: equity 0.70 vs break-even 0.51, EV call +35.91
2hKs w=1.00 c two pair on dry board: equity 0.70 vs break-even 0.51, EV call +35.44
2sKs w=1.00 c two pair on dry board: equity 0.70 vs break-even 0.51, EV call +35.66
reasons (weight, continuing weight):
422.72 0.00 air on dry board
34.88 0.00 bottom pair on dry board
106.48 0.00 middle pair on dry board
1.00 1.00 set on dry board
87.47 0.00 top pair weak kicker on dry board
18.00 18.00 two pair on dry board
+11
View File
@@ -0,0 +1,11 @@
MDF_UNREAD=0
TURN_SPIEL=grund
OPEN_JAM=1
RAKE_LIVE=1
RERAISE_TIEFE=1
RERAISE_BLUFF=erst
TURN_RAISE_BLUFF=0
TURN_RAISE_NUR=rtb:0.30
STATION_POSTFLOP=schmal
LESEN_DRAHT=raise
GRUNDSTRATEGIE=D:\Projects\pokerfreak\.claude\worktrees\engine-lecks-angreifen-de7b88\daten
+121
View File
@@ -0,0 +1,121 @@
"""LBR-Knotenaufschluesselung (lbr-veto, 15.11.): woher kommt der LBR-Gewinn gegen die Engine?
Liest eine Spurdatei von engine_lbr mit LBR_SPUR=1 (Zeile: i wert d:... Token...) und schluesselt den
Gewinn (bb/100, Mittel ueber beide Sitze wie engine_lbr) nach Linien auf:
- ende: wie die Hand endet (wer auf welcher Street foldet bzw. Showdown) und der letzte Zug davor;
- lbr-zug: jeder LBR-Bet/Raise nach Street und Groessenklasse, mit Fold-Anteil fp, den LBR einpreiste,
und der lokalen Gewinnschaetzung g (nur Information; die Summe der Haende ist das Mass).
Aufruf: python spur_auswertung.py <spurdatei> [mindestens_haende]
"""
import math
import sys
from collections import defaultdict
def klasse(tok):
# b75 -> Groessenklasse in Prozent des Pots
z = tok[1:]
if not z.isdigit():
return tok
n = int(z)
if n >= 300:
g = "jam"
elif n >= 110:
g = "over"
elif n >= 60:
g = "gross"
else:
g = "klein"
return tok[0] + ":" + g
def lesen(pfad):
haende = []
for z in open(pfad, encoding="utf-8"):
f = z.split()
if len(f) < 3:
continue
i, v = int(f[0]), float(f[1])
toks = [t for t in f[2:] if not t.startswith("d:")]
deal = next((t for t in f[2:] if t.startswith("d:")), "")
haende.append((i, v, toks, deal))
return haende
def zug(t):
# "tL:b75[g=..]" -> (street, wer, aktion, extra)
s, rest = t[0], t[1:]
wer, a = rest.split(":", 1)
extra = ""
if "[" in a:
a, extra = a.split("[", 1)
return s, wer, a, extra.rstrip("]")
def ende(toks):
if not toks:
return "?"
s, wer, a, _ = zug(toks[-1])
if a == "f":
s2, w2, a2, _ = zug(toks[-2]) if len(toks) > 1 else ("?", "?", "?", "")
return f"{s}:{wer} foldet auf {w2}-{klasse(a2)}"
# Showdown: die letzte Aggression (wer, Street, Groesse), die gecallt wurde
agg = [zug(x) for x in toks if zug(x)[2][0] in "br"]
if not agg:
return "showdown ohne Einsatz"
s, wer, a, _ = agg[-1]
return f"showdown nach {s}:{wer}-{klasse(a)} gecallt"
def bericht(haende, mind):
n = len(haende)
sitz = defaultdict(list)
for i, v, _, _ in haende:
sitz[i % 2].append(v)
gesamt = 50.0 * sum(sum(x) / len(x) for x in sitz.values())
print(f"{n} Haende, LBR {gesamt:+.1f} bb/100 (Mittel beider Sitze)")
for name, schluessel in (("Ende der Hand", lambda t: [ende(t)]),
("Linie bis Turn-Ende (Engine-Zuege)", lambda t: [" ".join(x for x in t if x[1] == "E" or x[1] == "L") and linie(t)]),
("LBR-Aggression je Street/Groesse", lambda t: lbr_zuege(t))):
eimer = defaultdict(lambda: [0.0, 0.0, 0])
for i, v, toks, _ in haende:
for k in set(schluessel(toks)):
e = eimer[k]
e[0] += v
e[1] += v * v
e[2] += 1
print(f"\n== {name} (Beitrag bb/100 = Summe/Haende*100; ±95 %)")
reihen = sorted(eimer.items(), key=lambda kv: -kv[1][0])
for k, (s, q, c) in reihen:
if c < mind:
continue
beitrag = 100.0 * s / n
# Beitrag-SE ueber alle n Haende (Indikator mal Wert)
m = s / n
se = math.sqrt(max(q / n - m * m, 0.0) / n)
print(f"{beitrag:+8.1f} ±{196 * se:5.1f} n={c:5d} je Hand {s / c:+6.2f} bb {k}")
def linie(toks):
out = []
for t in toks:
s, wer, a, _ = zug(t)
if s == "r":
break
out.append(f"{s}{wer}{klasse(a) if a[0] in 'br' else a}")
return " ".join(out)
def lbr_zuege(toks):
out = []
for t in toks:
s, wer, a, _ = zug(t)
if wer == "L" and a[0] in "br":
out.append(f"{s}:{klasse(a)}")
return out or ["keine LBR-Aggression"]
if __name__ == "__main__":
bericht(lesen(sys.argv[1]), int(sys.argv[2]) if len(sys.argv) > 2 else 5)
+86
View File
@@ -0,0 +1,86 @@
//! Node probe (lbr-veto, 15.11.): the engine's answer at one S1 node for EVERY combo of the board, to
//! see which hands it continues with where LBR wins (e.g. its flop range facing a jam).
//!
//! Run: `diag_lbr_knoten "<board>" <line>`, line = the trace tokens of `lbr_hand_spur` without street
//! and player, comma separated, e.g. `x,b1950` (big blind checks, button jams). Prints the fold share
//! of the range (chart weights of the player to act), the continuing combos sorted by river EHS, and
//! the engine's reasons with their weight.
use rechner::blueprint::abstraktion::{combo_index, river_cuts, river_ehs};
use rechner::blueprint::engine_gegner::EngineGegner;
use rechner::blueprint::mccfr::Knoten;
use rechner::blueprint::s1::{Abstraktion, Aktion, S1};
use rechner::card::Card;
use rechner::hand::fast7;
use std::collections::BTreeMap;
fn token(s: &S1, k: usize, kind: usize) -> String {
let c = s.baum.beitrag[k];
let pot = c[0] + c[1];
let neu = (s.baum.beitrag[kind][0] + s.baum.beitrag[kind][1]) - pot;
match s.baum.aktion[kind] {
Some(Aktion::Check) => "x".into(),
Some(Aktion::Call) => "c".into(),
Some(Aktion::Fold) => "f".into(),
Some(Aktion::Bet(_)) => format!("b{:.0}", 100.0 * neu / pot),
Some(Aktion::Raise(_)) => format!("r{:.0}", 100.0 * neu / pot),
None => "?".into(),
}
}
fn main() {
let a: Vec<String> = std::env::args().collect();
let board = fast7::mask(&Card::parse_list(&a[1]).expect("board"));
rechner::engine::flop_spieler::set_flop_spieler(rechner::engine::flop_spieler::from_env());
if std::env::var("TURN_SPIEL").as_deref() == Ok("grund") {
rechner::engine::turn_game::set_turn_player(rechner::engine::turn_game::TurnPlayer::Grund);
}
let s = S1::neu(Abstraktion { flop: None, turn: None, river: river_cuts(50, 1) });
let g = EngineGegner::default();
let mut k = s.baum.baum.wurzel;
for t in a.get(2).map(|x| x.split(',').collect::<Vec<_>>()).unwrap_or_default() {
let Knoten::Zug { kinder, .. } = &s.baum.baum.knoten[k] else { panic!("line ends early") };
let alle: Vec<String> = kinder.iter().map(|c| token(&s, k, *c)).collect();
k = *kinder.iter().find(|c| token(&s, k, **c) == t).unwrap_or_else(|| panic!("{t} not in {alle:?}"));
}
let Knoten::Zug { spieler, kinder, .. } = &s.baum.baum.knoten[k] else { panic!("terminal") };
let p = *spieler;
let namen: Vec<String> = kinder.iter().map(|c| token(&s, k, *c)).collect();
println!("node {k}, player {p} ({}), children {namen:?}", ["BB", "BTN"][p]);
// The board's river EHS is only defined on 5 cards; on flop/turn sort by the flop EHS of a random
// completion is not needed: use the made strength now (fast7 score) as the sort key instead.
let ehs = if board.count_ones() == 5 { Some(river_ehs(board, &s.alle)) } else { None };
let (mut wsum, mut wfold) = (0.0, 0.0);
let mut weiter: Vec<(u32, String, String, f64)> = Vec::new();
let mut gruende: BTreeMap<String, [f64; 2]> = BTreeMap::new();
let deck = Card::parse_list("2c 3c 4c 5c 6c 7c 8c 9c Tc Jc Qc Kc Ac 2d 3d 4d 5d 6d 7d 8d 9d Td Jd Qd Kd Ad 2h 3h 4h 5h 6h 7h 8h 9h Th Jh Qh Kh Ah 2s 3s 4s 5s 6s 7s 8s 9s Ts Js Qs Ks As").unwrap();
for (i, c) in s.alle.iter().enumerate() {
let w = s.gewicht[p][i];
if w <= 0.0 || c & board != 0 {
continue;
}
let (row, d) = g.zeile_und_entscheidung(&s, k, *c, board);
let a = row.iter().position(|x| *x > 0.5).unwrap_or(0);
wsum += w;
let grund = d.as_ref().map(|d| d.reason.split([':', '(']).next().unwrap_or("").trim().to_string()).unwrap_or_default();
let e = gruende.entry(grund).or_insert([0.0; 2]);
e[0] += w;
if namen[a] == "f" {
wfold += w;
} else {
e[1] += w;
let karten: Vec<String> = deck.iter().filter(|x| fast7::bit(**x) & c != 0).map(|x| x.short()).collect();
let st = fast7::score(c | board);
let z = ehs.as_ref().map(|e| format!("{:.2}", e[combo_index(*c)])).unwrap_or_default();
weiter.push((st, karten.join(""), format!("{} {z} {}", namen[a], d.map(|d| d.reason).unwrap_or_default()), w));
}
}
println!("fold share {:.4} of chart weight {wsum:.1}", wfold / wsum.max(1e-12));
weiter.sort_by(|a, b| b.0.cmp(&a.0));
for (_, h, t, w) in &weiter {
println!(" {h} w={w:.2} {t}");
}
println!("reasons (weight, continuing weight):");
for (r, [w, c]) in &gruende {
println!(" {w:7.2} {c:7.2} {r}");
}
}
+11 -2
View File
@@ -71,6 +71,7 @@ fn main() {
}
_ => EngineGegner::default(),
};
let spur = std::env::var("LBR_SPUR").as_deref() == Ok("1");
let next = AtomicUsize::new(0);
let datei = Mutex::new(std::fs::OpenOptions::new().create(true).append(true).open(&out).expect("out file"));
let werte = Mutex::new(fertig);
@@ -80,8 +81,16 @@ fn main() {
sc.spawn(|| loop {
let j = next.fetch_add(1, Ordering::Relaxed);
let Some(&i) = offen.get(j) else { break };
let v = lbr_hand(&s, &g, i, seed, None);
writeln!(datei.lock().unwrap(), "{i} {v}").expect("write");
// LBR_SPUR=1: the hand's line after the value (`lbr::lbr_hand_spur`), same value.
let v = if spur {
let (v, z) = rechner::blueprint::lbr::lbr_hand_spur(&s, &g, i, seed);
writeln!(datei.lock().unwrap(), "{i} {v} {}", z.join(" ")).expect("write");
v
} else {
let v = lbr_hand(&s, &g, i, seed, None);
writeln!(datei.lock().unwrap(), "{i} {v}").expect("write");
v
};
let mut w = werte.lock().unwrap();
w[i as usize] = Some(v);
let n = j + 1;
+51 -3
View File
@@ -105,7 +105,7 @@ impl Gegner for Blaupause<'_> {
/// an error of order `1/sqrt(k)`. `None` tracks every combo (exact). The subset is drawn from its own
/// stream (`mischen`), so exact and subsampled LBR play the same deal (paired comparison). Noise can
/// only make LBR choose worse, so the subsampled value is still a lower bound on exploitability.
fn hand<G: Gegner>(s: &S1, g: &G, l: usize, rng: &mut Zufall, mischen: &mut Zufall, stichprobe: Option<usize>) -> f64 {
fn hand<G: Gegner>(s: &S1, g: &G, l: usize, rng: &mut Zufall, mischen: &mut Zufall, stichprobe: Option<usize>, mut spur: Option<&mut Vec<String>>) -> f64 {
let mut cache: std::collections::HashMap<(usize, usize), Vec<f64>> = std::collections::HashMap::new();
let mut zeile = |k: usize, i: usize, board: u64, klasse: usize| -> Vec<f64> {
cache.entry((k, i)).or_insert_with(|| g.zeile(s, k, s.alle[i], board, klasse)).clone()
@@ -116,6 +116,10 @@ fn hand<G: Gegner>(s: &S1, g: &G, l: usize, rng: &mut Zufall, mischen: &mut Zufa
let w0: Vec<f64> = s.alle.iter().zip(&s.gewicht[o]).map(|(c, g)| if c & d.hand[l] == 0 { *g } else { 0.0 }).collect();
let boards = [d.board[0] | d.board[1] | d.board[2], d.board[0] | d.board[1] | d.board[2] | d.board[3], d.board.iter().fold(0, |m, c| m | c)];
let ehs_river = river_ehs(boards[2], &s.alle);
if let Some(sp) = spur.as_deref_mut() {
let ix = super::abstraktion::combo_index;
sp.push(format!("d:{:x},{:x},{:x},ehsL={:.2},ehsE={:.2}", d.hand[l], d.hand[o], boards[2], ehs_river[ix(d.hand[l])], ehs_river[ix(d.hand[o])]));
}
// Subsampling: the support in random order; `m` of it is active, the rest weighs 0 until drawn.
let mut reihe: Vec<usize> = Vec::new();
let mut m = 0;
@@ -167,6 +171,9 @@ fn hand<G: Gegner>(s: &S1, g: &G, l: usize, rng: &mut Zufall, mischen: &mut Zufa
}
}
verlauf.push((k, a, strasse));
if let Some(sp) = spur.as_deref_mut() {
sp.push(format!("{}E:{}", b"ftr"[strasse] as char, zug(baum, k, kinder[a])));
}
k = kinder[a];
continue;
}
@@ -198,6 +205,9 @@ fn hand<G: Gegner>(s: &S1, g: &G, l: usize, rng: &mut Zufall, mischen: &mut Zufa
let (pot, mine) = (c[0] + c[1], c[l]);
let wp = gegen(&eq, &w);
let mut best = (f64::NEG_INFINITY, kinder[0]);
// Trace only: the best passive value (fold/check/call) and the fold share of the chosen bet.
let mut passiv = f64::NEG_INFINITY;
let mut fp_best = f64::NAN;
for &kind in kinder {
let v = match baum.aktion[kind] {
Some(Aktion::Fold) => -mine,
@@ -220,18 +230,47 @@ fn hand<G: Gegner>(s: &S1, g: &G, l: usize, rng: &mut Zufall, mischen: &mut Zufa
}
}
let fp = if all > 0.0 { fold / all } else { 0.0 };
fp * (pot - mine) + (1.0 - fp) * (gegen(&eq, &call_w) * 2.0 * to - to)
let v = fp * (pot - mine) + (1.0 - fp) * (gegen(&eq, &call_w) * 2.0 * to - to);
if v > best.0 {
fp_best = fp;
}
v
}
None => unreachable!("every child has an action"),
};
if matches!(baum.aktion[kind], Some(Aktion::Fold) | Some(Aktion::Check) | Some(Aktion::Call)) {
passiv = passiv.max(v);
}
if v > best.0 {
if !matches!(baum.aktion[kind], Some(Aktion::Bet(_)) | Some(Aktion::Raise(_))) {
fp_best = f64::NAN;
}
best = (v, kind);
}
}
if let Some(sp) = spur.as_deref_mut() {
sp.push(format!("{}L:{}[g={:.2},fp={:.2},eq={:.2}]", b"ftr"[strasse] as char, zug(baum, k, best.1), best.0 - passiv, fp_best, wp));
}
k = best.1;
}
}
/// Trace token of the edge `k -> kind`: x check, c call, f fold, b<n>/r<n> bet/raise with the added
/// chips in percent of the pot at `k`.
fn zug(baum: &super::s1::Einsatzbaum, k: usize, kind: usize) -> String {
let c = baum.beitrag[k];
let pot = c[0] + c[1];
let neu = (baum.beitrag[kind][0] + baum.beitrag[kind][1]) - pot;
match baum.aktion[kind] {
Some(Aktion::Check) => "x".into(),
Some(Aktion::Call) => "c".into(),
Some(Aktion::Fold) => "f".into(),
Some(Aktion::Bet(_)) => format!("b{:.0}", 100.0 * neu / pot),
Some(Aktion::Raise(_)) => format!("r{:.0}", 100.0 * neu / pot),
None => "?".into(),
}
}
/// LBR against the blueprint over `haende` hands (alternating seats) on `threads` threads.
pub fn lbr(s: &S1, tab: &Tabellen, haende: usize, threads: usize, seed: u64) -> Ergebnis {
lbr_gegen(s, &Blaupause(tab), haende, threads, seed)
@@ -267,7 +306,16 @@ fn strom(seed: u64, i: u64, art: u64) -> Zufall {
/// LBR's result in bb for hand `i` alone (seat `i % 2`): the same value `lbr_werte` gives for it, so a
/// long run can be split into pieces and resumed.
pub fn lbr_hand<G: Gegner>(s: &S1, g: &G, i: u64, seed: u64, stichprobe: Option<usize>) -> f64 {
hand(s, g, (i % 2) as usize, &mut strom(seed, i, 0), &mut strom(seed, i, 1), stichprobe)
hand(s, g, (i % 2) as usize, &mut strom(seed, i, 0), &mut strom(seed, i, 1), stichprobe, None)
}
/// `lbr_hand` with its line: one token per decision (`fE:x`, `tL:b75[g=..,fp=..,eq=..]`: street, who -
/// L = LBR, E = the opponent - and the move; `g` is LBR's local gain of its choice over its best passive
/// option, `fp` the fold share it priced, `eq` its equity against the range). Same value as `lbr_hand`.
pub fn lbr_hand_spur<G: Gegner>(s: &S1, g: &G, i: u64, seed: u64) -> (f64, Vec<String>) {
let mut spur = Vec::new();
let v = hand(s, g, (i % 2) as usize, &mut strom(seed, i, 0), &mut strom(seed, i, 1), None, Some(&mut spur));
(v, spur)
}
/// LBR's result in bb for every hand `i` (seat `i % 2`), each hand on its own stream: the values do not
+4 -1
View File
@@ -135,7 +135,10 @@ fn postflop(spot: &Spot, thresholds: &Thresholds, raw: &Spot, premium: f64) -> D
return d.with_equity(equity.share);
}
// Bounded exploitation of the non-station reads (`read_exploit`, switch GEGNER_BREIT, off).
return super::read_exploit::postflop(raw, &hand_read, super::river_subgame::fold_veto(raw, floored));
// Flop fold veto and all-in veto (off by default, FLOP_VETO / JAM_VETO, lbr-veto): a heuristic
// fold becomes a call where the flop solver continues / the blueprint's all-in range pays it.
let vetoed = super::flop_spieler::jam_fold_veto(raw, super::flop_spieler::flop_fold_veto(raw, super::river_subgame::fold_veto(raw, floored)));
return super::read_exploit::postflop(raw, &hand_read, vetoed);
}
floored
}
+155 -1
View File
@@ -190,7 +190,161 @@ fn public_key(spot: &Spot, cfg: &FlopConfig) -> u64 {
/// The live stage-C decision, or `None` and the heuristic keeps it.
pub fn flop_spieler_decision(raw: &Spot) -> Option<Decision> {
if !flop_spieler() || raw.street != Street::Flop || raw.hero_cards.len() != 2 || raw.board.len() != 3 {
if !flop_spieler() {
return None;
}
solve_decision(raw)
}
/// Which villains the flop fold veto (`FLOP_VETO`, lbr-veto 15.11.) defends against.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum FlopVeto {
Aus,
/// Only a villain without a usable postflop aggression read (none, or thinner than the river
/// gearbox's trust floor): the heuristic's fold there rests on the population range model alone.
Ungelesen,
/// Every heads-up villain.
Alle,
}
/// `FLOP_VETO=1|ungelesen` or `FLOP_VETO=alle`, read once; anything else is off (bit-identical).
pub fn flop_veto() -> FlopVeto {
static V: std::sync::OnceLock<FlopVeto> = std::sync::OnceLock::new();
*V.get_or_init(|| match std::env::var("FLOP_VETO").as_deref() {
Ok("1") | Ok("ungelesen") => FlopVeto::Ungelesen,
Ok("alle") => FlopVeto::Alle,
_ => FlopVeto::Aus,
})
}
/// An aggression read thinner than this is no read (the river gearbox's and the MDF floor's floor).
const VETO_READ_MIN: f64 = 0.25;
/// Flop fold veto (lbr-veto, 15.11.): the heuristic folds a heads-up flop bet, the flop solver (ranges
/// from the blueprint where it recognises the spot, else the range model) is asked, and if its sampled
/// action continues, hero calls instead. Never touches a call, a raise or a check, so the heuristic's
/// value exploit against callers stays as it is; only the over-fold the LBR collects (engine folds
/// ~97 % of its range to a flop jam, ~63 % to a 75 % c-bet on dry boards, MDF 5 % / 43 %) is priced
/// against an equilibrium instead of the population's value-heavy betting range.
pub fn flop_fold_veto(raw: &Spot, d: Decision) -> Decision {
let modus = flop_veto();
if modus == FlopVeto::Aus
|| d.choice != crate::game::Choice::Fold
|| raw.street != Street::Flop
|| raw.to_call <= 0.0
|| !raw.is_legal(crate::game::ActionKind::Call)
{
return d;
}
if modus == FlopVeto::Ungelesen {
let gelesen = raw.live_villains().next().and_then(|v| v.profile.as_ref()).is_some_and(|p| {
p.aggression.is_some_and(|a| !a.is_nan()) && p.aggression_confidence.is_some_and(|c| !c.is_nan() && c >= VETO_READ_MIN)
});
if gelesen {
return d;
}
}
match solve_decision(raw) {
Some(s) if s.choice != crate::game::Choice::Fold => {
Decision { choice: crate::game::Choice::Call, confidence: s.confidence, reason: format!("Flop-Fold-Veto: {}", s.reason), ..d }
}
_ => d,
}
}
/// `JAM_VETO=1` (lbr-veto 15.11.), read once; anything else is off (bit-identical).
pub fn jam_veto() -> bool {
static V: std::sync::OnceLock<bool> = std::sync::OnceLock::new();
*V.get_or_init(|| std::env::var("JAM_VETO").as_deref() == Ok("1"))
}
/// All-in veto (lbr-veto, 15.11.): the heuristic folds to a heads-up flop or turn all-in (the call ends
/// the betting), and where the blueprint recognises the spot, hero's exact equity against the
/// blueprint's range for that all-in (turn and river enumerated, card removal included) is compared
/// with the price after rake; at or above it, hero calls. The LBR's largest single edge: it jams the
/// flop 19.5x pot in ~28 % of its hands and the engine folds ~97 % of its range (MDF 5 %), because the
/// population range model reads a jam as value only, while at equilibrium a huge overbet carries
/// nearly as many bluffs as value. Only folds are touched, only all-ins, only recognised spots, so
/// every call, raise and value line of the heuristic stays as it is.
pub fn jam_fold_veto(raw: &Spot, d: Decision) -> Decision {
if !jam_veto()
|| d.choice != crate::game::Choice::Fold
|| !matches!(raw.street, Street::Flop | Street::Turn)
|| raw.hero_cards.len() != 2
|| raw.to_call <= 0.0
|| !raw.is_legal(crate::game::ActionKind::Call)
|| raw.live_villains().count() != 1
{
return d;
}
// A call that ends the betting: the villain is all-in, or hero has no chips behind after calling.
let allin = raw.live_villains().next().is_some_and(|v| v.stack <= 1e-9) || raw.hero_stack <= raw.to_call + 1e-9;
if !allin {
return d;
}
// The blueprint recognises a spot by the effective stack, `min(stacks behind) + pot / 2`: after an
// all-in the jammer has nothing behind, so that reads ~half the real depth and every all-in falls out
// of the window. Here only, the villain's stack is set so the formula gives the depth at the street's
// start (`min(hero, villain) behind + street contributions` and half the pot before the street);
// nothing else of the blueprint path changes.
let mut gated = crate::engine::read_gate::gate_reads(raw);
let im_zug = |seat: u8| {
raw.history.iter().filter(|r| r.street == raw.street && r.seat == seat).filter_map(|r| r.amount).fold(0.0f64, f64::max)
};
let Some(vs) = raw.live_villains().next().map(|v| (v.seat, v.stack)) else { return d };
let (ch, cv) = (im_zug(raw.hero_seat), im_zug(vs.0));
let tiefe = (raw.hero_stack + ch).min(vs.1 + cv) + (raw.pot - ch - cv) / 2.0;
for v in gated.villains.iter_mut().filter(|v| v.seat == vs.0) {
v.stack = (tiefe - raw.pot / 2.0).max(0.0);
}
let Some((_, villain)) = crate::blueprint::ranges::gewichtete_listen_offen(&gated) else { return d };
let hero = fast7::mask(&raw.hero_cards);
let board = fast7::mask(&raw.board);
let Some(eq) = equity_vs(hero, board, &villain) else { return d };
let be = crate::odds::break_even::break_even(raw.pot, raw.to_call);
if eq < be {
return d;
}
Decision {
choice: crate::game::Choice::Call,
reason: format!("Jam-Veto: equity {eq:.3} vs blueprint all-in range ({} combos) >= break-even {be:.3}", villain.len()),
..d
}
}
/// Exact equity of `hero` against a weighted range on a flop or turn board (every run-out enumerated,
/// ties half), `None` if no combo of the range survives card removal.
fn equity_vs(hero: u64, board: u64, range: &[(Vec<Card>, f64)]) -> Option<f64> {
let dead = hero | board;
let deck: Vec<u64> = (0..4).flat_map(|s| (0..13).map(move |r| 1u64 << (16 * s + r))).filter(|b| b & dead == 0).collect();
let combos: Vec<(u64, f64)> = range.iter().map(|(c, w)| (fast7::mask(c), *w)).filter(|(m, w)| m & dead == 0 && *w > 0.0).collect();
if combos.is_empty() {
return None;
}
let runouts: Vec<u64> = match board.count_ones() {
3 => (0..deck.len()).flat_map(|i| (i + 1..deck.len()).map(move |j| (i, j))).map(|(i, j)| deck[i] | deck[j]).collect(),
4 => deck.clone(),
_ => vec![0],
};
let (mut won, mut tot) = (0.0, 0.0);
for r in &runouts {
let full = board | r;
let me = fast7::score(full | hero);
for (m, w) in &combos {
if m & r != 0 {
continue;
}
let o = fast7::score(full | m);
won += w * if me > o { 1.0 } else if me == o { 0.5 } else { 0.0 };
tot += w;
}
}
(tot > 0.0).then(|| won / tot)
}
/// The flop solve's sampled action for hero, or `None` (not a heads-up flop, no ranges, no time).
fn solve_decision(raw: &Spot) -> Option<Decision> {
if raw.street != Street::Flop || raw.hero_cards.len() != 2 || raw.board.len() != 3 {
return None;
}
let gated = crate::engine::read_gate::gate_reads(raw);