use crate::exploit::thresholds::Thresholds; use crate::read::draw::Draw; use crate::read::hand_read::HandRead; use crate::read::made::Made; use crate::read::suit_pattern::SuitPattern; use crate::read::tier::{tier, Tier}; /// Thresholds as seen by one specific hand on one specific board (heads-up basis). #[derive(Clone, Copy, Debug, PartialEq)] pub struct Stance { /// Equity above break-even needed to continue. pub call_margin: f64, /// Equity needed for a value raise. pub value_raise: f64, /// A value raise is allowed at all (pot control off). pub value_ok: bool, /// Any raise is allowed (`BoardOnly` never raises). pub raise_ok: bool, } const CALL_MARGIN: (f64, f64) = (0.0, 0.2); const VALUE_RAISE: (f64, f64) = (0.5, 0.95); /// Wetness at or above this is a "wet" board (no thin value raise for one pair). const WET: f64 = 0.6; /// Wetness at or below this is "dry"; the strong-hand discount fades out by 0.3. const DRY: f64 = 0.3; /// Shifts `(call_margin, value_raise)` for the hand's tier and the board, `w` = wetness. /// /// | tier | call margin | value raise | value raise allowed | /// |---------|----------------------------------|-------------------------------------|------------------------------| /// | Weak | +0.03 facing a bet without a draw| +0.10 | yes | /// | Medium | +0.01 + 0.04w (+0.03 four-flush) | +0.06 + 0.12w | no if w >= 0.6 or four-flush | /// | Strong | +0.02w (+0.03 four-flush) | -0.04 dry (fades to 0 at w=0.3) + 0.05w (+0.08 four-flush) | yes | /// | Monster | 0 | 0 | yes | /// /// `Made::BoardOnly` may not raise at all. Results are clamped to /// `call_margin` in [0, 0.2] and `value_raise` in [0.5, 0.95]. Unknown wetness counts as 0.5. pub fn texture_stance(base: &Thresholds, read: &HandRead, facing_bet: bool) -> Stance { let w = if read.texture.wetness.is_nan() { 0.5 } else { read.texture.wetness.clamp(0.0, 1.0) }; let four = read.texture.suits == SuitPattern::FourFlush; let four_margin = if four { 0.03 } else { 0.0 }; let drawing = read.draw >= Draw::Gutshot; let dry = (1.0 - w / DRY).clamp(0.0, 1.0); let (margin, value, value_ok) = match tier(read.made) { Tier::Weak => (if facing_bet && !drawing { 0.03 } else { 0.0 }, 0.10, true), Tier::Medium => (0.01 + 0.04 * w + four_margin, 0.06 + 0.12 * w, !(w >= WET || four)), Tier::Strong => ( 0.02 * w + four_margin, -0.04 * dry + 0.05 * w + if four { 0.08 } else { 0.0 }, true, ), Tier::Monster => (0.0, 0.0, true), }; let raise_ok = read.made != Made::BoardOnly; Stance { call_margin: (base.call_margin + margin).clamp(CALL_MARGIN.0, CALL_MARGIN.1), value_raise: (base.value_raise + value).clamp(VALUE_RAISE.0, VALUE_RAISE.1), value_ok: value_ok && raise_ok, raise_ok, } }