#!/usr/bin/env python3 """Nachspiel der 34 Stack-off-Knoten (eigene Haende 15.-18.11., |netto| >= 40 bb, gegen Jam/Raise): Live-Stand 467becde gegen Live + Kandidat. Eingaben ausserhalb des Repos (anfragen.jsonl, knoten.jsonl von der Stack-off-Nachspiel-Aufgabe). python -I -X utf8 messung/stackoff/nachspiel34.py "K=V;K=V" """ import json import os import shutil import sys sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..", "lesen")) import roentgen # noqa: E402 ordner, schalter, exe, arm, aus = sys.argv[1:6] B = os.path.join(os.path.dirname(exe), "pokerbench-stackoff-nachspiel.exe") shutil.copy2(exe, B) kern = roentgen.kern_aufruf(B, timeout_je=60.0, prioritaet=roentgen.BELOW_NORMAL_PRIORITY_CLASS) live = roentgen.lies_schalter(schalter) kand = dict(live) for kv in filter(None, arm.split(";")): k, v = kv.split("=", 1) kand[k] = v K = [json.loads(z) for z in open(os.path.join(ordner, "knoten.jsonl"), encoding="utf-8")] A = [json.loads(z) for z in open(os.path.join(ordner, "anfragen.jsonl"), encoding="utf-8")] per = {} for a in A: per.setdefault(a["hand"], []).append(a["anfrage"]) anf = [] for k in K: tr = [a for a in per[k["hand"]] if a["street"] == k["strasse"] and abs(a["toCall"] / a["bigBlind"] - k["tc_bb"]) < 0.06 and abs(a["pot"] / a["bigBlind"] - k["pot_bb"]) < 0.06] anf.append(tr[0]) ol, ok = kern(anf, live), kern(anf, kand) def zug(o): d = o.get("decision") or o return (d.get("action") or "?") + (f" {d['size']}" if d.get("size") else "") with open(aus, "w", encoding="utf-8", newline="\n") as f: for k, a, b in zip(K, ol, ok): z = dict(strasse=k["strasse"], art=k["art"], karten=k["karten"], netto=k["netto"], live=zug(a), kandidat=zug(b)) f.write(json.dumps(z) + "\n") print(z["strasse"], z["art"], z["karten"], z["netto"], z["live"], "->", z["kandidat"], "" if z["live"] == z["kandidat"] else " <== anders")