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.
45 lines
1.5 KiB
Rust
45 lines
1.5 KiB
Rust
//! Multipliers that narrow or widen a guessed opponent range.
|
|
|
|
use crate::game::Street;
|
|
|
|
/// Later streets: players who are still in hold stronger hands.
|
|
const BY_STREET: [f64; 4] = [1.0, 0.8, 0.62, 0.5];
|
|
|
|
pub fn street_factor(street: Street) -> f64 {
|
|
BY_STREET[street as usize]
|
|
}
|
|
|
|
/// A bet of `to_call / pot` (capped at 1.5 pots) narrows the range: `1 / (1 + 1.2 r)`.
|
|
/// No bet gives 1.0; a pot-sized bet about 0.45. Unusable numbers count as a big bet
|
|
/// if there is something to call, else no bet.
|
|
pub fn bet_factor(to_call: f64, pot: f64) -> f64 {
|
|
let ratio = if to_call.is_nan() || to_call <= 0.0 {
|
|
0.0
|
|
} else if pot.is_nan() || pot <= 0.0 {
|
|
MAX_BET_RATIO
|
|
} else {
|
|
(to_call / pot).min(MAX_BET_RATIO)
|
|
};
|
|
1.0 / (1.0 + 1.2 * ratio)
|
|
}
|
|
|
|
const MAX_BET_RATIO: f64 = 1.5;
|
|
|
|
/// Passive multiway pots (nobody has bet) leave wider ranges: +10 % per extra player,
|
|
/// at most three extra. Once somebody bets the bonus is gone.
|
|
pub fn multiway_factor(live_players: usize, someone_bet: bool) -> f64 {
|
|
if someone_bet {
|
|
1.0
|
|
} else {
|
|
1.0 + 0.1 * live_players.saturating_sub(1).min(3) as f64
|
|
}
|
|
}
|
|
|
|
/// Sticky players (low foldToBet) continue with more hands, foldy ones with fewer:
|
|
/// `1 + 0.4 * (0.5 - foldToBet)`, so 0.84 to 1.2. Unknown or NaN gives 1.0.
|
|
pub fn stickiness_factor(fold_to_bet: Option<f64>) -> f64 {
|
|
fold_to_bet
|
|
.filter(|b| !b.is_nan())
|
|
.map_or(1.0, |b| 1.0 + 0.4 * (0.5 - b.clamp(0.0, 1.0)))
|
|
}
|