Files
pokerfreak/messung/stackoff/eigen_replay.py
T
mmintelandClaude Opus 5.5 7a011c63a8 Stack-off: GEGEN_GROSS-Zusaetze river, ab:<r>, allin (River-All-in-Range nur stark); Messung Population, Holdout, GROSS_CALL verworfen
Kandidat GEGEN_GROSS=0.2,river,ab:0.75,allin, aus = bitgleich. Holdout River: Jams +9886 bb [+5607, +14177],
grosse Einsaetze ohne All-in +1317, Raises +44; eigene Haende +0,37 bb/100. Ohne allin verliert der Schalter
an grossen Nicht-All-in-Einsaetzen (-11766). Nicht live.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 20:06:46 +01:00

68 lines
2.6 KiB
Python

#!/usr/bin/env python3
"""Eigen-Replay Turn/River (Haende 15.-18.11.): Live-Stand gegen Live + Kandidat; anders, bb wie gespielt, Latenz.
bb wie gespielt fuer CALL->FOLD: -(netto der Hand + vor der Entscheidung investiert), d. h. was der Call ab hier
brachte; FOLD->CALL ohne aufgedeckte Gegnerhand nicht bewertbar.
python -I -X utf8 messung/stackoff/eigen_replay.py <eigen.jsonl> <anfragen.jsonl> <schalter.txt> <kern.exe> "K=V" <aus.jsonl>
"""
import json
import os
import re
import shutil
import sys
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..", "lesen"))
import roentgen # noqa: E402
eig, anf, sch, exe, arm, aus = sys.argv[1:7]
E = {json.loads(z)["hand"]: json.loads(z) for z in open(eig, encoding="utf-8")}
A = [json.loads(z) for z in open(anf, encoding="utf-8")]
B = os.path.join(os.path.dirname(os.path.abspath(exe)), "pokerbench-stackoff-eigen.exe")
shutil.copy2(exe, B)
kern = roentgen.kern_aufruf(B, timeout_je=60.0, prioritaet=roentgen.BELOW_NORMAL_PRIORITY_CLASS)
live = roentgen.lies_schalter(sch)
kand = dict(live)
for kv in filter(None, arm.split(";")):
k, v = kv.split("=", 1)
kand[k] = v
ol = kern([a["anfrage"] for a in A], live)
ok = kern([a["anfrage"] for a in A], kand)
def art(o):
d = o.get("decision") or o
return (d.get("action") or "?").upper()
def ms(o):
m = re.search(r"(\d+) ms", str((o.get("decision") or o).get("reason") or ""))
return int(m.group(1)) if m else None
anders, summe, ml, mk = [], 0.0, [], []
for a, x, y in zip(A, ol, ok):
r = a["anfrage"]
bb = r["bigBlind"]
if ms(x) is not None:
ml.append(ms(x))
if ms(y) is not None:
mk.append(ms(y))
if art(x) == art(y):
continue
e = E[a["hand"]]
inv = (e["spot"]["heroStack"] - r["heroStack"]) / bb
wert = -(e["netto_bb"] + inv) if (art(x), art(y)) == ("CALL", "FOLD") else None
if wert is not None:
summe += wert
f = r["toCall"] / max(r["pot"] - r["toCall"], 1e-9)
anders.append(dict(strasse=r["street"], quote=round(f, 2), tc_bb=round(r["toCall"] / bb, 1), live=art(x), kandidat=art(y),
netto_bb=e["netto_bb"], bb_wie_gespielt=None if wert is None else round(wert, 1)))
with open(aus, "w", encoding="utf-8", newline="\n") as f:
for z in anders:
f.write(json.dumps(z) + "\n")
for z in anders:
print(z)
med = lambda v: sorted(v)[len(v) // 2] if v else None
print(f"anfragen {len(A)} anders {len(anders)} bb wie gespielt (CALL->FOLD) {summe:+.1f}; ms median live {med(ml)} kand {med(mk)}, "
f"mittel live {sum(ml) / max(len(ml), 1):.0f} kand {sum(mk) / max(len(mk), 1):.0f}")