/// Hero's equity share in the called branch of a raise: against the hands that call /// it, not against the whole range (a bet folds out the weak part, the rest is stronger). /// Raw shares, before the multiway realisation discount. #[derive(Clone, Debug, PartialEq)] pub struct Called { by_size: Vec<(f64, f64)>, flat: Option, } impl Called { /// The same share for every size (no calling-range model: the whole range calls). pub fn flat(share: f64) -> Called { Called { by_size: Vec::new(), flat: Some(share) } } /// One share per raise-to amount. pub fn sized(by_size: Vec<(f64, f64)>) -> Called { Called { by_size, flat: None } } /// The share for a raise to `to`; `fallback` when the size is unknown or the share /// is not a probability. pub fn share_at(&self, to: f64, fallback: f64) -> f64 { self.by_size .iter() .find(|(size, _)| (size - to).abs() < 1e-9) .map(|(_, share)| *share) .or(self.flat) .filter(|s| s.is_finite() && (0.0..=1.0).contains(s)) .unwrap_or(fallback) } }