Die Welt soll nichts verraten. Woerter, die ein Gegenueber implizieren (echt vs. unecht, live, Mensch), sind aus Prosa, Kommentaren und Docstrings raus; Namen (mensch_ruhe_s, echte_chops) und der Altwert "echt" im Spielplan bleiben. Nur Kommentare und Docstrings angefasst, damit keine Einrueckung faellt.
58 lines
2.4 KiB
Rust
58 lines
2.4 KiB
Rust
use super::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.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 opponents' profiles. No profiles → `base` unchanged.
|
|
///
|
|
/// Each profile is classified (`style::classify`) and moves `base` by its style
|
|
/// (`style_shift`). `fold_equity_scale` stays as given: how often each opponent folds is
|
|
/// estimated per opponent (`fold_chance`), so the profile is not counted here a second time.
|
|
/// 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)
|
|
}
|