Files
pokerfreak/tests/bluff_range.rs
T
mmintel 9c79d8236b Acceptance 5.11.: channel play without AFK, quiet focus, working Cockpit, stronger play
- Practice tables: 20-min session 54/54 turns at the server, control session 28 turns,
  0 timeouts; stage: 3 tables, two rounds each, clean teardown.
- Never let the clock run: an engine abstention becomes check or fold (nie_verstreichen).
- Mittler join in a fixed order (kill the duplicate, then announce), a mittler ends with its
  game, the laufwache opens no tables, stop waits for the runner to stand up.
- Focus: no lobby connections from HUD, probes or layout; "Focus Window on Turn" off.
- Tables: disconnected or sitting-out opponents do not count; a table without channel is
  closed and avoided after 45 s; the join event keeps the writer's pid (strict invariants).
- Geldwache: same room list as the runner, the table's own report, stand up before closing.
- Engine: the small blind completes the top 65 % against limpers (price per fair share);
  the calling range of a bet is as wide as the villain calls - value bets into stations.
- Cockpit: the source tree never comes from SHELL; one operating set for laufwache and
  Cockpit (sicht/start.py --client, ServerStart).
- Project lives in ~/Projects/pokerfreak (kern was a detour).
2026-11-05 16:10:43 +01:00

93 lines
3.1 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,
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);
}