Einzelhaende an den Splash-Dienst: Mischung je Entscheidung mit und ohne totes Geld/Nachpost (J9o Splash20, 98o Nachpost)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-03 16:26:21 +01:00
co-authored by Claude Opus 5.5
parent 683387d287
commit dd6e50167b
@@ -0,0 +1,78 @@
# Einzelne Haende an den Splash-Dienst (03.12., Hauptsession: J9o Splash20, 98o Nachpost): je Entscheidung des Helden seine Mischung
# ({"op":"probs"}) MIT totem Geld / Nachpost und OHNE (dead_money weg, live_post weg). Anfrage wie die Bruecke (Kontext::aus), auch mit Brett.
# python -X utf8 farm_hand_mischung.py <schatten.jsonl> <aus.json> <hand> [<hand> ...] [--port 47135]
import sys; sys.dont_write_bytecode = True
import json, socket
import farm_splash_wuerfel as W
def anfrage(q, mit=True):
bb = q["bigBlind"]; c = lambda x: round(x / bb * 100)
h = q["history"]; held = q["heroSeat"]
sitze = sorted({v["seat"] for v in q["villains"]} | {held} | {x["seat"] for x in h}); pos = {s: i for i, s in enumerate(sitze)}; n = len(sitze)
sb = next(pos[x["seat"]] for x in h if x["action"] == "POST_SB")
haus, tot, nach, drin, auf, hist, bb_da, st = 0, [0] * n, [0] * n, [0] * n, [0] * n, [], False, "PREFLOP"
for x in h:
a, s = x["action"], pos[x["seat"]]
if x.get("street", "PREFLOP") != st:
st, auf = x.get("street"), [0] * n
if a == "POST_ANTE":
if x.get("splash"): haus += c(x["amount"])
else: tot[s] += c(x["amount"]); drin[s] += c(x["amount"])
continue
if a == "POST_BB" and bb_da:
t = c(x["amount"]); nach[s] = t; drin[s] += t - auf[s]; auf[s] = t; continue
bb_da |= a == "POST_BB"
typ = {"POST_SB": "post_sb", "POST_BB": "post_bb", "FOLD": "fold", "CHECK": "check", "CALL": "call", "BET": "bet", "RAISE": "raise", "ALL_IN": "all_in"}[a]
e = {"seat": s, "type": typ}
if a in ("POST_SB", "POST_BB", "BET", "RAISE", "ALL_IN", "CALL") and x.get("amount") is not None:
t = c(x["amount"]); drin[s] += t - auf[s]; auf[s] = t
if a != "CALL": e["to"] = t
hist.append(e)
stand = {pos[held]: c(q["heroStack"])}
for v in q["villains"]:
stand[pos[v["seat"]]] = c(v["stack"])
spieler = []
for s in range(n):
p = {"seat": s, "stack_start": stand[s] + drin[s]}
if mit and tot[s]: p["dead"] = tot[s]
if mit and nach[s]: p["live_post"] = nach[s]
elif not mit and nach[s]: p["stack_start"] -= 0 # ohne Nachpost: der Post bleibt im Stapel (Platz hat dann nichts gesetzt)
spieler.append(p)
brett = [W.karte(k) for s_ in ("FLOP", "TURN", "RIVER") for k in (q.get("board") or {}).get(s_, [])]
r = {"small_blind": 50, "big_blind": 100, "button_seat": sb if n == 2 else (sb + n - 1) % n, "hero_seat": pos[held],
"hole_cards": [W.karte(k) for k in q["heroCards"]], "board": brett, "players": spieler, "history": hist, "options": {"seed": 1, "include_probs": False}}
if mit and haus: r["dead_money"] = haus
return r
def main():
a = sys.argv[1:]; port = 47135
if "--port" in a:
i = a.index("--port"); port = int(a[i + 1]); a = a[:i] + a[i + 2:]
pfad, aus, haende = a[0], a[1], set(a[2:])
s = socket.create_connection(("127.0.0.1", port), timeout=60); f = s.makefile("rw", encoding="utf-8")
def frage(v):
f.write(json.dumps(v) + "\n"); f.flush(); return json.loads(f.readline())
erg = []
for z in open(pfad, encoding="utf-8", errors="replace"):
if not any(h in z[:400] for h in haende): continue
try: d = json.loads(z)
except Exception: continue
q = d.get("q")
if not q or str(d.get("hand")) not in haende: continue
zeile = {"hand": d["hand"], "street": q["street"], "gespielt": d.get("gespielt"), "motor_grund": str((d.get("motor") or {}).get("reason"))[:120]}
for mit in (True, False):
r = anfrage(q, mit)
# ohne Nachpost: Spieler mit live_post tauchen dann wie ohne Einsatz auf (Abweichung zum echten Tisch, nur zum Vergleich)
p = frage({"op": "probs", "req": r})
zeile["mit" if mit else "ohne"] = {"ok": p.get("ok"), "source": p.get("source"), "fehler": p.get("error"),
"probs": [(x["type"], x.get("to"), round(x["p"], 3)) for x in p.get("probs", [])]}
erg.append(zeile)
json.dump(erg, open(aus, "w", encoding="utf-8"), ensure_ascii=False, indent=1)
for e in erg:
print(json.dumps(e, ensure_ascii=False)[:600])
if __name__ == "__main__":
main()