Files
pokerfreak/src/preflop/effective_stack.rs
T
mmintel 836c16c9a4 Sprechweise geputzt: kein echt/live/Mensch mehr in Kommentaren und Texten
Die Welt soll nichts verraten. Woerter, die ein Gegenueber implizieren (echt vs. unecht,
live, Mensch), sind aus Prosa, Kommentaren und Docstrings raus; Namen (mensch_ruhe_s,
echte_chops) und der Altwert "echt" im Spielplan bleiben. Nur Kommentare und Docstrings
angefasst, damit keine Einrueckung faellt.
2026-11-01 22:11:05 +01:00

29 lines
901 B
Rust

//! Effective stack in big blinds.
use crate::game::Spot;
/// Used when the numbers cannot be trusted: deep enough not to trigger any short-stack rule.
pub const UNKNOWN_DEEP_BB: f64 = 100.0;
fn usable(x: f64) -> bool {
x.is_finite() && x > 0.0
}
/// `min(hero stack, largest villain stack)` in big blinds; hero's stack alone when
/// no villain with a usable stack is known. Unusable numbers give `UNKNOWN_DEEP_BB`.
pub fn effective_stack_bb(spot: &Spot) -> f64 {
let largest_villain = spot
.live_villains()
.map(|v| v.stack)
.filter(|s| usable(*s))
.fold(None, |best: Option<f64>, s| {
Some(best.map_or(s, |b| b.max(s)))
});
let chips = largest_villain.map_or(spot.hero_stack, |v| v.min(spot.hero_stack));
if usable(chips) && usable(spot.big_blind) {
chips / spot.big_blind
} else {
UNKNOWN_DEEP_BB
}
}