Die Welt nannte 'pokerfreak' nur noch in zwei Harness-Zeilen - der Rest waren veraltete Rust-Pruefungen im Pruefordner, die der Aufbau nie auffrischte.
80 lines
2.8 KiB
Rust
80 lines
2.8 KiB
Rust
//! Spec: P(fold) of one opponent from their profile and the bet size.
|
|
//!
|
|
//! Mapping: `p = 1 - (1 - f)^(ratio / 0.66)`, `f` = foldToBet (or the style default),
|
|
//! times 0.7 when the opponent already bet (they are being raised), capped at 0.95.
|
|
//! foldToBet is measured against a typical two-thirds-pot bet, so at that size p = f.
|
|
|
|
use rechner::exploit::fold_chance::{
|
|
fold_base, fold_chance, DEFAULT_FOLD_TO_BET, MAX_FOLD, RAISE_RESISTANCE, REFERENCE_RATIO,
|
|
};
|
|
use rechner::exploit::profile::Profile;
|
|
use rechner::exploit::table_fold::pressure_ratio;
|
|
|
|
fn folds(f: f64) -> Profile {
|
|
Profile { fold_to_bet: Some(f), ..Profile::default() }
|
|
}
|
|
|
|
fn close(a: f64, b: f64) -> bool {
|
|
(a - b).abs() < 1e-9
|
|
}
|
|
|
|
#[test]
|
|
fn at_the_reference_size_the_chance_is_fold_to_bet() {
|
|
for f in [0.1, 0.3, 0.5, 0.8] {
|
|
assert!(close(fold_chance(Some(&folds(f)), REFERENCE_RATIO, false), f), "{f}");
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn bigger_bets_and_bigger_folders_fold_more() {
|
|
let p = folds(0.5);
|
|
let sizes = [0.1, 0.33, 0.5, 0.66, 1.0, 1.5, 3.0];
|
|
for w in sizes.windows(2) {
|
|
assert!(fold_chance(Some(&p), w[0], false) < fold_chance(Some(&p), w[1], false));
|
|
}
|
|
for w in [0.1, 0.3, 0.5, 0.7, 0.9].windows(2) {
|
|
assert!(fold_chance(Some(&folds(w[0])), 1.0, false) < fold_chance(Some(&folds(w[1])), 1.0, false));
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn no_bet_no_fold_and_never_certain() {
|
|
assert_eq!(fold_chance(Some(&folds(0.9)), 0.0, false), 0.0);
|
|
assert!(fold_chance(Some(&folds(1.0)), 10.0, false) <= MAX_FOLD);
|
|
assert!(fold_chance(Some(&folds(0.0)), 10.0, false) == 0.0, "a player who never folds never folds");
|
|
}
|
|
|
|
#[test]
|
|
fn being_raised_after_betting_folds_less() {
|
|
let p = folds(0.6);
|
|
assert!(close(fold_chance(Some(&p), 1.0, true), RAISE_RESISTANCE * fold_chance(Some(&p), 1.0, false)));
|
|
}
|
|
|
|
#[test]
|
|
fn without_fold_to_bet_the_style_decides() {
|
|
let nit = Profile { vpip: Some(0.10), pfr: Some(0.08), ..Profile::default() };
|
|
let station = Profile { vpip: Some(0.55), pfr: Some(0.05), ..Profile::default() };
|
|
assert_eq!(fold_base(None), DEFAULT_FOLD_TO_BET);
|
|
assert!(fold_base(Some(&nit)) > DEFAULT_FOLD_TO_BET);
|
|
assert!(fold_base(Some(&station)) < DEFAULT_FOLD_TO_BET);
|
|
assert_eq!(fold_base(Some(&folds(0.33))), 0.33);
|
|
}
|
|
|
|
#[test]
|
|
fn garbage_inputs_stay_inside_zero_and_the_cap() {
|
|
for f in [f64::NAN, -1.0, 2.0] {
|
|
for r in [f64::NAN, -1.0, 0.5, f64::INFINITY] {
|
|
let p = fold_chance(Some(&folds(f)), r, false);
|
|
assert!((0.0..=MAX_FOLD).contains(&p), "{f} {r} -> {p}");
|
|
}
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn pressure_is_the_extra_over_a_call_against_the_pot_after_calling() {
|
|
assert!(close(pressure_ratio(10.0, 0.0, 5.0), 0.5));
|
|
// Raise to 20 over a bet of 5 into 10: 15 extra against a pot of 15.
|
|
assert!(close(pressure_ratio(10.0, 5.0, 20.0), 1.0));
|
|
assert_eq!(pressure_ratio(0.0, 0.0, 0.0), 0.0);
|
|
}
|