From 2579773005b3f49a12b95afd8ad64ecaddda9886 Mon Sep 17 00:00:00 2001 From: Marc Mintel Date: Sat, 7 Nov 2026 00:44:20 +0100 Subject: [PATCH] PLO5 messbar: Ende-zu-Ende-Pipeline-Test und River-Call/Fold-Messlatte - tests/pipeline_plo5.rs: echte Fuenf-Karten-Spots durch wire::respond, prueft gueltige Aktionen und die genau-2-aus-5-Handklassen (Set, Strasse, kein Flush aus vier gleichfarbigen Lochkarten) ueber den vorhandenen Evaluator. - src/bin/benchmark_plo5.rs + benchmarks/plo5_baseline.txt: Messlatte ueber einen festen Satz River-Spots. Tiefe Monte-Carlo-Equity (120k) als Wahrheit, Chip-EV der Engine-Aktion als Spot-Wert, gepaarter Vergleich (sim::paired) mit Verdikt BESSER/SCHLECHTER/gleich und Exit 1 bei Rueckschritt. - plans/2026-11-06_plo5/03_PLO5_MESSLATTE.md: wie man misst, Grenzen der Messung. --- benchmarks/plo5_baseline.txt | 16 ++ plans/2026-11-06_plo5/03_PLO5_MESSLATTE.md | 48 ++++ src/bin/benchmark_plo5.rs | 242 +++++++++++++++++++++ tests/pipeline_plo5.rs | 113 ++++++++++ 4 files changed, 419 insertions(+) create mode 100644 benchmarks/plo5_baseline.txt create mode 100644 plans/2026-11-06_plo5/03_PLO5_MESSLATTE.md create mode 100644 src/bin/benchmark_plo5.rs create mode 100644 tests/pipeline_plo5.rs diff --git a/benchmarks/plo5_baseline.txt b/benchmarks/plo5_baseline.txt new file mode 100644 index 00000000..d2cad87c --- /dev/null +++ b/benchmarks/plo5_baseline.txt @@ -0,0 +1,16 @@ +label ed79423e+lokal +scenario monster +deals 5 +seed 104372000587777 +counts 5 0 0 +samples 9.771833333333333 10 7.0425 9.094916666666666 10 +scenario marginal +deals 5 +seed 104372000587777 +counts 5 0 0 +samples 7.1335 3.4498291666666674 6.981533333333333 9.33625 -3.7799166666666664 +scenario trash +deals 5 +seed 104372000587777 +counts 5 0 0 +samples 0 0 0 0 0 diff --git a/plans/2026-11-06_plo5/03_PLO5_MESSLATTE.md b/plans/2026-11-06_plo5/03_PLO5_MESSLATTE.md new file mode 100644 index 00000000..f5b314b9 --- /dev/null +++ b/plans/2026-11-06_plo5/03_PLO5_MESSLATTE.md @@ -0,0 +1,48 @@ +# PLO5-Messlatte und Ende-zu-Ende-Test (7.11.2026) + +Ohne Messlatte ist jede Engine-Verbesserung auf PLO5 unbeweisbar. Dieser Schritt liefert zwei +Belege, analog zu dem, was NLHE (`benchmark`) und PLO4 (`pipeline_plo4`) schon haben. + +## 1. Ende-zu-Ende-Test: `tests/pipeline_plo5.rs` + +Echte PLO5-Spots (fuenf Lochkarten) laufen durch die ganze Kette (`wire::respond`). Geprueft wird: +gueltige Aktion statt Ablehnung, falsche Lochkartenzahl wird abgelehnt, und vor allem die +Handklasse als **genau zwei aus fuenf**: ein Hole-Paar + Brett-Match = Set, zwei Hole-Verbinder + +drei Brettkarten = Strasse, und vier gleichfarbige Lochkarten ergeben **keinen** Flush (das trennt +die Omaha-Regel sauber von Hold'em "beste fuenf aus allen"). Die Showdown-Bewertung nutzt den +vorhandenen Evaluator `hand::showdown::best`, keinen neuen. + + cargo test --test pipeline_plo5 # 6 Pruefungen, gruen + +## 2. Die Messlatte: `src/bin/benchmark_plo5.rs` + `benchmarks/plo5_baseline.txt` + +Fuer PLO5 gibt es noch keinen Gegner-Simulator wie bei NLHE. Die Messlatte misst deshalb einen eng +umrissenen, aber ehrlichen Teil der Staerke: die **River-Entscheidung Call/Fold** ueber einen +festen Satz Referenz-Spots (fuenf Lochkarten, fertiges Brett). + +So misst sie: +1. Eine **tiefe** Monte-Carlo-Equity (`equity::monte_carlo`, 120 000 Laeufe, fester Seed) liefert + je Spot die Wahrheit E = Hero-Anteil gegen zufaellige Gegnerhaende. +2. Die Engine bekommt denselben Spot und waehlt CALL oder FOLD. +3. Spot-Wert = Chip-EV der gewaehlten Aktion am Showdown, in Big Blinds: + `CALL -> E*(Pot+ToCall) - ToCall`, `FOLD -> 0`. Guter Call zahlt positiv, schlechter negativ. +4. Zwei Laeufe werden Spot fuer Spot gepaart verglichen (`sim::paired`, dieselbe Logik wie die + NLHE-Leiter) -> Verdikt **BESSER / SCHLECHTER / gleich**, Exit-Code 1 bei Rueckschritt. + + cargo run --release --bin benchmark_plo5 # gegen die Basislinie + cargo run --release --bin benchmark_plo5 -- --save # aktuelle Engine wird zur Basislinie + +### Erste Basislinie (echt gelaufen, Commit ed79423e, 15 Spots, ~7 s) + +Summe EV +69,03 bb. Monster (Set, Flush, Strasse, Quads, Full House) callt die Engine alle korrekt +mit hohem EV. Die Messlatte deckt zugleich einen **echten Leak** auf: Ueberpaar Asse auf dem Brett +9-8-7-6-5 hat nur 18,9 % Equity, die Engine callt trotzdem (EV -3,78 bb). Totes Blatt (Muell) foldet +sie durchweg. Gegen sich selbst: "gleich", 0 geaendert, reproduzierbar. + +### Grenzen (bewusst, ehrlich) + +- Nur River, nur Call/Fold. Kein Bet-Sizing, keine Bluffs, keine fruehen Strassen, kein Preflop. +- Wahrheit gegen **Zufalls**-Gegner, nicht gegen geschaetzte Ranges. Der systematische Zufalls-Bias + ist in beiden Laeufen gleich und hebt sich im gepaarten Unterschied weitgehend auf; das Verdikt + misst die *Veraenderung*, nicht das absolute Niveau. +- Aendert man den Equity-Referenzkern (`equity/`) selbst, muss die Basislinie neu gespeichert werden. diff --git a/src/bin/benchmark_plo5.rs b/src/bin/benchmark_plo5.rs new file mode 100644 index 00000000..4d70ba03 --- /dev/null +++ b/src/bin/benchmark_plo5.rs @@ -0,0 +1,242 @@ +//! PLO5-Messlatte: Ist die Engine auf PLO5 staerker oder schwaecher als vorher? +//! +//! Die NLHE-Leiter (`src/bin/benchmark.rs`) spielt ganze Haende im Selbstspiel. Fuer PLO5 gibt es +//! dafuer noch keinen Gegner-Simulator. Diese Messlatte misst stattdessen einen eng umrissenen, +//! aber ehrlichen Teil der Staerke: die River-Entscheidung Call/Fold ueber einen festen Satz +//! Referenz-Spots (fuenf Lochkarten, fertiges Brett). +//! +//! WIE gemessen wird: +//! 1. Fuer jeden Spot liefert eine TIEFE Monte-Carlo-Equity (`equity::monte_carlo`, 120k Laeufe, +//! fester Seed) die Wahrheit E = Hero-Anteil gegen zufaellige Gegnerhaende. +//! 2. Die Engine (`wire::respond`) bekommt genau diesen Spot und waehlt CALL oder FOLD. +//! 3. Der Spot-Wert ist der Chip-EV der gewaehlten Aktion am Showdown, in Big Blinds: +//! CALL -> E * (Pot + ToCall) - ToCall FOLD -> 0 +//! Ein guter Call (E ueber dem Preis) zahlt positiv, ein schlechter negativ; Fold ist 0. +//! 4. Zwei Laeufe werden Spot fuer Spot gepaart verglichen (`sim::paired`), Verdikt +//! BESSER / SCHLECHTER / gleich -- wie die NLHE-Leiter. +//! +//! ```text +//! cargo run --release --bin benchmark_plo5 # gegen benchmarks/plo5_baseline.txt +//! cargo run --release --bin benchmark_plo5 -- --save # aktuelle Engine wird zur Basislinie +//! ``` +//! +//! Grenzen (bewusst eng): nur River, nur Call/Fold, Wahrheit gegen ZUFALLS-Gegner (nicht gegen +//! geschaetzte Ranges). Misst also Equity-Treue der River-Calls, nicht Bet-Sizing, Bluffs oder +//! fruehe Strassen. Der systematische Zufalls-Bias hebt sich im gepaarten Unterschied weitgehend auf. + +use rechner::card::Card; +use rechner::equity::monte_carlo::estimate; +use rechner::equity::query::Query; +use rechner::equity::villain_range::VillainRange; +use rechner::rng::Rng; +use rechner::sim::benchmark::{parse, render, verdict_of_run, Report, Run, ScenarioRun}; +use rechner::sim::paired::Verdict; +use rechner::variant::{rules, Variant}; +use rechner::wire::respond::respond; +use std::process::{exit, Command}; +use std::time::Instant; +use std::{env, fs, thread}; + +const BASELINE: &str = "benchmarks/plo5_baseline.txt"; +const REF_TRIALS: u32 = 120_000; +const REF_SEED: u64 = 0x5EED_0005_0001; +const ENGINE_SEED: u64 = 0x5EED_0005_ABCD; +const STACK_BB: f64 = 1000.0; + +/// Ein Referenz-Spot: Hero haelt fuenf Karten, das Brett ist komplett (River), Hero muss `to_call` +/// in einen Pot von `pot` (beides in Big Blinds) zahlen, gegen `villains` lebende Gegner. +struct RefSpot { + scenario: &'static str, + hero: &'static str, + board: &'static str, + villains: usize, + pot: f64, + to_call: f64, +} + +const fn spot(scenario: &'static str, hero: &'static str, board: &'static str, villains: usize, pot: f64, to_call: f64) -> RefSpot { + RefSpot { scenario, hero, board, villains, pot, to_call } +} + +/// Fester Satz Spots. Monster sollen callen, Muell soll folden, dazwischen liegt die Kante. +const SPOTS: [RefSpot; 15] = [ + // Monster (heads-up, Pot-Bet): starke Made-Hands, Call ist klar +EV. + spot("monster", "As Ah Ks Kh 2c", "Ac Kd 7s 7d 2h", 1, 10.0, 10.0), // Asse voll + spot("monster", "Ah Kh 2c 3d 4s", "9h 5h 3h Ts 2d", 1, 10.0, 10.0), // Nut-Flush + spot("monster", "Qs Qh 2c 3d 4s", "Qd 9h 5s 7c 2h", 1, 10.0, 10.0), // Top-Set + spot("monster", "Th 9h Ad Ks Qc", "8c 7d 6s 2h Jd", 1, 10.0, 10.0), // Strasse + spot("monster", "Js Jh 2c 3d 4s", "Jd Jc 9h 5s 2h", 1, 10.0, 10.0), // Quads + // Marginal (heads-up, Halb- bis Pot-Bet): echte Kantenentscheidungen um die Preisgrenze. + spot("marginal", "As 5h 2c 3d 4s", "Ad 9h 5c 7d 2s", 1, 10.0, 5.0), // zwei Paar Asse/Fuenfen + spot("marginal", "Ks Qh 2c 3d 4s", "Kd 9h 5c 7d 2s", 1, 10.0, 7.0), // Top-Paar Koenige + spot("marginal", "Th Td 2c 3d 4s", "Ah 9h 5c 7d 2s", 1, 10.0, 6.0), // Unterpaar + spot("marginal", "9s 8h 2c 3d 4s", "7d 6h 5c Ad Ks", 1, 10.0, 5.0), // Strasse auf Angstbrett + spot("marginal", "As Ah 2c 3d 4s", "9h 8s 7c 6d 5h", 1, 10.0, 7.0), // Ueberpaar auf Strassenbrett + // Muell (drei Gegner, Pot-Bet): breite Niederlage, Fold ist klar richtig. + spot("trash", "6c 7d 8h Tc Qs", "As Kd 9h 4c 2s", 3, 12.0, 10.0), + spot("trash", "2s 3s 4h 6h 8d", "Ac Kd Qh Js 9c", 3, 12.0, 10.0), + spot("trash", "7s 6h 2c 3d 4h", "As Ad Kh Qc Jd", 3, 12.0, 10.0), + spot("trash", "9c 8d 2h 3s 4c", "Ah Ad Kh Qd Jc", 3, 12.0, 10.0), + spot("trash", "Ts 9d 2c 3h 4s", "Ac Kc Qc 5d 2h", 3, 12.0, 10.0), // moegliches Gegner-Flush-Brett +]; + +/// Hero-Anteil am Pot gegen `villains` zufaellige Gegner, tief ausgewuerfelt: die Wahrheit. +fn reference_equity(index: usize, s: &RefSpot) -> f64 { + let hero = Card::parse_list(s.hero).expect("hero cards"); + let board = Card::parse_list(s.board).expect("board cards"); + let ranges: Vec = (0..s.villains).map(|_| VillainRange::Any).collect(); + let query = Query { rules: rules(Variant::Plo5), hero: &hero, board: &board, villains: &ranges, trials: REF_TRIALS }; + let seed = REF_SEED.wrapping_add(index as u64 * 0x9E37_79B9_7F4A_7C15); + estimate(&query, Rng::seeded(seed)).expect("reference spot must be a valid query").0.share +} + +fn card_json(c: Card) -> String { + format!(r#"{{"rank":"{}","suit":"{}"}}"#, c.rank.name(), c.suit.name()) +} + +fn cards_json(cards: &[Card]) -> String { + format!("[{}]", cards.iter().map(|c| card_json(*c)).collect::>().join(",")) +} + +fn request(s: &RefSpot) -> String { + let hero = Card::parse_list(s.hero).expect("hero cards"); + let board = Card::parse_list(s.board).expect("board cards"); + let villains: Vec = (0..s.villains) + .map(|i| format!(r#"{{"seat":{},"stack":{STACK_BB},"folded":false}}"#, i + 1)) + .collect(); + format!( + r#"{{"variant":"PLO5","bigBlind":1.0,"seats":6,"heroSeat":6,"buttonSeat":1,"heroCards":{},"board":{{"FLOP":{},"TURN":{},"RIVER":{}}},"street":"RIVER","pot":{},"toCall":{},"heroStack":{STACK_BB},"legalActions":["FOLD","CALL"],"seed":{ENGINE_SEED},"villains":[{}]}}"#, + cards_json(&hero), + cards_json(&board[0..3]), + cards_json(&board[3..4]), + cards_json(&board[4..5]), + s.pot, + s.to_call, + villains.join(","), + ) +} + +fn action(response: &str) -> String { + let start = response.find("\"action\":").map(|i| i + 9).unwrap_or(0); + response[start..].trim_start().trim_start_matches('"').chars().take_while(|c| *c != '"').collect() +} + +/// Chip-EV der Aktion am Showdown, in Big Blinds. Fold ist 0, Call setzt den Anteil in Chips um. +fn score(action: &str, equity: f64, s: &RefSpot) -> f64 { + match action { + "CALL" => equity * (s.pot + s.to_call) - s.to_call, + _ => 0.0, // FOLD oder (unerwartet) ABSTAIN: nichts investiert, nichts gewonnen. + } +} + +struct Played { + equity: f64, + action: String, + sample: f64, +} + +fn play(index: usize, s: &RefSpot) -> Played { + let equity = reference_equity(index, s); + let action = action(&respond(&request(s))); + let sample = score(&action, equity, s); + Played { equity, action, sample } +} + +/// Spielt alle Spots (ein Thread je Spot) und buendelt sie nach Szenario zu `ScenarioRun`s. +fn run_all(label: &str) -> (Run, Vec) { + let played: Vec = thread::scope(|scope| { + let handles: Vec<_> = SPOTS.iter().enumerate().map(|(i, s)| scope.spawn(move || play(i, s))).collect(); + handles.into_iter().map(|h| h.join().expect("spot panicked")).collect() + }); + let mut scenarios: Vec = Vec::new(); + for (s, p) in SPOTS.iter().zip(&played) { + if scenarios.last().map(|r| r.name != s.scenario).unwrap_or(true) { + scenarios.push(ScenarioRun { + name: s.scenario.to_string(), + deals: 0, + seed: REF_SEED, + decisions: 0, + abstains: 0, + invalid: 0, + samples: Vec::new(), + }); + } + let run = scenarios.last_mut().expect("just pushed"); + run.deals += 1; + if p.action == "ABSTAIN" { + run.abstains += 1; + run.invalid += 1; // Aussetzen auf einem gueltigen River-Spot ist ein Defekt. + } else { + run.decisions += 1; + } + run.samples.push(p.sample); + } + (Run { label: label.to_string(), scenarios }, played) +} + +fn git(args: &[&str]) -> String { + Command::new("git").args(args).output().map(|o| String::from_utf8_lossy(&o.stdout).trim().to_string()).unwrap_or_default() +} + +fn version() -> String { + let dirty = if git(&["status", "--porcelain"]).is_empty() { "" } else { "+lokal" }; + format!("{}{dirty}", git(&["rev-parse", "--short", "HEAD"])) +} + +fn word(verdict: Verdict) -> &'static str { + match verdict { + Verdict::Identical => "gleich", + Verdict::Better => "BESSER", + Verdict::Worse => "SCHLECHTER", + Verdict::Unclear => "nicht unterscheidbar", + } +} + +fn print_spots(played: &[Played]) { + for (s, p) in SPOTS.iter().zip(played) { + println!("{:<9} {:<17} E={:>5.1}% {:<5} EV={:>+7.2} bb", s.scenario, s.hero, 100.0 * p.equity, p.action, p.sample); + } +} + +fn print_report(report: &Report) { + for (name, c) in &report.scenarios { + println!("{name:<14} {:>+8.2} ± {:>6.2} bb {:>3} geaendert {}", c.delta_bb_per_100 / 100.0, c.ci95 / 100.0, c.changed_deals, word(c.verdict)); + } + println!("{:<14} {:>+8.2} ± {:>6.2} bb {:>3} geaendert {}", "GESAMT", report.overall.delta_bb_per_100 / 100.0, report.overall.ci95 / 100.0, report.overall.changed_deals, word(report.overall.verdict)); + if report.invalid > 0 { + println!("{} Aussetzer auf gueltigen Spots: Defekt in der PLO5-Entscheidung", report.invalid); + } +} + +fn main() { + let save = env::args().any(|a| a == "--save"); + let started = Instant::now(); + let (run, played) = run_all(&version()); + print_spots(&played); + let total: f64 = played.iter().map(|p| p.sample).sum(); + println!("\n{} Summe EV {:>+.2} bb ueber {} Spots in {:.0} s", run.label, total, played.len(), started.elapsed().as_secs_f64()); + if save { + if let Err(e) = fs::write(BASELINE, render(&run)) { + eprintln!("{BASELINE}: {e}"); + exit(2); + } + println!("Basislinie gespeichert: {BASELINE}"); + return; + } + let base = fs::read_to_string(BASELINE).map_err(|e| format!("{BASELINE}: {e}")).and_then(|t| parse(&t)); + match base.and_then(|b| { + println!("\ngegen Basislinie {}", b.label); + verdict_of_run(&b, &run) + }) { + Ok(report) => { + print_report(&report); + if report.has_regression() { + exit(1); + } + } + Err(e) => { + eprintln!("{e}"); + exit(2); + } + } +} diff --git a/tests/pipeline_plo5.rs b/tests/pipeline_plo5.rs new file mode 100644 index 00000000..d1259232 --- /dev/null +++ b/tests/pipeline_plo5.rs @@ -0,0 +1,113 @@ +//! PLO5 (five hole cards, Omaha rule, pot-limit) end to end through `wire::respond::respond`. +//! +//! Companion to `tests/pipeline_plo4.rs`: real five-card spots travel the whole pipeline +//! (decode -> guard -> engine -> encode) and we check that the answer is a legal action and +//! that the hand is read as "exactly two hole cards plus three board cards" -- a set from a +//! hole pair, a straight from two connectors, and never a flush from four suited hole cards. +//! The showdown reading uses the existing evaluator (`hand::showdown::best`); no new one. + +mod support; + +use rechner::hand::category::Category; +use rechner::hand::showdown::best; +use rechner::variant::HoleUsage; +use rechner::wire::respond::respond; +use support::{action, board_json, cards_json, field, short, size}; + +/// Aces in the hand (for the set), broadway kickers. +const HERO: &str = "As Ah Ks Qh Jd"; + +fn request(hero: &str, board: &str, pot: f64, to_call: f64, legal: &str, max_raise: f64) -> String { + let cards = short(board); + let street = match cards.len() { + 0 => "PREFLOP", + 3 => "FLOP", + 4 => "TURN", + _ => "RIVER", + }; + format!( + r#"{{"variant":"PLO5","bigBlind":0.05,"seats":6,"heroSeat":6,"buttonSeat":4,"heroCards":{},"board":{},"street":"{street}","pot":{pot},"toCall":{to_call},"heroStack":3.84,"minRaiseTo":{},"maxRaiseTo":{max_raise},"legalActions":{legal},"villains":[{{"seat":4,"stack":4.89,"folded":false}}]}}"#, + cards_json(&short(hero)), + board_json(&cards), + (to_call * 2.0).max(0.05), + ) +} + +const FACING_BET: &str = r#"["FOLD","CALL","RAISE"]"#; +const CHECKED_TO: &str = r#"["CHECK","RAISE"]"#; + +#[test] +fn a_real_plo5_request_is_answered_not_rejected() { + // Set of aces on a dry flop: a legal action, never a fold, and no decode/guard complaint. + let out = respond(&request(HERO, "Ac 7d 2s", 0.2, 0.1, FACING_BET, 3.84)); + assert_ne!(action(&out), "ABSTAIN", "{out}"); + let reason = field(&out, "reason").unwrap_or(""); + assert!(!reason.contains("expected") && !reason.contains("invalid"), "{out}"); + assert_ne!(action(&out), "FOLD", "{out}"); +} + +#[test] +fn any_other_number_of_hole_cards_is_refused() { + for hero in ["As Ah Ks Qh", "As Ah Ks Qh Jd 9c"] { + let out = respond(&request(hero, "Ac 7d 2s", 0.2, 0.1, FACING_BET, 3.84)); + assert_eq!(action(&out), "ABSTAIN", "{hero}: {out}"); + let reason = field(&out, "reason").unwrap_or(""); + assert!(reason.contains("expected 5 cards for PLO5"), "{hero}: {out}"); + } +} + +#[test] +fn a_hole_pair_plus_a_board_match_is_read_as_a_set() { + // Two hole aces plus the board ace: three of a kind under the exactly-two rule. + let (hole, board) = (short(HERO), short("Ac 7d 2s")); + let strength = best(HoleUsage::ExactlyTwoHole, &hole, &board).expect("valid"); + assert_eq!(strength.category, Category::ThreeOfAKind); + + // And the pipeline reports the same category on the river of that board. + let out = respond(&request(HERO, "Ac 7d 2s 9h 4c", 0.4, 0.0, CHECKED_TO, 3.84)); + assert_eq!(field(&out, "category"), Some("\"ThreeOfAKind\""), "{out}"); +} + +#[test] +fn two_hole_connectors_make_a_straight_with_three_board_cards() { + // Ten-nine in the hand with 8-7-6 on the board: a made straight, exactly two hole cards. + let hero = "Th 9c Ad Ks Qh"; + let (hole, board) = (short(hero), short("8h 7c 6d")); + let strength = best(HoleUsage::ExactlyTwoHole, &hole, &board).expect("valid"); + assert_eq!(strength.category, Category::Straight); + + let out = respond(&request(hero, "8h 7c 6d 2s 2h", 0.4, 0.0, CHECKED_TO, 3.84)); + assert_eq!(field(&out, "category"), Some("\"Straight\""), "{out}"); +} + +#[test] +fn four_suited_hole_cards_cannot_make_a_flush() { + // Four hole hearts, but only two hearts on the board: a flush needs three board cards of the + // suit, so exactly-two-hole can never reach five hearts here. + let hero = "Ah Kh Qh Jh 2c"; + let (hole, board) = (short(hero), short("9h 5h 3d 8c 2s")); + let strength = best(HoleUsage::ExactlyTwoHole, &hole, &board).expect("valid"); + assert!(strength.category < Category::Straight, "{:?}", strength.category); + + let out = respond(&request(hero, "9h 5h 3d 8c 2s", 1.0, 0.0, CHECKED_TO, 3.84)); + let category = field(&out, "category").unwrap_or(""); + assert!(!category.contains("Flush") && !category.contains("Straight"), "{out}"); +} + +#[test] +fn raises_never_exceed_the_pot() { + let mut raises = 0; + for (pot, to_call) in [(0.2, 0.0), (0.2, 0.1), (0.5, 0.25), (1.2, 0.4), (3.0, 1.0)] { + for (board, hero) in [("Ac 7d 2s", HERO), ("Ac 7d 2s 9h 4c", HERO), ("8h 7c 6d", "Th 9c Ad Ks Qh")] { + let legal = if to_call > 0.0 { FACING_BET } else { CHECKED_TO }; + let out = respond(&request(hero, board, pot, to_call, legal, 3.84)); + if action(&out) == "RAISE" { + raises += 1; + let s = size(&out).expect("a raise carries a size"); + let cap = pot + 2.0 * to_call; + assert!(s <= cap + 1e-9, "raise to {s} over pot-limit cap {cap}: {out}"); + } + } + } + assert!(raises > 0, "the set of aces must raise at least once"); +}