Files
mmintel 2579773005 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.
2026-11-07 00:44:20 +01:00

114 lines
5.1 KiB
Rust

//! 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");
}