Files
pokerfreak/tests/bluff_range.rs
T
mmintelandClaude Opus 5.5 bc1a622838 Live-Lecks 14.11. als Schalter, Fixture, Spec und Micro-Leiterzeile
Zwei Muster trugen 23 von 996 Micro-Haenden (-579,5 BB):
- MDF_UNREAD=0: MDF-Boden am River verteidigt nur noch gegen gemessene Ueber-Bluffer.
- RAISE_DRAWS=stark: Range einer Erhoehung haelt nur starke Draws statt jeden Gutshot.
- RAISE_PRIOR=0: Erhoehung ohne Populations-Bluff-Prior (gemessen: Verlierer, bleibt aus).
Vorgabe bleibt bei allen Schaltern das alte Verhalten (Replay trifft alle Live-Entscheidungen).

Fixture tests/live_fixture/micro_2026-11-14.jsonl (23 Faelle), Spec tests/live_lecks_spec.py,
Flop-Nachbau lesen/rueckbau.py, Leiterzeile micro-passiv mit @blind/@oracle in ab_zelle.
cargo test --lib, bluff_range, called_range_share gruen.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 17:31:37 +01:00

94 lines
3.2 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,
}],
}
}
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);
}