use super::fold_chance::{fold_base_cbet, fold_chance_on, sized_fold, MAX_FOLD}; use crate::game::{line, Spot}; /// Pressure of a raise to `to`: the chips beyond a call, `to - to_call`, over the pot /// after calling, `pot + to_call`. A plain bet (`to_call = 0`) is `to / pot`. /// 0 when the pot is empty or the numbers are not finite. pub fn pressure_ratio(pot: f64, to_call: f64, to: f64) -> f64 { let base = pot + to_call; let ratio = (to - to_call).max(0.0) / base; if base > 0.0 && ratio.is_finite() { ratio } else { 0.0 } } /// P(every villain folds) to hero raising to `to`: each villain's `fold_chance` /// (from their own profile) times the shared `scale` (`Thresholds::fold_equity_scale`), /// capped, multiplied over the villains as independent events. No villain: 0. pub fn table_fold(spot: &Spot, to: f64, scale: f64) -> f64 { let ratio = pressure_ratio(spot.pot, spot.to_call, to); let facing_raise = spot.to_call > 0.0; let scale = if scale.is_finite() { scale.max(0.0) } else { 1.0 }; let mut live = spot.live_villains().peekable(); if live.peek().is_none() { return 0.0; } // Hero's continuation bet is priced by the fold-to-c-bet read (`fold_base_cbet`). let cbet = line::cbet_spot(&spot.history, spot.hero_seat, spot.street); live.map(|v| { let p = v.profile.as_ref(); let f = if cbet { sized_fold(fold_base_cbet(p), ratio, facing_raise) } else { fold_chance_on(p, ratio, facing_raise, Some(spot.street)) }; (f * scale).clamp(0.0, MAX_FOLD) }) .product() }