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