Live 14.11. (Micro-Lauf 4, Hand 177615800656, -89,5 BB): CO open-jammt 89,5 bb, Hero A7o am
BTN deckt ihn; die Chips zeigten kein All-in, die History eine Erhoehung -> "BTN vs open",
die CFR-Tabelle fuer 2,5-bb-Opens callte 99 %. Ebenso 177689800508 (75o im BB gegen 34 bb, -34 BB).
- preflop::open_jam: einzige Erhoehung all-in (ALL_IN oder Stack 0) oder committend (Erhoehung
>= Reststack) = Open-Jam. Situation FacingAllIn, Tiefe = der Jam (min der Gesamtstacks).
Blinds <= 25 bb: die Nash-Call-Tabellen; sonst Call genau dann, wenn die Equity gegen die
Nash-Push-Range des Jammer-Sitzes (bei 25 bb gedeckelt, die weiteste rationale Range) den
Preis erreicht. Exakt je Klasse mit Kartenentfernung (eingefrorene Equity-Matrix).
- Schalter OPEN_JAM=1 (Vorgabe aus = altes Verhalten), in decide.py als bekannter Schalter.
- Fixture tests/live_fixture/open_jam_2026-11-14.jsonl (alle 5 beantwortbaren Open-Jams des
Tages), Spec tests/preflop_open_jam.rs: aus = Live-Antwort, an = neu.
- open_jam_ev: Chip-EV alt/neu ueber alle Hero-Haende, 33 Spots x 8 Jam-Ranges
(messung_openjam/open_jam_ev.txt). ab_zelle zaehlt Open-Jam-Entscheidungen des Arms.
cargo test --lib und die Preflop-/Pipeline-Specs gruen; pipeline_bluff (1) und
preflop_multi_advice (3) scheitern schon auf b1f8d2e, unberuehrt.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
165 lines
6.7 KiB
Rust
165 lines
6.7 KiB
Rust
//! Spec: an all-in OPEN is answered against a jam range, not by the "vs open" tables.
|
||
//!
|
||
//! Live leak, Micro run 4 (14.11., hand 177615800656, −89.5 BB): the cutoff open-jammed ≈ 90 bb,
|
||
//! hero A7o on the button covered it (1.98 behind, 1.79 to call). The chips did not show an all-in
|
||
//! for hero, the history showed one raise, so the engine read "vs open" and the CFR table for a
|
||
//! 2.5 bb open called 99 %. The request is frozen in `tests/live_fixture/open_jam_2026-11-14.jsonl`.
|
||
//!
|
||
//! The switch `OPEN_JAM` (default off) is process-global, so everything that toggles it runs in
|
||
//! ONE test, in order.
|
||
|
||
use rechner::game::{SeenAction, Spot};
|
||
use rechner::guard::validate::check;
|
||
use rechner::json::{parse, render, Value};
|
||
use rechner::preflop::open_jam::{call_vs_jam, depth_bb, open_jam, price, set_open_jam};
|
||
use rechner::wire::decode::decode;
|
||
use rechner::wire::respond::respond;
|
||
|
||
const FIXTURE: &str = include_str!("live_fixture/open_jam_2026-11-14.jsonl");
|
||
|
||
fn field<'a>(v: &'a Value, key: &str) -> &'a Value {
|
||
match v {
|
||
Value::Object(fields) => &fields.iter().find(|(k, _)| k == key).unwrap_or_else(|| panic!("no {key}")).1,
|
||
_ => panic!("not an object"),
|
||
}
|
||
}
|
||
|
||
fn set(v: &mut Value, key: &str, new: Value) {
|
||
match v {
|
||
Value::Object(fields) => match fields.iter_mut().find(|(k, _)| k == key) {
|
||
Some(slot) => slot.1 = new,
|
||
None => fields.push((key.to_string(), new)),
|
||
},
|
||
_ => panic!("not an object"),
|
||
}
|
||
}
|
||
|
||
/// The fixture cases (every answerable open-jam of 14.11.).
|
||
fn cases() -> Vec<Value> {
|
||
FIXTURE.lines().filter(|l| !l.trim().is_empty()).map(|l| parse(l).expect("fixture json")).collect()
|
||
}
|
||
|
||
fn text(v: &Value, key: &str) -> String {
|
||
match field(v, key) {
|
||
Value::String(s) => s.clone(),
|
||
other => panic!("{key}: {other:?}"),
|
||
}
|
||
}
|
||
|
||
/// The live request of hand 177615800656 (A7o, −89.5 BB).
|
||
fn live() -> Value {
|
||
let case = cases().into_iter().find(|c| text(c, "hand") == "177615800656").expect("hand 177615800656");
|
||
field(&case, "spot").clone()
|
||
}
|
||
|
||
fn cards(a: (&str, &str), b: (&str, &str)) -> Value {
|
||
parse(&format!(r#"[{{"rank":"{}","suit":"{}"}},{{"rank":"{}","suit":"{}"}}]"#, a.0, a.1, b.0, b.1)).unwrap()
|
||
}
|
||
|
||
/// The live request with other hole cards (none of them is dead in the live hand).
|
||
fn live_with(a: (&str, &str), b: (&str, &str)) -> Value {
|
||
let mut v = live();
|
||
set(&mut v, "heroCards", cards(a, b));
|
||
v
|
||
}
|
||
|
||
fn spot(v: &Value) -> Spot {
|
||
check(decode(v).expect("decode")).expect("valid")
|
||
}
|
||
|
||
/// (action, reason) of the engine for a request.
|
||
fn answer(v: &Value) -> (String, String) {
|
||
let out = parse(&respond(&render(v))).expect("answer json");
|
||
(text(&out, "action"), text(&out, "reason"))
|
||
}
|
||
|
||
#[test]
|
||
fn open_jam_detection_and_price() {
|
||
let s = spot(&live());
|
||
let jam = open_jam(&s).expect("the live open is an open-jam");
|
||
assert_eq!(jam.seat, 1);
|
||
assert!((jam.raised_to - 1.79).abs() < 1e-9 && (jam.total - 1.79).abs() < 1e-9, "{jam:?}");
|
||
// Hero covers: the depth is the jam (89.5 bb), not hero's 99 bb.
|
||
assert!((depth_bb(&s, &jam) - 89.5).abs() < 1e-6, "{}", depth_bb(&s, &jam));
|
||
// Hero calls 1.79 into 1.82 + 1.79: needs 49.6 %.
|
||
let (call, pot) = price(&s, &jam);
|
||
assert!((call - 1.79).abs() < 1e-9 && (pot - 3.61).abs() < 1e-9, "{call} {pot}");
|
||
|
||
// A normal open (2.5 bb raise, chips behind) is not an open-jam.
|
||
let mut normal = live();
|
||
let history = parse(
|
||
r#"[{"street":"PREFLOP","seat":3,"action":"POST_SB","amount":0.01},
|
||
{"street":"PREFLOP","seat":4,"action":"POST_BB","amount":0.02},
|
||
{"street":"PREFLOP","seat":5,"action":"FOLD"},
|
||
{"street":"PREFLOP","seat":1,"action":"RAISE","amount":0.05}]"#,
|
||
)
|
||
.unwrap();
|
||
set(&mut normal, "history", history);
|
||
set(&mut normal, "toCall", Value::Number(0.05));
|
||
set(&mut normal, "pot", Value::Number(0.08));
|
||
let mut ns = spot(&normal);
|
||
ns.villains.iter_mut().filter(|v| v.seat == 1).for_each(|v| v.stack = 1.74);
|
||
assert_eq!(open_jam(&ns), None);
|
||
// A committing open (raise to 1.00 with 0.79 behind) is one: the jammer's whole 1.79 is at stake.
|
||
ns.history.iter_mut().filter(|r| r.seat == 1).for_each(|r| r.amount = Some(1.0));
|
||
ns.villains.iter_mut().filter(|v| v.seat == 1).for_each(|v| v.stack = 0.79);
|
||
let committed = open_jam(&ns).expect("committing open");
|
||
assert!((committed.total - 1.79).abs() < 1e-9, "{committed:?}");
|
||
// A 3-bet jam (two raises) is not an open-jam.
|
||
let mut three = spot(&live());
|
||
three.history.insert(3, rechner::game::ActionRecord {
|
||
street: rechner::game::Street::Preflop,
|
||
seat: 5,
|
||
action: SeenAction::Raise,
|
||
amount: Some(0.05),
|
||
});
|
||
assert_eq!(open_jam(&three), None);
|
||
}
|
||
|
||
#[test]
|
||
fn live_open_jam_folds_a7o_and_calls_the_top() {
|
||
// Switch off: the live answer, reproduced (the replay is faithful).
|
||
set_open_jam(false);
|
||
let (action, reason) = answer(&live());
|
||
assert_eq!(action, "CALL", "{reason}");
|
||
assert!(reason.contains("vs open"), "{reason}");
|
||
|
||
// Switch on: A7o folds against the cutoff's jam range.
|
||
set_open_jam(true);
|
||
let (action, reason) = answer(&live());
|
||
assert_eq!(action, "FOLD", "{reason}");
|
||
assert!(reason.contains("open-jam"), "{reason}");
|
||
let plan = call_vs_jam(&spot(&live()), 0.0).expect("answered by the jam rule");
|
||
assert!(plan.reason.contains("price 0.496"), "{}", plan.reason);
|
||
|
||
// The top of the deck still calls; the hands the "vs open" table called but the jam range
|
||
// beats fold.
|
||
for (a, b, want) in [
|
||
(("ACE", "SPADES"), ("ACE", "HEARTS"), "CALL"),
|
||
(("KING", "SPADES"), ("KING", "HEARTS"), "CALL"),
|
||
(("QUEEN", "SPADES"), ("QUEEN", "HEARTS"), "CALL"),
|
||
(("ACE", "SPADES"), ("KING", "SPADES"), "CALL"),
|
||
(("ACE", "HEARTS"), ("TEN", "SPADES"), "FOLD"),
|
||
(("KING", "HEARTS"), ("QUEEN", "SPADES"), "FOLD"),
|
||
(("SIX", "SPADES"), ("SIX", "HEARTS"), "FOLD"),
|
||
] {
|
||
let (action, reason) = answer(&live_with(a, b));
|
||
assert_eq!(action, want, "{a:?}{b:?}: {reason}");
|
||
}
|
||
|
||
// Every answerable open-jam of 14.11. (5 hands): off = the live answer, on = `neu`.
|
||
// 177615800656 A7o and 177689800508 75o (BB vs 34 bb, −34 BB) called and fold now; JJ in the
|
||
// small blind (120 bb jam) raised and calls now - the same all-in.
|
||
for case in cases() {
|
||
let hand = text(&case, "hand");
|
||
set_open_jam(false);
|
||
let (old, why) = answer(field(&case, "spot"));
|
||
assert_eq!(old, text(&case, "live"), "{hand} off: {why}");
|
||
set_open_jam(true);
|
||
let (new, why) = answer(field(&case, "spot"));
|
||
assert_eq!(new, text(&case, "neu"), "{hand} on: {why}");
|
||
assert!(why.contains("open-jam"), "{hand} on: {why}");
|
||
}
|
||
set_open_jam(false);
|
||
}
|