Files
pokerfreak/src/exploit/band_stretch.rs
T
mmintelandClaude Opus 5.5 9a9c6c946d Range narrowing from action history, position from inferred button
Wire: optional history decoding. exploit::range_model: role band + postflop
continuations. preflop::button / seat_position: button inference from blinds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 12:41:03 +01:00

38 lines
1.5 KiB
Rust

use super::preflop_role::PreflopRole;
use super::profile::Profile;
use super::range_guess::DEFAULT_VPIP;
/// A regular preflop raise frequency (six-max).
pub const DEFAULT_PFR: f64 = 0.18;
const MIN_STRETCH: f64 = 0.5;
const MAX_STRETCH: f64 = 1.8;
fn frequency(x: Option<f64>) -> Option<f64> {
x.filter(|v| !v.is_nan()).map(|v| v.clamp(0.0, 1.0))
}
/// How much looser (> 1) or tighter (< 1) than the reference player this villain is, for
/// the kind of action the role is made of. Clamped to `[0.5, 1.8]`; 1.0 without data.
///
/// - raising roles: `pfr / 0.18`; without pfr, `sqrt(vpip / 0.30)` (half-strength vpip)
/// - calling, limping and blind roles: `vpip / 0.30`
pub fn stretch(role: PreflopRole, profile: Option<Profile>) -> f64 {
let profile = profile.unwrap_or_default();
let (vpip, pfr) = (frequency(profile.vpip), frequency(profile.pfr));
let raw = if role.is_raising() {
pfr.map(|f| f / DEFAULT_PFR)
.or_else(|| vpip.map(|v| (v / DEFAULT_VPIP).sqrt()))
} else {
vpip.map(|v| v / DEFAULT_VPIP)
};
raw.unwrap_or(1.0).clamp(MIN_STRETCH, MAX_STRETCH)
}
/// A band `[lo, hi]` for a player `factor` times as loose as the reference: the upper
/// edge moves out by `factor`, the lower edge in by `1 / factor` (looser players raise
/// less often with their best hands, so fewer hands are excluded at the top).
/// Width is non-decreasing in `factor`.
pub fn stretched(lo: f64, hi: f64, factor: f64) -> (f64, f64) {
(lo / factor, hi * factor)
}