Files
pokerfreak/tests/engine_thin_value.rs
T
mmintel 04c8e6d3e0 Tournaments: tables left alone by cash rules, break modelled; thin value on turn and river
- A tournament table (tournament type or tournament lobby) is never sat out, left or closed by
  the cash runner: session end, schedule pause, empty table, no channel, over the table count
  (tests/turniertisch_spec.py).
- Clone tournament gets a break (isTourneyOnBreak, no hands, level clock stops); the runner sits
  through it and plays on (tests/turnier_kette_spec.py).
- Medium hands may bet thin on the turn and the river when checked to and the favourite at the
  table; EV decides, held back inside the EV error, small sizes (tests/engine_thin_value.rs).
- archiv/mitschrieb/TURNIERE.md: what works in the clone, what is missing at the real client.
2026-11-05 17:11:50 +01:00

126 lines
10 KiB
Rust

//! Spec: thin value on the turn and the river.
//!
//! A medium hand (middle pair, top pair with a weak kicker) stayed below the value bar on the
//! turn and the river and checked - also into calling stations, where betting is the money.
//! Now it may bet for thin value when the action is checked to it on the turn or the river and it
//! is the favourite at the table (realised share at least one half), on a board where a medium hand
//! may value-bet at all (not wet, no four-flush). The bet is only taken when its own EV beats
//! checking - the called branch is played against a calling range as wide as the villains call
//! (`exploit::call_floor`), so it pays against stations and not against tight callers - and,
//! unlike a value raise, a thin bet inside its EV error is held back (no bet).
//!
//! Not on the flop (more cards to come than the one-street EV sees), never as a raise of a bet.
//! The recorded requests are from the practice tables of 5.11.2026.
mod spot_fixture;
mod support;
use rechner::engine::effective::Effective;
use rechner::engine::postflop::choose_postflop;
use rechner::engine::thin_value::{thin_value, THIN_VALUE_SHARE};
use rechner::exploit::thresholds::Thresholds;
use rechner::game::{ActionKind, Choice, Spot, Street};
use rechner::read::draw::Draw;
use rechner::read::made::Made;
use rechner::read::suit_pattern::SuitPattern;
use rechner::wire::respond::respond;
use spot_fixture::{cards, estimate, flop, read_of};
use support::{action, size};
/// Round numbers on the turn, checked to hero: pot 10, deep stacks, one villain.
fn turn_checked_to_hero() -> Spot {
Spot {
board: cards("Ac 7d 2s 9h"),
street: Street::Turn,
pot: 10.0,
to_call: 0.0,
hero_stack: 100.0,
min_raise_to: Some(1.0),
max_raise_to: Some(100.0),
legal: vec![ActionKind::Check, ActionKind::Raise],
..flop()
}
}
#[test]
fn a_thin_bet_bets_when_sure_and_is_held_back_inside_its_ev_error() {
// Middle pair on a dry turn, share 0.6: under the value bar (0.652), over the favourite share.
let medium = read_of(Made::MiddlePair, Draw::None, 0, SuitPattern::Rainbow, 0.1);
let sure = choose_postflop(&turn_checked_to_hero(), &estimate(0.6, 0.001), &Thresholds::BASE, &medium);
assert!(matches!(sure.choice, Choice::Raise { .. }), "{sure:?}");
let shaky = choose_postflop(&turn_checked_to_hero(), &estimate(0.6, 0.2), &Thresholds::BASE, &medium);
assert_eq!(shaky.choice, Choice::Abstain, "{shaky:?}");
}
fn eff(share: f64) -> Effective {
Effective {
villains: 2,
share,
call_margin: 0.02,
value_raise: 0.7,
value_ok: true,
raise_ok: true,
semibluff_ok: true,
}
}
#[test]
fn a_medium_hand_ahead_of_the_table_may_bet_thin_on_turn_and_river() {
for street in [Street::Turn, Street::River] {
assert!(thin_value(&eff(0.6), Made::TopPairWeakKicker, street, true), "{street:?}");
assert!(thin_value(&eff(0.6), Made::MiddlePair, street, true), "{street:?}");
}
}
#[test]
fn the_favourite_share_is_the_border() {
assert_eq!(THIN_VALUE_SHARE, 0.5);
assert!(thin_value(&eff(THIN_VALUE_SHARE), Made::MiddlePair, Street::River, true));
assert!(!thin_value(&eff(THIN_VALUE_SHARE - 0.01), Made::MiddlePair, Street::River, true));
}
#[test]
fn never_on_the_flop_and_never_raising_a_bet() {
assert!(!thin_value(&eff(0.6), Made::TopPairWeakKicker, Street::Flop, true));
assert!(!thin_value(&eff(0.6), Made::TopPairWeakKicker, Street::Preflop, true));
assert!(!thin_value(&eff(0.6), Made::TopPairWeakKicker, Street::Turn, false));
}
#[test]
fn only_medium_hands_and_only_where_value_is_allowed() {
assert!(!thin_value(&eff(0.6), Made::BottomPair, Street::River, true));
assert!(!thin_value(&eff(0.6), Made::TopPairGoodKicker, Street::River, true));
let wet = Effective { value_ok: false, ..eff(0.6) };
assert!(!thin_value(&wet, Made::MiddlePair, Street::River, true));
let board_only = Effective { raise_ok: false, ..eff(0.6) };
assert!(!thin_value(&board_only, Made::MiddlePair, Street::River, true));
}
/// K9 on K-8-3-T, checked to hero, two calling stations (one never folds).
const K9_TURN: &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"}],"TURN":[{"rank":"TEN","suit":"CLUBS"}]},"street":"TURN","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},{"street":"FLOP","seat":1,"action":"CHECK"},{"street":"FLOP","seat":2,"action":"CHECK"},{"street":"FLOP","seat":3,"action":"CHECK"}]}"#;
/// Q6 on 9-Q-T, a flop: thin value waits for the turn.
const Q6_FLOP: &str = r#"{"variant":"NLHE","bigBlind":500.0,"seats":3,"heroSeat":1,"heroCards":[{"rank":"SIX","suit":"DIAMONDS"},{"rank":"QUEEN","suit":"CLUBS"}],"board":{"FLOP":[{"rank":"NINE","suit":"HEARTS"},{"rank":"QUEEN","suit":"DIAMONDS"},{"rank":"TEN","suit":"DIAMONDS"}]},"street":"FLOP","pot":1740.0,"toCall":0.0,"heroStack":46304.5,"minRaiseTo":500.0,"maxRaiseTo":46304.5,"legalActions":["FOLD","CHECK","RAISE"],"villains":[{"seat":2,"stack":19420.0,"folded":false,"profile":{"vpip":0.0,"pfr":0.0,"foldToBet":0.0,"hands":4}},{"seat":3,"stack":170113.59,"folded":false,"profile":{"vpip":0.78,"pfr":0.02,"foldToBet":0.36,"hands":33}}],"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":"CALL","amount":500.0},{"street":"PREFLOP","seat":2,"action":"CHECK"}]}"#;
/// T9 on 5-T-Q-A facing a turn bet: no thin raise, the call stays.
const T9_TURN_FACING: &str = r#"{"variant":"NLHE","bigBlind":500.0,"seats":2,"heroSeat":1,"heroCards":[{"rank":"NINE","suit":"SPADES"},{"rank":"TEN","suit":"HEARTS"}],"board":{"FLOP":[{"rank":"FIVE","suit":"HEARTS"},{"rank":"TEN","suit":"SPADES"},{"rank":"QUEEN","suit":"DIAMONDS"}],"TURN":[{"rank":"ACE","suit":"DIAMONDS"}]},"street":"TURN","pot":3160.0,"toCall":1000.0,"heroStack":49312.0,"minRaiseTo":2000.0,"maxRaiseTo":49312.0,"legalActions":["FOLD","CALL","RAISE"],"villains":[{"seat":2,"stack":17362.0,"folded":false,"profile":{"vpip":0.0,"pfr":0.0,"foldToBet":0.0,"hands":6}}],"history":[{"street":"PREFLOP","seat":1,"action":"POST_ANTE","amount":80.0},{"street":"PREFLOP","seat":2,"action":"POST_ANTE","amount":80.0},{"street":"PREFLOP","seat":2,"action":"POST_SB","amount":250.0},{"street":"PREFLOP","seat":1,"action":"POST_BB","amount":500.0},{"street":"PREFLOP","seat":2,"action":"CALL","amount":500.0},{"street":"PREFLOP","seat":1,"action":"CHECK"},{"street":"FLOP","seat":1,"action":"BET","amount":500.0},{"street":"FLOP","seat":2,"action":"CALL","amount":500.0},{"street":"TURN","seat":1,"action":"CHECK"},{"street":"TURN","seat":2,"action":"BET","amount":1000.0}]}"#;
/// AJ on a four-flush river: a medium hand does not value-bet there.
const AJ_RIVER_FOURFLUSH: &str = r#"{"variant":"NLHE","bigBlind":500.0,"seats":4,"heroSeat":1,"heroCards":[{"rank":"ACE","suit":"CLUBS"},{"rank":"JACK","suit":"SPADES"}],"board":{"FLOP":[{"rank":"FIVE","suit":"SPADES"},{"rank":"KING","suit":"DIAMONDS"},{"rank":"SIX","suit":"DIAMONDS"}],"TURN":[{"rank":"JACK","suit":"DIAMONDS"}],"RIVER":[{"rank":"SEVEN","suit":"DIAMONDS"}]},"street":"RIVER","pot":4570.0,"toCall":0.0,"heroStack":47510.0,"minRaiseTo":500.0,"maxRaiseTo":47510.0,"legalActions":["FOLD","CHECK","RAISE"],"villains":[{"seat":2,"stack":299660.59,"folded":false,"profile":{"vpip":0.72,"pfr":0.03,"foldToBet":0.3,"hands":17}},{"seat":3,"stack":336134.19,"folded":true,"profile":{"vpip":0.81,"pfr":0.25,"foldToBet":0.0,"hands":15}},{"seat":4,"stack":54339.0,"folded":false,"profile":{"vpip":0.78,"pfr":0.0,"foldToBet":0.0,"hands":12}}],"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":4,"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":4,"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":"FOLD"},{"street":"PREFLOP","seat":4,"action":"CALL","amount":1250.0},{"street":"FLOP","seat":1,"action":"CHECK"},{"street":"FLOP","seat":2,"action":"CHECK"},{"street":"FLOP","seat":4,"action":"CHECK"},{"street":"TURN","seat":1,"action":"CHECK"},{"street":"TURN","seat":2,"action":"CHECK"},{"street":"TURN","seat":4,"action":"CHECK"}]}"#;
#[test]
fn top_pair_bets_the_turn_into_calling_stations_and_bets_small() {
let out = respond(K9_TURN);
assert_eq!(action(&out), "RAISE", "{out}");
let pot = 3990.0;
let bet = size(&out).expect("a size");
assert!(bet <= 0.5 * pot, "a thin bet is small: {bet} into {pot}");
}
#[test]
fn the_recorded_spots_outside_thin_value_stay_as_they_were() {
for (name, request, expected) in
[("Q6 flop", Q6_FLOP, "CHECK"), ("T9 facing a bet", T9_TURN_FACING, "CALL"), ("AJ four-flush", AJ_RIVER_FOURFLUSH, "CHECK")]
{
let out = respond(request);
assert_eq!(action(&out), expected, "{name}: {out}");
}
}