diff --git a/entscheiden/turniermotor.py b/entscheiden/turniermotor.py index 93640ffd..1a648cd8 100644 --- a/entscheiden/turniermotor.py +++ b/entscheiden/turniermotor.py @@ -26,6 +26,33 @@ def zustaendig(q): return bool(q.get("variant") == "NLHE" and (q.get("_turnier") or q.get("tournament")) and q.get("legalActions")) +def blinds_einpassen(q): + """Kurzer Stapel im Blind (30.11.): wer weniger als den Blind hat, steht im Verlauf als ALL_IN statt POST_SB/POST_BB. + Der Motor sah "kein BB", spielte Notfall, der alte Kern hing bis 100 s und die naechste Hand verfiel (Freeroll 2824440, + Haende 35, 38, 64, 65). Erstes ALL_IN vor dem Flop, das hoechstens den fehlenden Blind betraegt, ist der Blind.""" + hist = q.get("history") + if not isinstance(hist, list): + return q + aktionen = [h.get("action") for h in hist if isinstance(h, dict)] + sb_da, bb_da = "POST_SB" in aktionen, "POST_BB" in aktionen + if sb_da and bb_da: + return q + bb, sb = q.get("bigBlind") or 0, q.get("smallBlind") or (q.get("bigBlind") or 0) / 2 + neu, geaendert = [], False + for i, h in enumerate(hist): + if (isinstance(h, dict) and h.get("street") == "PREFLOP" and h.get("action") == "ALL_IN" + and isinstance(h.get("amount"), (int, float)) and bb): + frei = [x for x in hist[:i] if isinstance(x, dict) and x.get("action") not in ("POST_ANTE", "POST_SB", "POST_BB", "POST")] + if not frei and not sb_da and h["amount"] <= sb + 1e-9: + neu.append(dict(h, action="POST_SB")); sb_da = geaendert = True + continue + if not frei and sb_da and not bb_da and h["amount"] <= bb + 1e-9: + neu.append(dict(h, action="POST_BB")); bb_da = geaendert = True + continue + neu.append(h) + return dict(q, history=neu) if geaendert else q + + def einpassen(q, r): """Der Motor rundet Einsaetze auf ganze Chips: ein All-in von 1133 kam als 1135 und wurde verworfen (26.11., sechsmal in der Short-Stack-Phase, dann spielte der alte Kern). Liegt BET/RAISE hoechstens einen halben Big Blind @@ -98,6 +125,7 @@ class Turniermotor(schatten.Schatten): def zug(self, zeile, raum=None, hand=None, frist=None): try: q = json.loads(zeile) + q = blinds_einpassen(q) if self.tot or not zustaendig(q): return None # "bis": _laufen gibt Flop/Turn/River die Restzeit mit (frist_rest_s, z["bis"]); ohne sie KeyError 'bis' bei jeder