Livelauf v1 30.11.: AsKc Turn-Call gegen All-in-Range bei 41 bb Rest war falsch. Aus-Pruefung gegen eec96654: 600/600 gleich; an: 39/4968 Nachflop-Entscheidungen auf 30.11. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
82 lines
3.5 KiB
Python
82 lines
3.5 KiB
Python
#!/usr/bin/env python3
|
|
"""Grobe Pruefung der Stack-off-Regel auf echten Live-Entscheidungen: jede Nachflop-Antwort gegen einen bis drei Gegner aus schatten.jsonl
|
|
(ab einem Tag) geht, so wie sie gespielt wurde, allein durch nl2::stackoff (Modus nl2_schicht, "nur": "stackoff").
|
|
Ausgabe: Zahl der Entscheidungen, Zahl der Aenderungen je Art, und je Aenderung Hand, Karten, Brett, vorher -> nachher, Ergebnis
|
|
der Hand (netto bb aus haende.jsonl, roh, ohne Glueckskorrektur). Hand-Ebene bleibt ausserhalb des Repos.
|
|
|
|
python -I -X utf8 pruef.py <motor.exe> <ordner> <schatten.jsonl> <haende.jsonl> <ab-zeit> [<bis-zeit>]
|
|
"""
|
|
import collections
|
|
import json
|
|
import os
|
|
import subprocess
|
|
import sys
|
|
|
|
RN = ["TWO", "THREE", "FOUR", "FIVE", "SIX", "SEVEN", "EIGHT", "NINE", "TEN", "JACK", "QUEEN", "KING", "ACE"]
|
|
FA = ["CLUBS", "DIAMONDS", "HEARTS", "SPADES"]
|
|
|
|
|
|
def k(c):
|
|
return "23456789TJQKA"[RN.index(c["rank"])] + "cdhs"[FA.index(c["suit"])]
|
|
|
|
|
|
def main():
|
|
exe, ordner, schatten, haende, ab = sys.argv[1:6]
|
|
bis = sys.argv[6] if len(sys.argv) > 6 else "9999"
|
|
netto = {}
|
|
for z in open(haende, "rb"):
|
|
try:
|
|
h = json.loads(z)
|
|
except ValueError:
|
|
continue
|
|
if h.get("netto") is not None and h.get("bb"):
|
|
netto[str(h.get("hand"))] = h["netto"] / h["bb"]
|
|
F = []
|
|
for z in open(schatten, "rb"):
|
|
if b'"street": "PREFLOP"' in z[:4000] and b'"street": "FLOP"' not in z:
|
|
continue
|
|
try:
|
|
r = json.loads(z)
|
|
except ValueError:
|
|
continue
|
|
if not (ab <= r.get("zeit", "") < bis):
|
|
continue
|
|
q, a = r.get("q") or {}, r.get("motor")
|
|
if not a or q.get("street") not in ("FLOP", "TURN", "RIVER"):
|
|
continue
|
|
if not 1 <= sum(1 for v in q.get("villains", []) if not v.get("folded")) <= 3:
|
|
continue
|
|
F.append(r)
|
|
env = {**os.environ, "MOTOR_STACKOFF": "1"}
|
|
p = subprocess.Popen([exe, "nl2_schicht", ordner], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL,
|
|
env=env, text=True, creationflags=0x08000000 | 0x4000)
|
|
art = collections.Counter()
|
|
aend = []
|
|
for r in F:
|
|
q, a = r["q"], r["motor"]
|
|
p.stdin.write(json.dumps({"q": q, "a": a, "nur": "stackoff"}) + "\n")
|
|
p.stdin.flush()
|
|
b = json.loads(p.stdout.readline())
|
|
art[a.get("action")] += 1
|
|
rund = lambda x: None if x is None else round(x, 6) # noqa: E731
|
|
if (b.get("action"), rund(b.get("size"))) != (a.get("action"), rund(a.get("size"))):
|
|
aend.append((r, a, b))
|
|
p.kill()
|
|
print("Entscheidungen", len(F), dict(art))
|
|
print("Aenderungen", len(aend), dict(collections.Counter(f"{a['action']}->{b['action']}" for _, a, b in aend)))
|
|
s = 0.0
|
|
for r, a, b in aend:
|
|
q = r["q"]
|
|
bb = q["bigBlind"]
|
|
brett = " ".join(k(c) for st in ("FLOP", "TURN", "RIVER") for c in (q.get("board") or {}).get(st, []))
|
|
n = netto.get(str(r["hand"]))
|
|
s += n or 0.0
|
|
print(f"{r['zeit'][5:16]} {''.join(k(c) for c in q['heroCards'])} | {brett} | Topf {q['pot'] / bb:.1f} zu {q['toCall'] / bb:.1f} "
|
|
f"Rest {q['heroStack'] / bb:.1f} | {a['action']} {'' if a.get('size') is None else round(a['size'] / bb, 1)} -> {b['action']} | "
|
|
f"Hand {'?' if n is None else f'{n:+.1f}'} bb | {str(b.get('reason'))[:150]} | vorher: {str(a.get('reason'))[:60]}")
|
|
print(f"Summe der geaenderten Haende (roh, wie gespielt): {s:+.1f} bb")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|