diff --git a/src/engine/decide.rs b/src/engine/decide.rs index 6bcb5a83..fa8cde05 100644 --- a/src/engine/decide.rs +++ b/src/engine/decide.rs @@ -200,6 +200,9 @@ pub fn decide(spot: &Spot) -> Decision { /// `decide` with an optional tournament situation (`icm`). Without one: cash. With one /// that cannot be priced: ABSTAIN. pub fn decide_with(spot: &Spot, lage: Option<&Turnierlage>) -> Decision { + // Chip-lineares Geld (der Sieger nimmt alles, alle Verbliebenen gleich bezahlt, p1 > p2 = ... = pn): + // ICM IST Chip-EV, also genau der Cash-Pfad. Eine unbepreisbare Lage bleibt ein Aussetzen. + let lage = lage.filter(|l| !(l.is_usable() && l.is_chip_linear())); // Only act on reads we are proven to beat blind play with (`read_gate`); competent and // aggressive opponents are played blind until the exploit logic earns them on the ladder. let gated = super::read_gate::gate_reads(spot); diff --git a/src/icm/lage.rs b/src/icm/lage.rs index f6c588c8..38468bf8 100644 --- a/src/icm/lage.rs +++ b/src/icm/lage.rs @@ -29,4 +29,41 @@ impl Turnierlage { && self.payouts.iter().all(|p| p.is_finite() && *p >= 0.0) && self.payouts.iter().sum::() > 0.0 } + + /// Money is affine in chips: every place from 2 to `players()` pays the same (an unpaid place + /// pays 0). Then Harville gives equity = c + (p1 - c) * chip share for every stack - winner + /// takes all, or everyone left paid alike - and ICM is chip-EV: no tournament line may differ. + pub fn is_chip_linear(&self) -> bool { + let n = self.players(); + let prize = |k: usize| self.payouts.get(k).copied().unwrap_or(0.0); + let scale = self.payouts.iter().fold(0.0_f64, |m, p| m.max(p.abs())).max(f64::MIN_POSITIVE); + (2..n).all(|k| (prize(k) - prize(1)).abs() <= 1e-12 * scale) + } +} + +#[cfg(test)] +mod tests { + use super::Turnierlage; + + fn lage(payouts: &[f64], players: usize) -> Turnierlage { + Turnierlage { payouts: payouts.to_vec(), stacks: vec![10.0; players], hero: 0, ante: 0.0, level: 1 } + } + + #[test] + fn chip_linear_money_is_recognised() { + assert!(lage(&[100.0], 4).is_chip_linear(), "winner takes all"); + assert!(lage(&[100.0, 0.0, 0.0], 5).is_chip_linear(), "WTA with zero places listed"); + assert!(lage(&[25.0, 25.0, 25.0, 25.0], 4).is_chip_linear(), "everyone left paid alike"); + assert!(lage(&[70.0, 10.0, 10.0, 10.0], 4).is_chip_linear(), "top prize over an equal rest"); + assert!(lage(&[65.0, 35.0], 2).is_chip_linear(), "heads-up: any split"); + assert!(lage(&[20.0, 20.0, 20.0, 20.0, 20.0], 3).is_chip_linear(), "more paid places than players, alike"); + } + + #[test] + fn a_real_ladder_is_not_chip_linear() { + assert!(!lage(&[50.0, 30.0, 20.0], 4).is_chip_linear(), "bubble"); + assert!(!lage(&[50.0, 30.0, 20.0], 3).is_chip_linear(), "all left paid, unequal"); + assert!(!lage(&[60.0, 20.0, 20.0], 4).is_chip_linear(), "place 4 unpaid"); + assert!(!lage(&[25.0, 25.0, 25.0, 25.0], 5).is_chip_linear(), "flat but a bubble"); + } } diff --git a/src/icm/push_fold.rs b/src/icm/push_fold.rs index c8a0e44d..f6bccd08 100644 --- a/src/icm/push_fold.rs +++ b/src/icm/push_fold.rs @@ -321,7 +321,9 @@ pub fn push_fold(spot: &Spot, lage: &Turnierlage) -> Option { if !ENABLED.load(Ordering::Relaxed) { return None; } - if !lage.is_usable() || lage.stacks.len() > MAX_FIELD || spot.street != Street::Preflop { + if !lage.is_usable() || lage.is_chip_linear() || lage.stacks.len() > MAX_FIELD || spot.street != Street::Preflop { + // Chip-linear money (winner takes all, everyone left paid alike): ICM IS chip-EV, the cash + // path plays it unchanged (tests/pipeline_tournament.rs winner_takes_all_is_cash_on_the_wire). return None; } if !matches!(spot.variant, Variant::Nlhe | Variant::Aof) || spot.hero_cards.len() != 2 { diff --git a/tests/pipeline_tournament.rs b/tests/pipeline_tournament.rs index d3b86add..2143805f 100644 --- a/tests/pipeline_tournament.rs +++ b/tests/pipeline_tournament.rs @@ -89,6 +89,21 @@ fn winner_takes_all_is_cash_on_the_wire() { assert_eq!(calls(depth, &wta), calls(depth, "")); } +#[test] +fn chip_linear_money_is_cash_on_the_wire() { + // Every place after the first pays alike (incl. 0 when unpaid): equity = c + (p1 - c) * share, + // money is affine in chips. All left paid alike, a top prize over equal rest, and a WTA whose + // payout list is longer than the field. + let depth = 10.0; + let field = [depth, depth, 2.0 * depth, 2.0 * depth]; + let cash = calls(depth, ""); + for payouts in [&[25.0, 25.0, 25.0, 25.0][..], &[70.0, 10.0, 10.0, 10.0], &[100.0, 0.0, 0.0, 0.0, 0.0]] { + assert_eq!(calls(depth, &tournament(payouts, &field)), cash, "{payouts:?}"); + } + // Heads-up any prize split is linear too (only place 2 after place 1). + assert_eq!(calls(depth, &tournament(&[65.0, 35.0], &[depth, depth])), cash, "heads-up 65/35"); +} + #[test] fn a_malformed_tournament_is_an_invalid_request() { let hole = &holes()[0];