Files
pokerfreak/tests/exploit_adjust.rs
T
mmintel 04d5251acf Welt ohne fremden Namen: Pruefordner vollstaendig mitkopieren, Engine nur im eigenen Baum
Die Welt nannte 'pokerfreak' nur noch in zwei Harness-Zeilen - der Rest waren veraltete
Rust-Pruefungen im Pruefordner, die der Aufbau nie auffrischte.
2026-11-01 23:37:11 +01:00

131 lines
3.8 KiB
Rust

use rechner::exploit::adjust::adjust;
use rechner::exploit::profile::Profile;
use rechner::exploit::thresholds::Thresholds;
const BASE: Thresholds = Thresholds::BASE;
fn profile(vpip: Option<f64>, pfr: Option<f64>, fold_to_bet: Option<f64>) -> Profile {
Profile {
vpip,
pfr,
fold_to_bet,
aggression: None,
}
}
fn station() -> Profile {
profile(Some(0.50), Some(0.05), Some(0.20))
}
fn nit() -> Profile {
profile(Some(0.10), Some(0.07), Some(0.75))
}
fn maniac() -> Profile {
profile(Some(0.60), Some(0.40), Some(0.40))
}
#[test]
fn no_information_changes_nothing() {
assert_eq!(adjust(BASE, &[]), BASE);
assert_eq!(adjust(BASE, &[Profile::default()]), BASE);
assert_eq!(
adjust(BASE, &[Profile::default(), Profile::default()]),
BASE
);
}
#[test]
fn calling_stations_are_value_bet_thinner_and_not_bluffed() {
let t = adjust(BASE, &[station()]);
// Fold equity is per opponent now (`exploit::fold_chance`), not a shared threshold.
assert_eq!(t.fold_equity_scale, BASE.fold_equity_scale, "{t:?}");
assert!(t.value_raise < BASE.value_raise);
}
#[test]
fn nits_fold_more_and_bet_strong() {
let t = adjust(BASE, &[nit()]);
assert_eq!(t.fold_equity_scale, BASE.fold_equity_scale);
assert!(t.call_margin > BASE.call_margin);
assert!(t.range_width_scale < BASE.range_width_scale);
}
#[test]
fn aggressive_players_are_called_wider() {
let t = adjust(BASE, &[maniac()]);
assert!(t.call_margin < BASE.call_margin);
assert!(t.range_width_scale > BASE.range_width_scale);
}
#[test]
fn fold_to_bet_no_longer_moves_the_shared_scale() {
// foldToBet enters per opponent through `fold_chance`; counting it here too would
// count it twice.
for i in 0..=20 {
let t = adjust(BASE, &[profile(Some(0.3), Some(0.1), Some(i as f64 / 20.0))]);
assert_eq!(t.fold_equity_scale, BASE.fold_equity_scale);
}
}
#[test]
fn several_profiles_combine_conservatively() {
let (s, n) = (adjust(BASE, &[station()]), adjust(BASE, &[nit()]));
let both = adjust(BASE, &[station(), nit()]);
assert_eq!(both.call_margin, s.call_margin.max(n.call_margin));
assert_eq!(
both.fold_equity_scale,
s.fold_equity_scale.min(n.fold_equity_scale)
);
assert_eq!(both.value_raise, s.value_raise.max(n.value_raise));
assert_eq!(
both.range_width_scale,
s.range_width_scale.min(n.range_width_scale)
);
// order does not matter, unknowns are ignored
assert_eq!(adjust(BASE, &[nit(), Profile::default(), station()]), both);
}
#[test]
fn outputs_stay_in_sane_ranges_for_any_input() {
let grid = [
None,
Some(-1.0),
Some(0.0),
Some(0.3),
Some(1.0),
Some(9.0),
Some(f64::NAN),
Some(f64::INFINITY),
];
for vpip in grid {
for pfr in grid {
for ftb in grid {
let t = adjust(BASE, &[profile(vpip, pfr, ftb)]);
assert!((0.0..=0.15).contains(&t.call_margin), "{t:?}");
assert!((0.52..=0.85).contains(&t.value_raise), "{t:?}");
assert!((0.0..=0.05).contains(&t.abstain_band), "{t:?}");
assert!((0.3..=1.6).contains(&t.fold_equity_scale), "{t:?}");
assert!((0.6..=1.4).contains(&t.range_width_scale), "{t:?}");
}
}
}
}
#[test]
fn adjust_is_pure() {
let ps = [station(), maniac()];
assert_eq!(adjust(BASE, &ps), adjust(BASE, &ps));
}
#[test]
fn adjustments_compose_with_a_non_default_base() {
let tight = Thresholds {
fold_equity_scale: 0.8,
..BASE
};
// The shared fold-equity scale passes through untouched (profiles act per opponent).
assert_eq!(adjust(tight, &[nit()]).fold_equity_scale, 0.8);
assert_eq!(adjust(tight, &[station()]).fold_equity_scale, 0.8);
}