SHARINGAN mit Splash, Antes und Nachpost (MOTOR_SHARINGAN_SPLASH=1, Standard aus): Splash als dead_money, Ante als players[].dead, nachgeposteter BB live als players[].live_post (Beleg: 619 Checks des Nachposters, Topf 40/40); Straddle bleibt beim Motor; Vorflop-Zuggrund nennt die Tabelle ohne totes Geld. Nur mit dem Splash-Dienst.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-03 15:26:01 +01:00
co-authored by Claude Opus 5.5
parent 66f007a5eb
commit d744f6b0bc
2 changed files with 166 additions and 7 deletions
+4 -2
View File
@@ -613,9 +613,11 @@ impl Motor {
}
/// Hybrid (MOTOR_VORFLOP_FLOP_QUELLE=sharingan): nur der 6-max-Hauptmotor ohne Straddle, Splash und Antes
/// (Splash und Antes mit MOTOR_SHARINGAN_SPLASH, 03.12.; Straddle bleibt beim Motor)
fn hybrid(&self, q: &Value) -> bool {
crate::sharingan::an() && !self.s.turnier && (self.s.n == 6 || crate::sharingan::rein() && (2..=6).contains(&self.s.n)) && !self.s.straddle && self.s.splash == 0 && !self.s.ante && self.s.art != crate::spiel::Art::PushFold
&& Self::splash_tot(q) == 0.0 && Self::ante_tot(q) == 0.0 && !Self::ist_straddle(q) && q.get("eigen").is_none() && q.get("probeHand").is_none()
let tot_ok = crate::sharingan::splash();
crate::sharingan::an() && !self.s.turnier && (self.s.n == 6 || crate::sharingan::rein() && (2..=6).contains(&self.s.n)) && !self.s.straddle && (tot_ok || self.s.splash == 0 && !self.s.ante) && self.s.art != crate::spiel::Art::PushFold
&& (tot_ok || Self::splash_tot(q) == 0.0 && Self::ante_tot(q) == 0.0) && !Self::ist_straddle(q) && q.get("eigen").is_none() && q.get("probeHand").is_none()
}
/// Ersatzzug aus dem Blueprint nach einer gescheiterten Suche: Grund der Suche anhaengen (" [Suche: search_busy ...]")
+162 -5
View File
@@ -73,6 +73,21 @@ pub fn rein() -> bool {
*A.get_or_init(|| an() && std::env::var("MOTOR_SHARINGAN_REIN").is_ok_and(|x| x == "1"))
}
/// MOTOR_SHARINGAN_SPLASH=1 (03.12., Owner "ich will Splash und Straddle mit reinhaben", Standard aus): Splash (Hausgeld im
/// Haupttopf), Antes und nachgepostete grosse Blinds gehen an SHARINGAN (`dead_money`, `players[].dead`, `players[].live_post`).
/// Der Nachpost ist live (Beleg schatten.jsonl 03.12.: 619 Checks des Nachposters ohne Erhoehung, Topf beim Flop 40 von 40 nur
/// mit Post als Einsatz). Nur mit dem Splash-Dienst (pokerbench-hybrid-*-splash.exe; der alte Dienst kennt die Felder nicht und
/// rechnete ohne totes Geld). Straddle (zweiter grosser Blind ueber 1 bb) spielt weiter der Motor. Vor dem Flop nimmt SHARINGAN
/// dieselben Tabellenknoten wie ohne totes Geld; der Zuggrund sagt es.
pub fn splash() -> bool {
static A: OnceLock<bool> = OnceLock::new();
*A.get_or_init(|| an() && std::env::var("MOTOR_SHARINGAN_SPLASH").is_ok_and(|x| x == "1"))
}
/// Zuggrund vor dem Flop, wenn totes Geld oder ein Nachpost im Topf liegt (seine Tabellen kennen beides nicht)
const GRUND_SPLASH: &str = " [Splash: Vorflop-Tabelle ohne totes Geld]";
const GRUND_NACHPOST: &str = " [Nachpost: Vorflop-Tabelle ohne Nachpost]";
fn schalter(k: &str, w: &str) -> bool {
std::env::var(k).is_ok_and(|x| x == w)
}
@@ -162,6 +177,8 @@ pub struct Kontext {
pub rake_knoten: bool,
/// Vor dem Helden liegt am Flop eine Kopf-an-Kopf-C-Bet gegen ihn (MOTOR_HYB_ZELLE=flop_cbet)
pub flop_cbet: bool,
/// Zusatz zum Zuggrund vor dem Flop (MOTOR_SHARINGAN_SPLASH): totes Geld oder Nachpost im Topf, sonst leer
pub vorflop_grund: &'static str,
}
impl Kontext {
@@ -199,8 +216,15 @@ pub fn kontext() -> Option<Rc<Kontext>> {
impl Kontext {
/// Vertrag -> seine ActRequest (BB = 100 Chips, Sitze 0..5 in Tischreihenfolge, `to` = Einsatz dieser Strasse,
/// stack_start = Stapel jetzt + eingezahlt). Nur volle sechs Plaetze, keine Antes; sonst None (dann spielt der Motor).
/// stack_start = Stapel jetzt + eingezahlt). Nur volle sechs Plaetze (mit MOTOR_SHARINGAN_REIN 2 bis 6); Antes, Splash und
/// Nachposts nur mit MOTOR_SHARINGAN_SPLASH; sonst None (dann spielt der Motor).
pub fn aus(q: &Value) -> Option<Kontext> {
Self::aus_mit(q, splash())
}
/// `mit_tot`: Antes (`players[].dead`), Splash (`dead_money`) und nachgepostete grosse Blinds bis 1 bb (`players[].live_post`)
/// an SHARINGAN geben; ein hoeherer Nachpost (Straddle) gibt None.
pub fn aus_mit(q: &Value, mit_tot: bool) -> Option<Kontext> {
let bb = q["bigBlind"].as_f64()?;
let c = |x: f64| (x / bb * 100.0).round() as i64;
let hist_q = q["history"].as_array()?;
@@ -218,9 +242,11 @@ impl Kontext {
let pos = |s: i64| sitze.iter().position(|&x| x == s);
let sb = pos(hist_q.iter().find(|h| h["action"] == "POST_SB")?["seat"].as_i64()?)?;
let bbs = pos(hist_q.iter().find(|h| h["action"] == "POST_BB")?["seat"].as_i64()?)?;
if bbs != (sb + 1) % n || hist_q.iter().filter(|h| h["action"] == "POST_BB").count() != 1 {
if bbs != (sb + 1) % n || (hist_q.iter().filter(|h| h["action"] == "POST_BB").count() != 1 && !mit_tot) {
return None;
}
// totes Geld: Splash des Hauses, Antes je Platz, Nachposts je Platz (live; der erste POST_BB ist der grosse Blind)
let (mut haus, mut tot, mut nachpost, mut bb_gesehen) = (0i64, [0i64; 6], [0i64; 6], false);
let strasse_nr = |s: &str| ["PREFLOP", "FLOP", "TURN", "RIVER"].iter().position(|x| *x == s).map(|x| x as u8);
let (mut hist, mut zuege, mut drin) = (Vec::new(), Vec::new(), [0i64; 6]);
let (mut st, mut auf, mut hoch) = (0u8, [0i64; 6], 0i64);
@@ -243,6 +269,28 @@ impl Kontext {
if strasse != st {
(st, auf, hoch, erh_str) = (strasse, [0; 6], 0, 0);
}
if mit_tot && x == "POST_ANTE" {
let a = c(h["amount"].as_f64()?);
if h["splash"] == true {
haus += a;
} else {
tot[s] += a;
drin[s] += a;
}
continue;
}
if mit_tot && x == "POST_BB" && bb_gesehen {
let t = c(h["amount"].as_f64()?);
if t > 100 {
return None; // Straddle: spielt der Motor
}
nachpost[s] = t;
drin[s] += t - auf[s];
auf[s] = t;
hoch = hoch.max(t);
continue;
}
bb_gesehen |= x == "POST_BB";
let topf_vor: i64 = drin.iter().sum();
let (auf_vor, hoch_vor) = (auf[s], hoch);
let war_rake = strasse == 0 && rake_knoten_von(s, erh_vor, &frei);
@@ -324,7 +372,14 @@ impl Kontext {
let mut start = [0i64; 6];
for s in 0..n {
start[s] = stand[s]? + drin[s];
spieler.push(json!({"seat": s, "stack_start": start[s]}));
let mut p = json!({"seat": s, "stack_start": start[s]});
if tot[s] > 0 {
p["dead"] = json!(tot[s]);
}
if nachpost[s] > 0 {
p["live_post"] = json!(nachpost[s]);
}
spieler.push(p);
}
// die erste fremde Flop-Groesse, die nicht den ganzen Stapel setzt; ab dort spielt (mit MOTOR_HYB_FLOP_SUCHE) der Motor
let erst_fremd = fremd_kandidat.iter().find(|&&(s, d, _)| d < start[s]).map(|x| x.2);
@@ -353,8 +408,18 @@ impl Kontext {
}
basis["options"]["track_seed"] = json!(saat32(f));
}
if haus > 0 {
basis["dead_money"] = json!(haus);
}
let vorflop_grund = if haus > 0 || tot.iter().any(|&x| x > 0) {
GRUND_SPLASH
} else if nachpost.iter().any(|&x| x > 0) {
GRUND_NACHPOST
} else {
""
};
let rake_knoten = q["street"] == "PREFLOP" && rake_knoten_von(hs, erh_vor, &frei);
Some(Kontext { basis, hist, brett, zuege, flop_fremd, rake_knoten, flop_cbet })
Some(Kontext { basis, hist, brett, zuege, flop_fremd, rake_knoten, flop_cbet, vorflop_grund })
}
}
@@ -518,7 +583,8 @@ fn frage_roh(v: &Value) -> Option<Value> {
/// Der eigene Zug von SHARINGAN, als Vertragsantwort. None: er weiss keinen (dann spielt der Motor).
pub fn zug(q: &Value, k: &Kontext) -> Option<Value> {
let r = frage(&json!({"op": "act", "req": k.basis}))?;
abbilden(q, &r["response"], String::new())
let grund = if q["street"] == "PREFLOP" { k.vorflop_grund } else { "" };
abbilden(q, &r["response"], grund.to_string())
}
/// Seine Antwort (`response`) als Vertragsantwort zum Zustand `q`; `zusatz` haengt an den Grund.
@@ -1087,3 +1153,94 @@ mod saat_spec {
assert!((400..600).contains(&summe), "oberes Bit nicht gleichverteilt: {summe}");
}
}
#[cfg(test)]
mod splash_spec {
//! MOTOR_SHARINGAN_SPLASH (03.12.): Splash, Antes und Nachposts in seiner Anfrage; Straddle bleibt beim Motor.
use super::Kontext;
use serde_json::{json, Value};
fn karte(r: &str, f: &str) -> Value {
json!({"rank": r, "suit": f})
}
/// Sechs Plaetze 1..6, Knopf 1, SB 2, BB 3; bb 0,02; Held am Zug; alle Stapel 2,00 nach den Einsaetzen
fn frage(held: i64, hist: Value) -> Value {
let villains: Vec<Value> = (1..=6).filter(|&s| s != held).map(|s| json!({"seat": s, "stack": 2.0})).collect();
json!({"bigBlind": 0.02, "heroSeat": held, "heroStack": 2.0, "street": "PREFLOP",
"heroCards": [karte("KING", "HEARTS"), karte("FOUR", "HEARTS")], "villains": villains, "history": hist, "seed": 7})
}
fn post(seat: i64, a: &str, x: f64) -> Value {
json!({"street": "PREFLOP", "seat": seat, "action": a, "amount": x})
}
fn zug(seat: i64, a: &str) -> Value {
json!({"street": "PREFLOP", "seat": seat, "action": a})
}
fn splash_frage() -> Value {
let mut ante = post(1, "POST_ANTE", 0.04);
ante["splash"] = json!(true);
frage(1, json!([ante, post(2, "POST_SB", 0.01), post(3, "POST_BB", 0.02), zug(4, "FOLD"), zug(5, "FOLD"), zug(6, "FOLD")]))
}
fn nachpost_frage() -> Value {
let mut c = zug(4, "CALL");
c["amount"] = json!(0.02);
frage(5, json!([post(2, "POST_SB", 0.01), post(3, "POST_BB", 0.02), post(5, "POST_BB", 0.02), c]))
}
#[test]
fn splash_geht_als_hausgeld_an_ihn_und_nicht_in_den_verlauf() {
let k = Kontext::aus_mit(&splash_frage(), true).expect("Splash-Hand mit Schalter");
assert_eq!(k.basis["dead_money"], 200);
let h = k.basis["history"].as_array().unwrap();
assert_eq!(h.len(), 5); // zwei Blinds, drei Folds; der Splash steht nicht im Verlauf
assert!(h.iter().all(|e| e["type"] != "post_ante"));
// der Splash kommt nicht aus dem Stapel des Helden (Platz 1 -> sein Platz 0)
assert_eq!(k.basis["players"][0]["stack_start"], 10_000);
assert!(k.basis["players"].as_array().unwrap().iter().all(|p| p.get("dead").is_none() && p.get("live_post").is_none()));
assert_eq!(k.vorflop_grund, " [Splash: Vorflop-Tabelle ohne totes Geld]");
}
#[test]
fn echte_ante_ist_totes_geld_des_platzes() {
let q = frage(1, json!([post(4, "POST_ANTE", 0.01), post(2, "POST_SB", 0.01), post(3, "POST_BB", 0.02), zug(4, "FOLD"), zug(5, "FOLD"), zug(6, "FOLD")]));
let k = Kontext::aus_mit(&q, true).unwrap();
assert_eq!(k.basis["players"][3]["dead"], 50);
assert_eq!(k.basis["players"][3]["stack_start"], 10_050); // Stapel jetzt + Ante
assert!(k.basis.get("dead_money").is_none());
assert_eq!(k.vorflop_grund, " [Splash: Vorflop-Tabelle ohne totes Geld]");
}
#[test]
fn nachgeposteter_bb_ist_lebender_einsatz_mit_option() {
let k = Kontext::aus_mit(&nachpost_frage(), true).expect("Nachpost mit Schalter");
let p = &k.basis["players"][4]; // Platz 5
assert_eq!(p["live_post"], 100);
assert_eq!(p["stack_start"], 10_100); // Stapel jetzt + Post
let h = k.basis["history"].as_array().unwrap();
assert_eq!(h.len(), 3); // SB, BB, Call; der Nachpost steht nur in players
assert_eq!(h[2]["type"], "call");
assert!(k.basis.get("dead_money").is_none());
assert_eq!(k.vorflop_grund, " [Nachpost: Vorflop-Tabelle ohne Nachpost]");
}
#[test]
fn straddle_bleibt_beim_motor() {
let q = frage(5, json!([post(2, "POST_SB", 0.01), post(3, "POST_BB", 0.02), post(4, "POST_BB", 0.04)]));
assert!(Kontext::aus_mit(&q, true).is_none());
}
#[test]
fn ohne_schalter_wie_bisher() {
assert!(Kontext::aus_mit(&splash_frage(), false).is_none());
assert!(Kontext::aus_mit(&nachpost_frage(), false).is_none());
// eine gewoehnliche Hand ist mit und ohne Schalter dieselbe Anfrage, ohne Zusatzfelder
let q = frage(1, json!([post(2, "POST_SB", 0.01), post(3, "POST_BB", 0.02), zug(4, "FOLD"), zug(5, "FOLD"), zug(6, "FOLD")]));
let (a, b) = (Kontext::aus_mit(&q, false).unwrap(), Kontext::aus_mit(&q, true).unwrap());
assert_eq!(a.basis, b.basis);
assert!(a.basis.get("dead_money").is_none());
assert_eq!(b.vorflop_grund, "");
}
}