Files
pokerfreak/tests/bluff_range.rs
T
mmintelandClaude Opus 5.5 6b3b3d501e Flussleck: zwei River-Fehler aus dem Live-Lauf 16.11. abends im Kern behoben (Schalter, aus = bitgleich)
RUF_ALLIN=1: called_equity simuliert die All-in-Groesse mit, die REST_STACK hinzufuegt
(vorher fiel der Call-Anteil des Jams auf den Anteil gegen die ganze Range zurueck, 0,678).
RUF_OBEN=river: am River zahlt die staerkste (1-Fold)-Spitze statt Boden plus Zufall.
WERT_BRETT=river: River-Boden der Wett-Range als Staerke-Perzentil auf dem echten Brett
(exploit/brett_floor.rs) statt Handklasse; Vierflush-Brett: Strasse 0,35 -> 0,16 Equity.

Pflichtfaelle: Live 10/16, Kandidat 12/16, 178854100443 CHECK und 178870300411 FOLD behoben,
kein alter Fall verloren. BEKANNTE_SCHALTER ergaenzt. Volles Tor fl-* laeuft gg. ps2-*-an.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 17:50:46 +01:00

96 lines
3.3 KiB
Rust

//! Spec: a betting range keeps a bluff fraction.
//!
//! A continuation with `bluff_share = b` lets hands below its floor through with a fixed,
//! per-hand acceptance so that, over all starting hands in the preflop band, the hands
//! below the floor make up `b` of what passes. Without it a bet is read as pure value
//! and hero folds every bluff catcher (systematic under-calling).
mod spot_fixture;
use rechner::card::{deck, Card};
use rechner::engine::range_filter::range_filter;
use rechner::exploit::range_spec::{Continuation, RangeSpec};
use rechner::read::glance::glance;
use rechner::read::made::Made;
use rechner::variant::{rules, Variant};
use spot_fixture::cards;
fn spec(bluff_share: f64) -> RangeSpec {
RangeSpec {
lo: 0.0,
hi: 0.6,
continues: vec![Continuation {
board_len: 5,
min_made: Made::TopPairGoodKicker,
draws_continue: false,
min_draw: rechner::read::draw::Draw::Gutshot,
bluff_share,
continue_share: None,
top_share: None,
min_strength: None,
}],
}
}
fn all_hands(board: &[Card]) -> Vec<[Card; 2]> {
let pool = deck::without(board);
(0..pool.len())
.flat_map(|i| (i + 1..pool.len()).map(move |j| (i, j)))
.map(|(i, j)| [pool[i], pool[j]])
.collect()
}
/// (passing hands, of which below the floor)
fn census(b: f64) -> (usize, usize) {
let board = cards("Kd 8s 4c 2h Jc");
let filter = range_filter(&spec(b), rules(Variant::Nlhe), Variant::Nlhe, &board);
let r = rules(Variant::Nlhe);
all_hands(&board).iter().filter(|h| filter(&h[..])).fold((0, 0), |(n, air), h| {
let below = glance(&r, &h[..], &board).map_or(true, |(m, _)| m < Made::TopPairGoodKicker);
(n + 1, air + usize::from(below))
})
}
#[test]
fn without_a_bluff_share_only_value_passes() {
let (n, air) = census(0.0);
assert!(n > 0);
assert_eq!(air, 0);
}
#[test]
fn the_bluff_share_is_met_over_the_whole_range() {
for b in [0.1, 0.25, 0.4] {
let (n, air) = census(b);
let share = air as f64 / n as f64;
assert!((share - b).abs() < 0.03, "b = {b}: {air}/{n} = {share:.3}");
}
}
#[test]
fn acceptance_is_fixed_per_hand_and_order_free() {
let board = cards("Kd 8s 4c 2h Jc");
let f = range_filter(&spec(0.3), rules(Variant::Nlhe), Variant::Nlhe, &board);
let g = range_filter(&spec(0.3), rules(Variant::Nlhe), Variant::Nlhe, &board);
for h in all_hands(&board).iter().take(400) {
let swapped = [h[1], h[0]];
assert_eq!(f(&h[..]), g(&h[..]));
assert_eq!(f(&h[..]), f(&swapped[..]));
}
}
#[test]
fn five_card_ranges_get_bluffs_too() {
let board = cards("Kd 8s 4c 2h Jc");
let f = range_filter(&spec(0.3), rules(Variant::Plo5), Variant::Plo5, &board);
// A hand with no pair at all on this board still passes sometimes.
let pool = deck::without(&board);
let passing_air = (0..300)
.map(|i| [0, 7, 13, 21, 29].map(|k| pool[(i * 3 + k) % pool.len()]))
.filter(|h| h.iter().enumerate().all(|(i, c)| !h[..i].contains(c)))
.filter(|h| glance(&rules(Variant::Plo5), &h[..], &board).is_ok_and(|(m, _)| m < Made::TopPairGoodKicker))
.filter(|h| f(&h[..]))
.count();
assert!(passing_air > 0);
}