Konflikte: BEKANNTE_SCHALTER vereinigt; range_filter Kept mit Accept + Klassen-Kipp; RAISE_FOLD_DECKEL in sized_fold_on. Specs gruen (169 Test-Binaries). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
144 lines
7.7 KiB
Rust
144 lines
7.7 KiB
Rust
//! Spec: the hands that call hero's bet are as many as the villain calls.
|
|
//!
|
|
//! A bet is valued over two branches: everybody folds (each villain's fold chance from their
|
|
//! profile, `exploit::fold_chance`), or hero is called - and then hero's share is measured
|
|
//! against the calling range. That range used to be only the hands above a calling floor
|
|
//! (bottom pair or a draw), however often the villain calls: a calling station that calls 80 %
|
|
//! was played as if it called with its best 40 %. Hero's share in the called branch came out far
|
|
//! too low, a bet with top pair looked worse than a check, and the bot hardly ever bet for value
|
|
//! (5.11.2026: 1 bet in 42 postflop decisions at the practice tables).
|
|
//!
|
|
//! Now a call continuation carries the villain's call frequency (`continue_share` = 1 - fold
|
|
//! chance to that bet): the floor hands stay, and hands below the floor are admitted until the
|
|
//! range is that wide. Without a share everything stays as it was (`bluff_share`).
|
|
|
|
mod spot_fixture;
|
|
mod support;
|
|
|
|
use rechner::card::{deck, Card};
|
|
use rechner::engine::range_filter::range_filter;
|
|
use rechner::exploit::call_floor::call_continuation;
|
|
use rechner::exploit::fold_chance::fold_chance;
|
|
use rechner::exploit::profile::Profile;
|
|
use rechner::exploit::range_spec::{Continuation, RangeSpec};
|
|
use rechner::game::{Street, Villain};
|
|
use rechner::read::glance::glance;
|
|
use rechner::read::made::Made;
|
|
use rechner::variant::{rules, Variant};
|
|
use rechner::wire::respond::respond;
|
|
use spot_fixture::cards;
|
|
use support::action;
|
|
|
|
const BOARD: &str = "Kd 8h 3c";
|
|
const THIN: f64 = 1.0 / 3.0;
|
|
|
|
fn floor_spec(min_made: Made, continue_share: Option<f64>) -> RangeSpec {
|
|
RangeSpec { class_target: None,
|
|
lo: 0.0,
|
|
hi: 1.0,
|
|
continues: vec![Continuation {
|
|
board_len: 3,
|
|
min_made,
|
|
draws_continue: false,
|
|
min_draw: rechner::read::draw::Draw::Gutshot,
|
|
bluff_share: 0.0,
|
|
continue_share,
|
|
top_share: None,
|
|
min_strength: None,
|
|
likelihood: 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()
|
|
}
|
|
|
|
/// (share of all hands that pass, every floor hand passes)
|
|
fn census(spec: &RangeSpec) -> (f64, bool) {
|
|
let board = cards(BOARD);
|
|
let r = rules(Variant::Nlhe);
|
|
let filter = range_filter(spec, r, Variant::Nlhe, &board);
|
|
let floor = spec.continues[0].min_made;
|
|
let hands = all_hands(&board);
|
|
let passing = hands.iter().filter(|h| filter(&h[..])).count();
|
|
let floor_kept = hands
|
|
.iter()
|
|
.filter(|h| glance(&r, &h[..], &board).is_ok_and(|(m, _)| m >= floor))
|
|
.all(|h| filter(&h[..]));
|
|
(passing as f64 / hands.len() as f64, floor_kept)
|
|
}
|
|
|
|
#[test]
|
|
fn the_calling_range_is_filled_up_to_the_call_frequency() {
|
|
for share in [0.3, 0.6, 0.8] {
|
|
let (passing, floor_kept) = census(&floor_spec(Made::TopPairGoodKicker, Some(share)));
|
|
assert!((passing - share).abs() < 0.01, "share {share}: {passing:.3} pass");
|
|
assert!(floor_kept, "share {share}: a floor hand was dropped");
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn a_floor_wider_than_the_share_stays_as_it_is() {
|
|
let (alone, _) = census(&floor_spec(Made::BottomPair, None));
|
|
let (narrow, floor_kept) = census(&floor_spec(Made::BottomPair, Some(0.05)));
|
|
assert!(alone > 0.05, "the floor alone passes {alone:.3}");
|
|
assert_eq!(narrow, alone);
|
|
assert!(floor_kept);
|
|
}
|
|
|
|
#[test]
|
|
fn without_a_share_only_the_floor_passes() {
|
|
let (alone, floor_kept) = census(&floor_spec(Made::TopPairGoodKicker, None));
|
|
assert!(alone > 0.0 && alone < 0.2, "the floor alone passes {alone:.3}");
|
|
assert!(floor_kept);
|
|
}
|
|
|
|
fn station(fold_to_bet: f64) -> Villain {
|
|
Villain {
|
|
seat: 2,
|
|
stack: 100.0,
|
|
folded: false,
|
|
profile: Some(Profile { vpip: Some(0.75), pfr: Some(0.03), fold_to_bet: Some(fold_to_bet), aggression: None, ..Profile::default() }),
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn a_call_continuation_is_as_wide_as_the_villain_calls() {
|
|
let v = station(0.36);
|
|
for facing_raise in [false, true] {
|
|
let c = call_continuation(&v, Street::Flop, THIN, facing_raise);
|
|
let calls = 1.0 - fold_chance(v.profile.as_ref(), THIN, facing_raise);
|
|
assert_eq!(c.continue_share, Some(calls), "facing a raise: {facing_raise}");
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn a_raised_villain_calls_wider_than_a_bet_one() {
|
|
let v = station(0.36);
|
|
let bet = call_continuation(&v, Street::Flop, THIN, false).continue_share.expect("share");
|
|
let raised = call_continuation(&v, Street::Flop, THIN, true).continue_share.expect("share");
|
|
assert!(raised > bet, "raised {raised} vs bet {bet}");
|
|
}
|
|
|
|
/// Recorded engine requests of 5.11.2026 (practice table, bb 500), hero iso-raised from the
|
|
/// small blind and both callers checked to hero on the flop. Seat 3 never folds (foldToBet 0).
|
|
const KING_NINE_TOP_PAIR: &str = r#"{"variant":"NLHE","bigBlind":500.0,"seats":3,"heroSeat":1,"heroCards":[{"rank":"NINE","suit":"HEARTS"},{"rank":"KING","suit":"CLUBS"}],"board":{"FLOP":[{"rank":"EIGHT","suit":"HEARTS"},{"rank":"KING","suit":"DIAMONDS"},{"rank":"THREE","suit":"CLUBS"}]},"street":"FLOP","pot":3990.0,"toCall":0.0,"heroStack":42030.0,"minRaiseTo":500.0,"maxRaiseTo":42030.0,"legalActions":["FOLD","CHECK","RAISE"],"villains":[{"seat":2,"stack":168945.59,"folded":false,"profile":{"vpip":0.77,"pfr":0.03,"foldToBet":0.36,"hands":31}},{"seat":3,"stack":624102.69,"folded":false,"profile":{"vpip":0.73,"pfr":0.05,"foldToBet":0.0,"hands":26}}],"history":[{"street":"PREFLOP","seat":1,"action":"POST_ANTE","amount":80.0},{"street":"PREFLOP","seat":2,"action":"POST_ANTE","amount":80.0},{"street":"PREFLOP","seat":3,"action":"POST_ANTE","amount":80.0},{"street":"PREFLOP","seat":1,"action":"POST_SB","amount":250.0},{"street":"PREFLOP","seat":2,"action":"POST_BB","amount":500.0},{"street":"PREFLOP","seat":3,"action":"CALL","amount":500.0},{"street":"PREFLOP","seat":1,"action":"RAISE","amount":1250.0},{"street":"PREFLOP","seat":2,"action":"CALL","amount":1250.0},{"street":"PREFLOP","seat":3,"action":"CALL","amount":1250.0}]}"#;
|
|
const ACE_QUEEN_HIGH: &str = r#"{"variant":"NLHE","bigBlind":500.0,"seats":3,"heroSeat":1,"heroCards":[{"rank":"QUEEN","suit":"CLUBS"},{"rank":"ACE","suit":"CLUBS"}],"board":{"FLOP":[{"rank":"SEVEN","suit":"DIAMONDS"},{"rank":"FOUR","suit":"CLUBS"},{"rank":"THREE","suit":"HEARTS"}]},"street":"FLOP","pot":3990.0,"toCall":0.0,"heroStack":43940.0,"minRaiseTo":500.0,"maxRaiseTo":43940.0,"legalActions":["FOLD","CHECK","RAISE"],"villains":[{"seat":2,"stack":169202.59,"folded":false,"profile":{"vpip":0.77,"pfr":0.03,"foldToBet":0.36,"hands":29}},{"seat":3,"stack":622222.19,"folded":false,"profile":{"vpip":0.73,"pfr":0.05,"foldToBet":0.0,"hands":24}}],"history":[{"street":"PREFLOP","seat":1,"action":"POST_ANTE","amount":80.0},{"street":"PREFLOP","seat":2,"action":"POST_ANTE","amount":80.0},{"street":"PREFLOP","seat":3,"action":"POST_ANTE","amount":80.0},{"street":"PREFLOP","seat":2,"action":"POST_SB","amount":250.0},{"street":"PREFLOP","seat":3,"action":"POST_BB","amount":500.0},{"street":"PREFLOP","seat":1,"action":"RAISE","amount":1250.0},{"street":"PREFLOP","seat":2,"action":"CALL","amount":1250.0},{"street":"PREFLOP","seat":3,"action":"CALL","amount":1250.0},{"street":"FLOP","seat":2,"action":"CHECK"},{"street":"FLOP","seat":3,"action":"CHECK"}]}"#;
|
|
|
|
#[test]
|
|
fn top_pair_bets_for_value_into_calling_stations() {
|
|
let out = respond(KING_NINE_TOP_PAIR);
|
|
assert_eq!(action(&out), "RAISE", "{out}");
|
|
}
|
|
|
|
#[test]
|
|
fn ace_high_does_not_bet_into_a_station_that_never_folds() {
|
|
let out = respond(ACE_QUEEN_HIGH);
|
|
assert_eq!(action(&out), "CHECK", "{out}");
|
|
}
|