diff --git a/entscheiden/motor/src/dienst.rs b/entscheiden/motor/src/dienst.rs index 7ce6561c..6df18550 100644 --- a/entscheiden/motor/src/dienst.rs +++ b/entscheiden/motor/src/dienst.rs @@ -2775,7 +2775,7 @@ impl Motor { let (k, g, exakt) = if flop_exakt { // MOTOR_FLOP_BIBLIOTHEK (flopbib_nach.rs): Mischung aus der Flop-Bibliothek statt der Loesung, wo sie dasselbe Spiel ist if let Some(ordner) = crate::flopbib_nach::ordner() { - match self.flop_bibliothek(ordner, q, &a, zuege, oop, ip, mich, hand, brett, bb) { + match self.flop_bibliothek(ordner, q, &a, zuege, oop, ip, mich, hand, brett, bb).and_then(crate::flopbib_nach::ohne_allin) { Ok(mut m) => { // MOTOR_ALLIN_PROBE: auch der All-in/Call aus der Bibliothek braucht beide Rechnungen (Q der Bibliothek als Bestantwort) let mut herkunft = Herkunft::von(Quelle::Bibliothek); diff --git a/entscheiden/motor/src/flopbib_nach.rs b/entscheiden/motor/src/flopbib_nach.rs index cb2e1546..5c84f378 100644 --- a/entscheiden/motor/src/flopbib_nach.rs +++ b/entscheiden/motor/src/flopbib_nach.rs @@ -95,6 +95,20 @@ pub struct Mischung { pub text: String, } +/// Die Bibliothek speichert Werte je Zug ohne die Reichweite des Gegners am Knoten. An einem kaum erreichten Knoten sind diese Werte nur +/// der Sockel des Loesers (keine Rechnung, nachrechnen::band_am_knoten), und ein All-in duerfte nie auf ihnen getragen werden. Darum spielt die +/// Bibliothek keinen Knoten mit All-in in der Mischung (Masse > 0) und keinen Call gegen All-in (nur Fold/Call): dort rechnet Flop exakt +/// mit dem Band eps / Reichweite. Sonst gilt die Mischung. +pub fn ohne_allin(m: Mischung) -> Result { + use postflop_solver::Action; + let allin = m.v.iter().any(|(a, p)| matches!(a, Action::AllIn(_)) && *p > 0.0); + let nur_fold_call = m.v.len() == 2 && m.v[0].0 == Action::Fold && m.v[1].0 == Action::Call; + if allin || nur_fold_call { + return Err("All-in-Knoten ohne Reichweite in der Bibliothek, rechnet exakt".into()); + } + Ok(m) +} + /// Bild der Linie (oder einer ihrer Stufen, deren Lage passt), Knoten ueber die echten Flop-Zuege, Mischung der Hand; sonst der Grund. #[allow(clippy::too_many_arguments)] pub fn mischung_fuer(wurzel: &str, art: Topfart, linie: &str, flop: [u8; 3], hand: (u8, u8), mich: usize, flop_zuege: &[(u8, i32)], lage: &Lage) -> Result { @@ -857,3 +871,21 @@ pub(crate) mod spec { assert!((s - 1.0).abs() < 1e-3, "{s}"); } } + +#[cfg(test)] +mod ohne_allin_spec { + use super::{ohne_allin, Mischung}; + use postflop_solver::Action; + + fn m(v: Vec<(Action, f32)>) -> Mischung { + Mischung { v, werte: Some(vec![]), luecke_topf: 0.01, gezogen: None, text: String::new() } + } + + #[test] + fn bibliothek_spielt_keinen_allin_knoten() { + assert!(ohne_allin(m(vec![(Action::Check, 0.6), (Action::Bet(300), 0.3), (Action::AllIn(9000), 0.1)])).is_err(), "All-in mit Masse"); + assert!(ohne_allin(m(vec![(Action::Fold, 0.4), (Action::Call, 0.6)])).is_err(), "Call gegen All-in"); + assert!(ohne_allin(m(vec![(Action::Check, 0.7), (Action::Bet(300), 0.3), (Action::AllIn(9000), 0.0)])).is_ok(), "All-in ohne Masse wird nie gezogen"); + assert!(ohne_allin(m(vec![(Action::Fold, 0.2), (Action::Call, 0.5), (Action::Raise(900), 0.3)])).is_ok()); + } +}