Leck-Finder (NL2-Spots): fluss/flussjam geben Set-/Zwei-Paar-Jamwert ab (netto -3254/-4162 bb), verworfen. flusspaarjam +2684 bb gegen Live (Untergrenze +596), kein Wert-Posten verloren, Pflichtfaelle bestanden. Schalter aus = Live-Pfad. Sim-Tor ob4-fpj laeuft. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
136 lines
6.4 KiB
Rust
136 lines
6.4 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 mut sizes = candidates(spot);
|
|
// CALLED_JAM: the all-in that `size_policy::no_mans_land` substitutes for a size leaving a small
|
|
// rest stack is not among the candidates; without its own entry the jam is priced against the
|
|
// whole range (`Called::share_at` falls back to the overall share).
|
|
let ueberbet = crate::exploit::fold_chance::ueberbet_cap_on(Some(spot.street)).is_some();
|
|
let jam_priced = ueberbet || match called_jam_mode() {
|
|
1 => true,
|
|
2 => super::options::all_read_folding(spot, CALLED_JAM_FOLD),
|
|
3 => !super::options::any_read_station(spot, CALLED_JAM_FOLD),
|
|
_ => false,
|
|
};
|
|
if jam_priced {
|
|
if let Some(jam) = crate::sizing::all_in::all_in(spot).filter(|j| j.is_finite() && *j > 0.0) {
|
|
if !sizes.iter().any(|s| (s - jam).abs() < 1e-9) {
|
|
sizes.push(jam);
|
|
}
|
|
}
|
|
}
|
|
// UEBERBET: a raise of at least pot (the all-in included when it is that big) is called by the
|
|
// top of the range; such sizes get their own simulation key (notch + 100). A short all-in below pot
|
|
// keeps the floor model (live 17.11.: a 0.88-pot river jam with top trips priced at 0.13 against
|
|
// the top of two ranges, a value bet lost).
|
|
let all_in = crate::sizing::all_in::all_in(spot).filter(|j| j.is_finite());
|
|
let heads_up = spot.live_villains().count() == 1;
|
|
let notched: Vec<(f64, i32, f64)> = sizes
|
|
.into_iter()
|
|
.map(|to| {
|
|
let ratio = pressure_ratio(spot.pot, spot.to_call, to);
|
|
let jam = crate::exploit::fold_chance::ueberbet_jam()
|
|
&& heads_up
|
|
&& ratio >= crate::exploit::fold_chance::UEBERBET_JAM_RATIO
|
|
&& all_in.is_some_and(|j| to >= j - 1e-9);
|
|
let top = ueberbet && (ratio >= crate::exploit::fold_chance::UEBERBET_TOP_RATIO || jam);
|
|
(to, size_notch(Some(ratio)) + if top { 100 } else { 0 }, 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(),
|
|
)
|
|
}
|
|
|
|
/// Messschalter (einmal gelesen) `CALLED_JAM=1`: the calling range is also simulated for the all-in
|
|
/// size. Live 16.11.: `REST_STACK` turned a pot bet into a jam (AA 1.52 into 1.12, AJ 1.90 into 0.79),
|
|
/// which had no calling-range entry, so the jam was priced at the overall share (AA 0.76) while the
|
|
/// pot-sized bet already stood at 0.40-0.46 against its callers. Default: off (bit-identical).
|
|
/// `gelesen`: only when every live villain has a raw read that folds to a bet at least
|
|
/// `CALLED_JAM_FOLD` (ladder 17.11.: `1` lost -4,5 / -6,8 to the station, which calls a jam with any
|
|
/// pair - priced at the overall share, the jam was right against it). Unread: as today.
|
|
/// `nicht_station`: for everyone except a villain read as a station (fold-to-bet below the bar);
|
|
/// unread villains get the calling range too.
|
|
pub fn called_jam_mode() -> u8 {
|
|
use std::sync::OnceLock;
|
|
static MODE: OnceLock<u8> = OnceLock::new();
|
|
*MODE.get_or_init(|| match std::env::var("CALLED_JAM").as_deref() {
|
|
Ok("1") => 1,
|
|
Ok("gelesen") => 2,
|
|
Ok("nicht_station") => 3,
|
|
_ => 0,
|
|
})
|
|
}
|
|
|
|
/// fold-to-bet a read must reach for `CALLED_JAM=gelesen` (`style::STATION_FOLD_TO_BET`).
|
|
const CALLED_JAM_FOLD: f64 = 0.30;
|
|
|
|
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) || notch >= 50;
|
|
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, 164) as u64);
|
|
estimate(&query, Rng::seeded(seed)).ok().map(|(e, _)| e.share)
|
|
}
|