Files
pokerfreak/src/sizing/allowed.rs
T
2026-10-28 11:51:24 +01:00

24 lines
833 B
Rust

use crate::game::Spot;
/// The entries of `allowed_sizes` hero may actually use, verbatim and ascending:
/// finite, positive, affordable, inside `[min_raise_to, max_raise_to]` when given.
/// `None` when the spot has no `allowed_sizes` at all.
pub fn valid_allowed(spot: &Spot) -> Option<Vec<f64>> {
spot.allowed_sizes.as_ref().map(|sizes| {
let mut usable: Vec<f64> = sizes
.iter()
.copied()
.filter(|s| {
s.is_finite()
&& *s > 0.0
&& *s <= spot.hero_stack
&& spot.min_raise_to.map_or(true, |min| *s >= min)
&& spot.max_raise_to.map_or(true, |max| *s <= max)
})
.collect();
usable.sort_by(f64::total_cmp);
usable.dedup();
usable
})
}