Files
pokerfreak/src/exploit/adjust.rs
T
mmintelandClaude Opus 5.5 ec800a1672 Preflop charts and exploitation layer
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>
2026-10-28 12:00:21 +01:00

59 lines
2.4 KiB
Rust

use super::fold_equity_scale::{fold_equity_scale, MAX_SCALE, MIN_SCALE};
use super::profile::Profile;
use super::style::classify;
use super::style_shift::shift_for;
use super::thresholds::Thresholds;
/// Output ranges: whatever the inputs, the engine never sees thresholds outside these.
const CALL_MARGIN: (f64, f64) = (0.0, 0.15);
const VALUE_RAISE: (f64, f64) = (0.52, 0.85);
const ABSTAIN_BAND: (f64, f64) = (0.0, 0.05);
const RANGE_WIDTH: (f64, f64) = (0.6, 1.4);
fn bounded(x: f64, (low, high): (f64, f64)) -> f64 {
if x.is_nan() {
low
} else {
x.clamp(low, high)
}
}
/// `base` as seen against one profile; `None` when the profile says nothing.
fn against(base: Thresholds, profile: &Profile) -> Option<Thresholds> {
shift_for(classify(profile)).map(|shift| Thresholds {
call_margin: bounded(base.call_margin + shift.call_margin, CALL_MARGIN),
value_raise: bounded(base.value_raise + shift.value_raise, VALUE_RAISE),
abstain_band: bounded(base.abstain_band, ABSTAIN_BAND),
fold_equity_scale: (base.fold_equity_scale
* fold_equity_scale(profile.fold_to_bet, shift.fold_equity_default))
.clamp(MIN_SCALE, MAX_SCALE),
range_width_scale: bounded(base.range_width_scale * shift.range_width, RANGE_WIDTH),
})
}
/// Conservative merge of two opponents: keep the harder-to-continue value of each
/// threshold (higher margins, lower fold equity, narrower ranges).
fn conservative(a: Thresholds, b: Thresholds) -> Thresholds {
Thresholds {
call_margin: a.call_margin.max(b.call_margin),
value_raise: a.value_raise.max(b.value_raise),
abstain_band: a.abstain_band.max(b.abstain_band),
fold_equity_scale: a.fold_equity_scale.min(b.fold_equity_scale),
range_width_scale: a.range_width_scale.min(b.range_width_scale),
}
}
/// Shift thresholds for the given live opponents' profiles. No profiles → `base` unchanged.
///
/// Each profile is classified (`style::classify`) and moves `base` by its style
/// (`style_shift`); foldToBet, when given, sets `fold_equity_scale` continuously.
/// Profiles with no usable numbers are ignored; with several informative ones the
/// results are merged conservatively. Outputs are clamped to sane ranges.
pub fn adjust(base: Thresholds, profiles: &[Profile]) -> Thresholds {
profiles
.iter()
.filter_map(|p| against(base, p))
.reduce(conservative)
.unwrap_or(base)
}