Files
pokerfreak/src/engine/called_equity.rs
T
mmintelandClaude Opus 5.5 2961efe3d1 Flussleck Tor bestanden: WERT_BRETT=river (River-Boden als Staerke auf dem Brett); RUF_ALLIN/RUF_OBEN als Verlierer entfernt
Volles Tor gg. ps2-*-an (Live mit S2): Leiter +2,42 +-0,72, Micro +4,47 +-0,98, pool-nl2 +1,95,
pool-nl2-echt +0,77, pool-phh +0,30, Lerner +2,76, kein Verlierer; LBR blind nicht schlechter;
6-max +1,36 +-0,67. Pflichtfaelle 11/16 (live 10): Strasse auf Vierflush jetzt FOLD, kein alter verloren.
AJ-Jam 178854100443 bleibt Ziel: Jam-Range simuliert / staerkste 1-Fold verlieren gegen Stations
(station@blind -6,79 / -28,73) und im 6-max (-10,54). Tafel: messung/flussleck/TOR.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 18:20:30 +01:00

84 lines
3.5 KiB
Rust

use super::called::Called;
use super::range_combos::{as_ranges_list, combo_list};
use super::range_filter::{range_filter, HandFilter};
use crate::card::Card;
use crate::equity::monte_carlo::estimate;
use crate::equity::query::Query;
use crate::equity::villain_range::VillainRange;
use crate::exploit::call_floor::{call_continuation, top_call_continuation};
use crate::exploit::range_model::range_spec;
use crate::exploit::size_notch::size_notch;
use crate::exploit::table_fold::pressure_ratio;
use crate::game::{ActionKind, Spot};
use crate::rng::Rng;
use crate::sizing::candidates::candidates;
/// Trials per calling-range simulation (one per size notch, so a few per decision).
const CALLED_TRIALS: u32 = 1000;
/// Hero's share against the hands that call a raise to each candidate size.
///
/// Each villain keeps their modelled range (`range_spec`) plus the calling floor
/// for that pressure (`exploit::call_floor`). Sizes in the same `size_notch` share one
/// simulation. A size whose simulation fails is left out (the engine then falls back
/// to the overall share). No legal raise: nothing to compute.
pub fn called_equity(spot: &Spot) -> Called {
if !spot.is_legal(ActionKind::Raise) {
return Called::sized(Vec::new());
}
let notched: Vec<(f64, i32, f64)> = candidates(spot)
.into_iter()
.map(|to| {
let ratio = pressure_ratio(spot.pot, spot.to_call, to);
(to, size_notch(Some(ratio)), ratio)
})
.collect();
let shares: Vec<(i32, Option<f64>)> = notched.iter().fold(Vec::new(), |mut done, (_, notch, ratio)| {
if !done.iter().any(|(n, _)| n == notch) {
done.push((*notch, simulate(spot, *notch, *ratio)));
}
done
});
Called::sized(
notched
.into_iter()
.filter_map(|(to, notch, _)| {
shares.iter().find(|(n, _)| *n == notch).and_then(|(_, s)| *s).map(|s| (to, s))
})
.collect(),
)
}
fn simulate(spot: &Spot, notch: i32, ratio: f64) -> Option<f64> {
let rules = spot.rules();
let filters: Vec<HandFilter> = spot
.live_villains()
.map(|v| {
let mut spec = range_spec(spot, v);
let fold_only = v.profile.is_some_and(|p| p.fold_only);
let call = if fold_only { top_call_continuation } else { call_continuation };
let mut c = call(v, spot.street, ratio, spot.to_call > 0.0);
if super::glaube::called_on() {
// POSTERIOR=fold: the range that calls is 1 - the fold the fold branch uses.
let goes_on = 1.0 - super::glaube::table_fold_of(spot, v, ratio, spot.to_call > 0.0);
if c.top_share.is_some() {
c.top_share = Some(goes_on);
} else {
c.continue_share = Some(goes_on);
}
}
spec.continues.push(c);
range_filter(&spec, rules, spot.variant, &spot.board)
})
.collect();
if filters.is_empty() {
return None;
}
let dead: Vec<Card> = spot.hero_cards.iter().chain(&spot.board).copied().collect();
let lists: Vec<_> = filters.iter().map(|f| combo_list(&rules, f, &dead)).collect();
let ranges: Vec<VillainRange> = as_ranges_list(&filters, &lists);
let query = Query { rules, hero: &spot.hero_cards, board: &spot.board, villains: &ranges, trials: CALLED_TRIALS };
let seed = spot.seed ^ (0xCA11_0000_u64 + (notch + 8).clamp(0, 64) as u64);
estimate(&query, Rng::seeded(seed)).ok().map(|(e, _)| e.share)
}