From 52993ecefbf473ea11f83283a763504ea73eb5cb Mon Sep 17 00:00:00 2001 From: Marc Mintel Date: Fri, 4 Dec 2026 01:31:20 +0100 Subject: [PATCH] Flop exakt: Rueckfall auf die Tafel laesst den Zuggrund wie ohne Schalter (Notiz im Feld flopExakt) Wiedergabe 1.903 Flop-Anfragen: 74 Rueckfaelle (zu lang / nicht fertig) spielten anders als ohne Schalter, weil ' [nicht genau: ...]' vor ': ' im Zuggrund stand und nl2.rs die Flop-Zuege daraus nicht mehr lesen konnte (NL2-Typ-Regel stumm). Co-Authored-By: Claude Opus 5.5 --- entscheiden/motor/src/dienst.rs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/entscheiden/motor/src/dienst.rs b/entscheiden/motor/src/dienst.rs index d5b9d898..a639f4e5 100644 --- a/entscheiden/motor/src/dienst.rs +++ b/entscheiden/motor/src/dienst.rs @@ -7,6 +7,11 @@ use postflop_solver::{Action, PostFlopGame}; use serde_json::{json, Value}; use std::collections::HashMap; +thread_local! { + /// Grund, warum MOTOR_FLOP_EXAKT auf die Tafel zurueckfiel (versuche -> antworte); nie im Zuggrund, damit der Rueckfall gleich "aus" ist + static FLOP_NOTIZ: std::cell::RefCell> = const { std::cell::RefCell::new(None) }; +} + /// Gelernte Strategie, eingelesen. pub struct Strategie { lage: HashMap, @@ -311,6 +316,7 @@ impl Motor { } pub fn antworte(&self, q: &Value) -> Value { + FLOP_NOTIZ.with(|n| n.borrow_mut().take()); // MOTOR_FLOP_EXAKT (flop_exakt.rs): Abbild bei Flop-Aufdeckung loest vor und merkt, kein Zug if q["suche_frueh"] == true && q["street"] == "FLOP" && crate::flop_exakt::an() { let nein = |g: String| json!({"action": "ABSTAIN", "size": null, "confidence": 0, "reason": format!("suche_frueh: {g}")}); @@ -321,7 +327,14 @@ impl Motor { }; } match self.versuche(q) { - Ok(a) => self.vorflop_allin(q, self.nl2(q, a)), + Ok(a) => { + let mut a = self.vorflop_allin(q, self.nl2(q, a)); + // Rueckfall von MOTOR_FLOP_EXAKT: Grund steht im eigenen Feld, der Zuggrund bleibt wie ohne Schalter (nl2.rs liest ihn) + if let Some(n) = FLOP_NOTIZ.with(|n| n.borrow_mut().take()) { + a["flopExakt"] = json!(format!("nicht genau: {n}")); + } + a + } Err(e) => { // Notfall: Equity gegen Zufallshaende gegen den Preis, vorsichtig; im reason erkennbar let legal = |x: &str| q["legalActions"].as_array().is_some_and(|l| l.iter().any(|y| y == x)); @@ -470,11 +483,13 @@ impl Motor { match self.genau_rechnen(q, &l, &zuege, &sitze, n - m, strasse, ich, hand, &brett, bb, salz) { Ok(Some(r)) => return Ok(r), Ok(None) => {} + Err(e) if flop_exakt => FLOP_NOTIZ.with(|n| *n.borrow_mut() = Some(e)), Err(e) => wieso = format!(" [nicht genau: {e}]"), } } if flop_exakt && q["suche_frueh"] == true { - return Ok(json!({"action": "ABSTAIN", "size": null, "confidence": 0, "reason": format!("suche_frueh: Flop exakt nicht vorgerechnet{wieso}")})); + let n = FLOP_NOTIZ.with(|n| n.borrow_mut().take()).map(|e| format!(" [nicht genau: {e}]")).unwrap_or_default(); + return Ok(json!({"action": "ABSTAIN", "size": null, "confidence": 0, "reason": format!("suche_frueh: Flop exakt nicht vorgerechnet{n}")})); } let gegner: Vec = (0..n) .filter(|&i| i != ich as usize && (i < 2 || i >= 2 + n - m) && !zuege.iter().any(|z| z.art == 0 && z.sitz as usize == i))