Hand percentiles (169-class equity ranking, Omaha-5 structural score with empirical CDF), position/situation inference, position x situation charts, all-in-or-fold charts, pot-odds all-in calls, advise(); exploit style classification, threshold adjustment and villain range guess. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
142 lines
3.9 KiB
Rust
142 lines
3.9 KiB
Rust
use pokerfreak::exploit::adjust::adjust;
|
|
use pokerfreak::exploit::profile::Profile;
|
|
use pokerfreak::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,
|
|
}
|
|
}
|
|
|
|
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()]);
|
|
assert!(t.fold_equity_scale < 0.7 * 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!(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 more_fold_to_bet_never_lowers_fold_equity_scale() {
|
|
for (vpip, pfr) in [(0.30, 0.10), (0.15, 0.10), (0.55, 0.40), (0.50, 0.05)] {
|
|
let scales: Vec<f64> = (0..=20)
|
|
.map(|i| {
|
|
adjust(
|
|
BASE,
|
|
&[profile(Some(vpip), Some(pfr), Some(i as f64 / 20.0))],
|
|
)
|
|
.fold_equity_scale
|
|
})
|
|
.collect();
|
|
assert!(
|
|
scales.windows(2).all(|w| w[0] <= w[1]),
|
|
"vpip {vpip}: {scales:?}"
|
|
);
|
|
assert!(scales[20] > scales[0]);
|
|
}
|
|
}
|
|
|
|
#[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
|
|
};
|
|
let t = adjust(tight, &[nit()]);
|
|
assert!(t.fold_equity_scale > 0.8);
|
|
assert!(
|
|
adjust(tight, &[station()]).fold_equity_scale
|
|
< adjust(BASE, &[station()]).fold_equity_scale
|
|
);
|
|
}
|