Files
pokerfreak/messung/motor/preis_straff/probe.py
T

44 lines
2.9 KiB
Python

"""Grobe Pruefung MOTOR_PREIS_STRAFF: alle Live-Anfragen seit 29.11. mit 'motor preis ... weit ueber dem Baum' (und eine Stichprobe
anderer Anfragen fuer die Aus-Pruefung) durch die neue Exe, Schalter aus und an. Schreibt ergebnis.jsonl (nur anhaengen)."""
import json, os, subprocess, sys, collections
LIVE = "D:/Projects/pokerfreak/.claude/worktrees/engine-lecks-angreifen-de7b88"
HIER = os.path.dirname(os.path.abspath(__file__))
EXE = os.path.join(HIER, "pokerbench-motor-preisstraff.exe")
BASIS = "D:/Projects/pokerfreak/entscheiden/motor/target/pokerbench-motor-schatten.exe"
d = "D:/Projects/pokerfreak/daten/grundstrategie/motor"
ARGS = ["dienst", "sechs100", d, "2000-600-400", "200", d + "/sechs100-v2.bin", "genau", f"hu={d}/hu100-v1.bin,{d}/hu200-v2.bin"]
ueber, andere = [], []
with open(LIVE + "/archiv/lauf/schatten.jsonl", "rb") as f:
for l in f:
if b'"q"' not in l or b"motor" not in l: continue
try: r = json.loads(l)
except Exception: continue
if str(r.get("zeit", "")) < "2026-11-29T21": continue
g = str((r.get("motor") or {}).get("reason") or "")
if "weit ueber dem Baum" in g and g.startswith("motor preis"): ueber.append(r)
elif g.startswith("motor ") and r["q"].get("street") in ("TURN", "RIVER") and len(andere) < 150 and hash(l) % 7 == 0: andere.append(r)
print("ueber dem Baum:", len(ueber), "andere:", len(andere))
def lauf(exe, env_zusatz, faelle):
env = dict(os.environ, **env_zusatz)
p = subprocess.Popen([exe] + ARGS, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, env=env, text=True,
creationflags=0x08000000 | 0x4000)
out = []
for r in faelle:
p.stdin.write(json.dumps(dict(r["q"], seed=r.get("seed") or 1)) + "\n"); p.stdin.flush()
out.append(json.loads(p.stdout.readline()))
p.kill(); return out
basis = lauf(BASIS, {}, ueber + andere)
aus = lauf(EXE, {}, ueber + andere)
an = lauf(EXE, {"MOTOR_PREIS_STRAFF": "1"}, ueber + andere)
gleich_aus = sum(a.get("action") == b.get("action") and a.get("size") == b.get("size") for a, b in zip(basis, aus))
print(f"Aus-Pruefung gegen Live-Exe: {gleich_aus}/{len(basis)} gleich")
w = collections.Counter();
with open(os.path.join(HIER, "ergebnis.jsonl"), "a", encoding="utf-8") as o:
for r, a, b in zip(ueber, aus, an):
w[(a.get("action"), b.get("action"))] += 1
o.write(json.dumps({"hand": r.get("hand"), "street": r["q"].get("street"), "aus": a.get("action"), "an": b.get("action"), "grund_an": b.get("reason")}, ensure_ascii=False) + "\n")
print(r.get("hand"), r["q"].get("street"), a.get("action"), "->", b.get("action"), "|", str(b.get("reason"))[:150])
print("aus->an:", dict(w))
gleich_andere = sum(a.get("action") == b.get("action") and a.get("size") == b.get("size") for a, b in zip(aus[len(ueber):], an[len(ueber):]))
print(f"andere Anfragen, an gegen aus: {gleich_andere}/{len(andere)} gleich")