Kern (Live-Schalter) auf 920 646 echten hhDealer-Vorflop-Spots, kreuzgefittet bepreist, 169-Klassen-Lauf. Praemien-Leck (897 Folds AA-QQ/AK gg All-in: Chart-Restzeile EP vs 3-bet+, open_jam-Preis bei gedeckeltem toCall), zu eng gg kurze 4-/5-Bet-Jams, Jam->Call tief; jamall Feld +20 400 bb ohne Praemien-Folds. Splash 2,3-2,9 % der Haende, Untergrenze >= 3,8 bb/100, Kern rechnet ihn heraus. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
489 lines
20 KiB
Python
489 lines
20 KiB
Python
#!/usr/bin/env python3
|
|
"""Vorflop all-in bis Showdown: welche Linie, wie oft, mit welcher echten Equity gegen welchen Preis.
|
|
|
|
Modellfrei, kein Zwilling. Eine Hand zaehlt, wenn vorflop jemand all-in ist, danach niemand mehr setzt und mindestens
|
|
zwei Spieler zeigen. Je Spieler im Showdown wird seine LETZTE Vorflop-Aktion zur Linie:
|
|
|
|
jam L0 / L1 / L2 / L3+ eigenes All-in als Open (auch Iso ueber Limper) / 3-Bet / 4-Bet / 5-Bet+
|
|
call L1 / L2 / L3 / L4+ Call eines All-ins auf Stufe Open-Jam / 3-Bet-Jam / 4-Bet-Jam / 5-Bet+-Jam
|
|
call kurz Call eines kurzen All-ins (< 20 bb), auf welcher Stufe auch immer
|
|
raise ueber kurz Raise (nicht all-in) ueber einen kurzen All-in, danach handelt keiner mehr
|
|
|
|
Tiefe = effektiv: min(eigener Beitrag, groesster Beitrag eines anderen im Showdown), nach Rueckgabe des Ueberhangs.
|
|
Preis = was die letzte Aktion effektiv nachlegt / Topf, um den der Spieler spielt (bei Jams: Gewinnschwelle, falls
|
|
gecallt; Fold-Equity ist darin NICHT enthalten). Equity = Monte-Carlo gegen die gezeigten Karten der anderen.
|
|
All-in-EV je Vorkommen = Equity x Topf - eigener Beitrag (bb), also ohne Glueck.
|
|
|
|
hhd <zip> <gewinner.pkl> <eigene_ids.txt> <eigener_name.txt> <aus.pkl> [--prozesse 8]
|
|
uns <uns.pkl> <aus.pkl> <shadow.jsonl> ... (unsere Rohlog-Haende, Begruendung aus den Schatten-Logs)
|
|
bericht <hhd.pkl> <uns.pkl-aus> <aus.json>
|
|
|
|
Ausgaben (Hashes, Handnummern) ausserhalb des Repos; ins Repo nur Summen.
|
|
"""
|
|
import collections
|
|
import hashlib
|
|
import io
|
|
import json
|
|
import os
|
|
import pickle
|
|
import random
|
|
import re
|
|
import sys
|
|
import zipfile
|
|
|
|
_HIER = os.path.dirname(os.path.abspath(__file__))
|
|
sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(_HIER)), "entscheiden"))
|
|
import eval7 as E # noqa: E402
|
|
|
|
KURZ = 20.0
|
|
ORD = "23456789TJQKA"
|
|
|
|
|
|
def _bremse():
|
|
try:
|
|
import ctypes
|
|
k = ctypes.windll.kernel32
|
|
k.GetCurrentProcess.restype = ctypes.c_void_p # 64 bit: sonst wird der Pseudo-Handle -1 abgeschnitten
|
|
k.SetPriorityClass.argtypes = [ctypes.c_void_p, ctypes.c_uint]
|
|
k.SetPriorityClass(k.GetCurrentProcess(), 0x4000) # BelowNormal
|
|
except Exception:
|
|
pass
|
|
|
|
|
|
def klasse(c):
|
|
"""['Ah','Kd'] -> 'AKo'."""
|
|
a, b = c[0][0].upper(), c[1][0].upper()
|
|
a, b = ("T" if a == "1" else a), ("T" if b == "1" else b)
|
|
if ORD.index(a) < ORD.index(b):
|
|
a, b = b, a
|
|
if a == b:
|
|
return a + b
|
|
return a + b + ("s" if c[0][-1].lower() == c[1][-1].lower() else "o")
|
|
|
|
|
|
def tiefe_bucket(t):
|
|
return "<20" if t < 20 else "20-40" if t < 40 else "40-80" if t < 80 else ">=80"
|
|
|
|
|
|
def linien(akt, n, commit):
|
|
"""akt = [(idx, art 'c'/'r'/'x'/'f', ziel_bb, allin)] vorflop nach den Blinds; commit = Endbeitrag je idx (bb, nach
|
|
Rueckgabe). -> {idx: (linie, preis_zaehler_vor, ziel)} fuer jeden mit letzter Aktion c/r; plus Hilfswerte."""
|
|
hoch = 1.0
|
|
stufe = 0 # Zahl der Erhoehungen bisher (Open = 1)
|
|
allin_kurz = {}
|
|
letzte = {}
|
|
beitrag_vor = {}
|
|
stand = collections.defaultdict(float)
|
|
for i, art, ziel, allin in akt:
|
|
if art in ("c", "r"):
|
|
vor = stand[i]
|
|
if art == "r" and ziel > hoch + 1e-9:
|
|
lv = stufe
|
|
if allin:
|
|
lin = "jam L%s" % (lv if lv < 3 else "3+")
|
|
else:
|
|
lin = "raise L%s" % (lv if lv < 3 else "3+")
|
|
stufe += 1
|
|
hoch = ziel
|
|
if allin and ziel < KURZ:
|
|
allin_kurz[stufe] = True
|
|
else:
|
|
# Call (auch ALL_IN unter Hoehe = Call fuer weniger)
|
|
lv = stufe
|
|
if lv == 0:
|
|
lin = "limp"
|
|
elif hoch < KURZ:
|
|
lin = "call kurz"
|
|
else:
|
|
lin = "call L%s" % (lv if lv < 4 else "4+")
|
|
letzte[i] = (lin, vor, ziel)
|
|
beitrag_vor[i] = vor
|
|
stand[i] = max(stand[i], min(ziel, commit[i] if commit[i] > 0 else ziel))
|
|
elif art == "f":
|
|
letzte.pop(i, None)
|
|
return letzte
|
|
|
|
|
|
def auswerten(n, blinds, akt, stacks_ende, karten, eq_laeufe=1500, seed=0):
|
|
"""Gemeinsamer Kern: -> Liste je Showdown-Spieler {idx, linie, tiefe, preis, eq, ev_bb, klasse}.
|
|
blinds: Beitrag je idx vor der ersten Aktion; akt wie linien(); karten {idx: ['Ah','Kd']}; stacks_ende: Endbeitrag
|
|
je idx (bb) vor Rueckgabe."""
|
|
roh = list(stacks_ende)
|
|
srt = sorted(roh, reverse=True)
|
|
if len(srt) >= 2 and srt[0] > srt[1]:
|
|
j = roh.index(srt[0])
|
|
roh[j] = srt[1] # Ueberhang zurueck
|
|
commit = roh
|
|
letzte = linien(akt, n, commit)
|
|
im_sd = list(karten)
|
|
aus = []
|
|
for i in im_sd:
|
|
if i not in letzte:
|
|
continue
|
|
lin, vor, ziel = letzte[i]
|
|
if lin.startswith("raise"):
|
|
# Raise ohne All-in, danach handelt keiner mehr: deckt einen All-in; ab 20 bb wirkt es wie ein Jam
|
|
lin = "raise ueber kurz" if min(commit[i], max(commit[j] for j in im_sd if j != i)) < KURZ else "jam" + lin[5:]
|
|
if lin == "limp":
|
|
continue
|
|
andere = [j for j in im_sd if j != i]
|
|
if not andere:
|
|
continue
|
|
ci = commit[i]
|
|
groesster = max(commit[j] for j in andere)
|
|
tiefe = min(ci, groesster)
|
|
topf = sum(min(commit[j], ci) for j in range(n))
|
|
nach = max(0.0, min(ci, ziel) - vor)
|
|
preis = nach / topf if topf > 0 else 0.0
|
|
eq = E.equity_mc(karten[i], [], [karten[j] for j in andere], laeufe=eq_laeufe, seed=seed + i)
|
|
aus.append({"idx": i, "linie": lin, "tiefe": tiefe, "preis": preis, "eq": eq, "topf": topf, "commit": ci,
|
|
"ev_bb": eq * topf - ci, "nach": nach, "klasse": klasse(karten[i]), "multi": len(andere) > 1})
|
|
return aus
|
|
|
|
|
|
# ---------------------------------------------------------------- hhDealer
|
|
B = r"₮([\d.,]+)"
|
|
RE_KOPF = re.compile(r"^CoinPoker Hand #(\d+): Hold'em No Limit \(₮([\d.]+)/₮([\d.]+)(?: - Ante ₮([\d.]+))?.*?\) - (\d{4})/(\d{2})/(\d{2})")
|
|
RE_KNOPF = re.compile(r"Seat #(\d+) is the button")
|
|
RE_SITZ = re.compile(r"^Seat (\d+): (.+) \(" + B + r" in chips")
|
|
RE_AKT = re.compile(r"^(.+?): (posts small blind|posts big blind|posts|calls|bets|raises|checks|folds)(?: " + B + r")?(?: to " + B + r")?")
|
|
RE_ZEIGT = re.compile(r"^(.+?): shows \[(\S\S) (\S\S)\]")
|
|
RE_ZURUECK = re.compile(r"^Uncalled bet \(" + B + r"\) returned to (.+)$")
|
|
|
|
|
|
def zahl(s):
|
|
return float(s.replace(",", "")) if s else 0.0
|
|
|
|
|
|
def kenn(nm):
|
|
return int.from_bytes(hashlib.sha1(nm.encode("utf-8")).digest()[:8], "little", signed=True)
|
|
|
|
|
|
def hhd_hand(blk):
|
|
"""-> (tag, [name je idx], n, events) oder None. Nur Haende mit Vorflop-All-in bis Showdown liefern events;
|
|
sonst (tag, namen, n, None) fuer die Zaehlung."""
|
|
z = [x.rstrip("\r") for x in blk.strip().splitlines()]
|
|
m = RE_KOPF.match(z[0])
|
|
if not m or abs(float(m.group(3)) - 0.02) > 1e-9 or m.group(4):
|
|
return None
|
|
import calendar
|
|
tag = calendar.timegm((int(m.group(5)), int(m.group(6)), int(m.group(7)), 0, 0, 0, 0, 0, 0)) // 86400
|
|
knopf, sitze, k = None, {}, 1
|
|
for k in range(1, len(z)):
|
|
mk = RE_KNOPF.search(z[k])
|
|
if mk:
|
|
knopf = int(mk.group(1))
|
|
ms = RE_SITZ.match(z[k])
|
|
if ms:
|
|
sitze[ms.group(2)] = (int(ms.group(1)), zahl(ms.group(3)))
|
|
elif z[k].startswith("*** HOLE CARDS"):
|
|
break
|
|
if knopf is None or len(sitze) < 2:
|
|
return None
|
|
aktiv, sb = set(), None
|
|
for x in z[1:]:
|
|
a = RE_AKT.match(x)
|
|
if a and a.group(1) in sitze:
|
|
aktiv.add(a.group(1))
|
|
if a.group(2) == "posts small blind" and sb is None:
|
|
sb = a.group(1)
|
|
sitze = {nm: v for nm, v in sitze.items() if nm in aktiv}
|
|
if sb is None or not 2 <= len(sitze) <= 6:
|
|
return None
|
|
nach = sorted(sitze, key=lambda nm: (sitze[nm][0] - knopf - 1) % 10)
|
|
nach = nach[nach.index(sb):] + nach[:nach.index(sb)]
|
|
n = len(nach)
|
|
pos = {nm: i for i, nm in enumerate(nach)}
|
|
pre = blk.split("*** FLOP")[0]
|
|
if "is all-in" not in pre or "*** SHOW DOWN" not in blk:
|
|
return tag, nach, n, None
|
|
nachflop = blk.split("*** FLOP", 1)[1].split("*** SHOW DOWN")[0] if "*** FLOP" in blk else ""
|
|
if re.search(r": (bets|checks|calls|raises|folds)", nachflop):
|
|
return tag, nach, n, None
|
|
bb = 0.02
|
|
blinds = [0.0] * n
|
|
beitrag = [0.0] * n
|
|
akt = []
|
|
karten = {}
|
|
s = 0
|
|
for x in z[1:]:
|
|
if x.startswith("*** FLOP"):
|
|
s = 1
|
|
if x.startswith("*** SUMMARY"):
|
|
break
|
|
mz = RE_ZEIGT.match(x)
|
|
if mz and mz.group(1) in pos:
|
|
karten[pos[mz.group(1)]] = [mz.group(2), mz.group(3)]
|
|
continue
|
|
if s:
|
|
continue
|
|
mr = RE_ZURUECK.match(x)
|
|
if mr:
|
|
continue
|
|
a = RE_AKT.match(x)
|
|
if not a or a.group(1) not in pos:
|
|
continue
|
|
i, was = pos[a.group(1)], a.group(2)
|
|
allin = x.endswith("and is all-in")
|
|
if was.startswith("posts"):
|
|
b = zahl(a.group(3))
|
|
if not akt:
|
|
blinds[i] += b / bb
|
|
beitrag[i] += b / bb
|
|
elif was == "folds":
|
|
akt.append((i, "f", 0.0, False))
|
|
elif was == "checks":
|
|
akt.append((i, "x", 0.0, False))
|
|
elif was == "calls":
|
|
beitrag[i] += zahl(a.group(3)) / bb
|
|
akt.append((i, "c", beitrag[i], allin))
|
|
elif was == "raises":
|
|
beitrag[i] = zahl(a.group(4)) / bb
|
|
akt.append((i, "r", beitrag[i], allin))
|
|
if len(karten) < 2:
|
|
return tag, nach, n, None
|
|
stacks = [sitze[nm][1] / bb for nm in nach]
|
|
return tag, nach, n, (blinds, akt, beitrag, karten, stacks)
|
|
|
|
|
|
def hhd_teil(args):
|
|
namen, zipf, gew, eigene, ich = args
|
|
_bremse()
|
|
za = zipfile.ZipFile(zipf)
|
|
zaehl = collections.Counter() # Spielerhaende je Gruppe
|
|
ev = []
|
|
for name in namen:
|
|
innen = zipfile.ZipFile(io.BytesIO(za.read(name)))
|
|
for info in innen.infolist():
|
|
text = innen.read(info).decode("utf-8", "replace")
|
|
for blk in re.split(r"\n\s*\n\s*\n", text):
|
|
if not blk.strip().startswith("CoinPoker Hand #") or "straddle" in blk:
|
|
continue
|
|
nr = blk.strip()[len("CoinPoker Hand #"):].split(":")[0]
|
|
if nr in eigene:
|
|
continue
|
|
try:
|
|
r = hhd_hand(blk)
|
|
except (ValueError, IndexError, KeyError):
|
|
r = None
|
|
if not r:
|
|
continue
|
|
tag, nach, n, d = r
|
|
hf = tag % 2
|
|
gruppen = []
|
|
vers = [((kenn(nm) >> 13) % 10) < 3 for nm in nach]
|
|
for nm in nach:
|
|
if nm == ich:
|
|
gruppen.append(None)
|
|
continue
|
|
g = "gew" if (kenn(nm), 1 - hf) in gew else "feld"
|
|
gruppen.append(g)
|
|
zaehl[g] += 1
|
|
zaehl["n%d_%s" % (n, g)] += 1
|
|
if d is None:
|
|
continue
|
|
blinds, akt, beitrag, karten, stacks = d
|
|
try:
|
|
res = auswerten(n, blinds, akt, beitrag, karten, eq_laeufe=600, seed=int(nr) % 100000)
|
|
except Exception:
|
|
zaehl["fehler"] += 1
|
|
continue
|
|
for e in res:
|
|
g = gruppen[e["idx"]]
|
|
if g is None:
|
|
continue
|
|
e["gruppe"] = g
|
|
e["n"] = n
|
|
e["pos"] = e["idx"]
|
|
e["stack"] = stacks[e["idx"]]
|
|
e["hf"] = hf
|
|
e["vers"] = vers[e["idx"]]
|
|
e["pos_n"] = (e["idx"], n)
|
|
ev.append(e)
|
|
return zaehl, ev
|
|
|
|
|
|
def hhd(args):
|
|
import multiprocessing as mp
|
|
zipf, gewf, eigf, ichf, aus = args[:5]
|
|
pr = int(args[args.index("--prozesse") + 1]) if "--prozesse" in args else 8
|
|
_bremse()
|
|
gew = pickle.load(open(gewf, "rb"))["gew"]
|
|
eigene = set(open(eigf, encoding="utf-8").read().split())
|
|
ich = open(ichf, encoding="utf-8").read().strip()
|
|
namen = sorted(i.filename for i in zipfile.ZipFile(zipf).infolist())
|
|
k = pr * 4
|
|
stuecke = [(namen[j::k], zipf, gew, eigene, ich) for j in range(k)]
|
|
zaehl, ev = collections.Counter(), []
|
|
with mp.Pool(pr, initializer=_bremse) as pool:
|
|
for j, (z, e) in enumerate(pool.imap_unordered(hhd_teil, stuecke)):
|
|
zaehl.update(z)
|
|
ev.extend(e)
|
|
print("%d/%d ereignisse %d %s" % (j + 1, k, len(ev), dict(zaehl)), flush=True)
|
|
pickle.dump({"zaehl": dict(zaehl), "ev": ev}, open(aus, "wb"))
|
|
|
|
|
|
# ---------------------------------------------------------------- unsere Haende
|
|
def teil_von(grund):
|
|
g = grund or ""
|
|
for key, name in (("jamread", "VORFLOP_POP jamread"), ("vs4bet", "VORFLOP_POP vs4bet"), ("bluff4", "VORFLOP_POP bluff4"),
|
|
("notweg", "VORFLOP_POP notweg"), ("Open-Jam", "OPEN_JAM"), ("open_jam", "OPEN_JAM"),
|
|
("open jam", "OPEN_JAM"), ("Push", "OPEN_JAM/Push-Fold"), ("push", "OPEN_JAM/Push-Fold"),
|
|
("VORFLOP_BAND", "VORFLOP_BAND"), ("Band", "VORFLOP_BAND"), ("CFR Teilspiel", "CFR-Teilspiel"),
|
|
("CFR", "CFR"), ("Regel", "Regeln"), ("Notbremse", "Notbremse")):
|
|
if key in g:
|
|
return name
|
|
return "sonst: " + g[:60]
|
|
|
|
|
|
def uns(args):
|
|
unsf, aus, logs = args[0], args[1], args[2:]
|
|
_bremse()
|
|
d = pickle.load(open(unsf, "rb"))
|
|
U, R = d["uns"], d["roh"]
|
|
gruende = {}
|
|
for f in logs:
|
|
for z in open(f, encoding="utf-8"):
|
|
if '"PREFLOP"' not in z or '"antwort"' not in z:
|
|
continue
|
|
x = json.loads(z)
|
|
a = x.get("anfrage") or {}
|
|
if a.get("street") != "PREFLOP" or not x.get("antwort"):
|
|
continue
|
|
hid = (x.get("kurz") or "").split(" ")[0]
|
|
gruende.setdefault(hid, []).append({"aktion": x["antwort"].get("action"), "grund": x["antwort"].get("reason", ""),
|
|
"toCall": a.get("toCall"), "heroStack": a.get("heroStack"),
|
|
"bb": a.get("bigBlind")})
|
|
zaehl = collections.Counter()
|
|
ev = []
|
|
for hid, u in U.items():
|
|
tag = u["zeit"][:10]
|
|
zaehl["alle"] += 1
|
|
zaehl[tag] += 1
|
|
r = R.get(hid)
|
|
if r is None:
|
|
continue
|
|
zaehl["mit_verlauf"] += 1
|
|
bb = float(u["bb"])
|
|
v = r["verlauf"]
|
|
sitze = []
|
|
for h in v:
|
|
if h["seat"] not in sitze:
|
|
sitze.append(h["seat"])
|
|
held = next((s for s, nm in r["namen"].items() if nm == u["spieler"]), None)
|
|
if held is None:
|
|
continue
|
|
held = int(held)
|
|
pre = [h for h in v if h["street"] == "PREFLOP"]
|
|
post = [h for h in v if h["street"] != "PREFLOP"]
|
|
if not any(h["action"] == "ALL_IN" for h in pre) or post or len(r["aufgedeckt"]) < 2:
|
|
continue
|
|
# Reihenfolge: SB zuerst
|
|
sb = next((h["seat"] for h in pre if h["action"] == "POST_SB"), None)
|
|
if sb is None:
|
|
continue
|
|
idx = {}
|
|
for h in pre:
|
|
if h["seat"] not in idx:
|
|
idx[h["seat"]] = len(idx)
|
|
n = max(len(idx), len(r["namen"]))
|
|
blinds = [0.0] * n
|
|
beitrag = [0.0] * n
|
|
akt = []
|
|
hoch = 0.0
|
|
for h in pre:
|
|
i = idx[h["seat"]]
|
|
a = h["action"]
|
|
amt = float(h.get("amount") or 0) / bb
|
|
if a in ("POST_SB", "POST_BB", "POST"):
|
|
blinds[i] += amt if not akt else 0
|
|
beitrag[i] = max(beitrag[i], amt)
|
|
hoch = max(hoch, amt)
|
|
elif a == "FOLD":
|
|
akt.append((i, "f", 0.0, False))
|
|
elif a == "CHECK":
|
|
akt.append((i, "x", 0.0, False))
|
|
elif a == "CALL":
|
|
beitrag[i] = max(beitrag[i], amt)
|
|
akt.append((i, "c", beitrag[i], False))
|
|
elif a in ("RAISE", "BET"):
|
|
beitrag[i] = amt
|
|
hoch = max(hoch, amt)
|
|
akt.append((i, "r", amt, False))
|
|
elif a == "ALL_IN":
|
|
beitrag[i] = max(beitrag[i], amt)
|
|
if amt > hoch + 1e-9:
|
|
hoch = amt
|
|
akt.append((i, "r", amt, True))
|
|
else:
|
|
akt.append((i, "c", amt, True))
|
|
karten = {idx[int(s)]: c for s, c in r["aufgedeckt"].items() if int(s) in idx}
|
|
if held not in idx or idx[held] not in karten:
|
|
continue
|
|
res = auswerten(n, blinds, akt, beitrag, karten, eq_laeufe=6000, seed=int(hid) % 100000)
|
|
for e in res:
|
|
if e["idx"] != idx[held]:
|
|
continue
|
|
g = gruende.get(hid, [])
|
|
letzte = g[-1] if g else None
|
|
luck = sum((u.get("aivat") or {}).values())
|
|
e.update({"tag": tag, "netto_bb": u["netto"] / bb, "ev_aivat_bb": u["netto"] / bb - luck,
|
|
"grund": letzte["grund"] if letzte else None, "teil": teil_von(letzte["grund"]) if letzte else "ohne Log",
|
|
"kern_aktion": letzte["aktion"] if letzte else None, "n": n, "hand": hid})
|
|
ev.append(e)
|
|
pickle.dump({"zaehl": dict(zaehl), "ev": ev}, open(aus, "wb"))
|
|
print(dict(zaehl), len(ev))
|
|
for e in sorted(ev, key=lambda e: e["tag"]):
|
|
if e["tag"] == "2026-11-22":
|
|
print(e["linie"], tiefe_bucket(e["tiefe"]), e["klasse"], "eq %.2f preis %.2f" % (e["eq"], e["preis"]), e["teil"],
|
|
(e["grund"] or "")[:110])
|
|
|
|
|
|
# ---------------------------------------------------------------- Summen (ins Repo)
|
|
def bericht(args):
|
|
hhdf, unsf, aus = args[:3]
|
|
H = pickle.load(open(hhdf, "rb"))
|
|
U = pickle.load(open(unsf, "rb"))
|
|
n_haende = {"uns": U["zaehl"]["mit_verlauf"], "uns_22": U["zaehl"].get("2026-11-22", 0),
|
|
"gew": H["zaehl"]["gew"], "feld": H["zaehl"]["feld"]}
|
|
praemie = {"AA", "KK", "QQ", "AKs", "AKo"}
|
|
|
|
def summe(ev, N):
|
|
if not ev:
|
|
return {"n": 0, "je_100_haende": 0.0}
|
|
n = len(ev)
|
|
return {"n": n, "je_100_haende": round(100 * n / N, 4), "equity": round(sum(e["eq"] for e in ev) / n, 3),
|
|
"preis": round(sum(e["preis"] for e in ev) / n, 3),
|
|
"allin_ev_bb": round(sum(e["ev_bb"] for e in ev) / n, 2),
|
|
"anteil_qq_ak": round(sum(e["klasse"] in praemie for e in ev) / n, 3)}
|
|
|
|
out = {"haende": n_haende, "linien": {}, "linien_tiefe": {}, "teile_uns": {}}
|
|
for name, kf in (("linien", lambda e: e["linie"]), ("linien_tiefe", lambda e: e["linie"] + " | " + tiefe_bucket(e["tiefe"]))):
|
|
keys = sorted({kf(e) for e in H["ev"]} | {kf(e) for e in U["ev"]})
|
|
for k in keys:
|
|
out[name][k] = {
|
|
"uns": summe([e for e in U["ev"] if kf(e) == k], n_haende["uns"]),
|
|
"uns_22": summe([e for e in U["ev"] if kf(e) == k and e["tag"] == "2026-11-22"], n_haende["uns_22"]),
|
|
"gewinner": summe([e for e in H["ev"] if e["gruppe"] == "gew" and kf(e) == k], n_haende["gew"]),
|
|
"feld": summe([e for e in H["ev"] if e["gruppe"] == "feld" and kf(e) == k], n_haende["feld"])}
|
|
out["gesamt"] = {"uns": summe(U["ev"], n_haende["uns"]),
|
|
"uns_22": summe([e for e in U["ev"] if e["tag"] == "2026-11-22"], n_haende["uns_22"]),
|
|
"gewinner": summe([e for e in H["ev"] if e["gruppe"] == "gew"], n_haende["gew"]),
|
|
"feld": summe([e for e in H["ev"] if e["gruppe"] == "feld"], n_haende["feld"])}
|
|
t = collections.Counter()
|
|
for e in U["ev"]:
|
|
g = e["grund"] or ""
|
|
teil = ("ohne Log (15.-19.11.)" if e["grund"] is None else "CFR-Teilspiel" if "CFR" in g
|
|
else "Preis-Kurve allin_call_cutoff" if "vs all-in, call top" in g
|
|
else "Chart vs 3-bet+ (full_row)" if "vs 3-bet+, call top" in g else "sonst")
|
|
t[teil + " | " + e["linie"]] += 1
|
|
out["teile_uns"] = dict(sorted(t.items()))
|
|
with open(aus, "w", encoding="utf-8", newline="\n") as f:
|
|
json.dump(out, f, ensure_ascii=False, indent=1)
|
|
print(json.dumps(out["gesamt"], ensure_ascii=False))
|
|
print(json.dumps(out["teile_uns"], ensure_ascii=False, indent=0))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
{"hhd": hhd, "uns": uns, "bericht": bericht}[sys.argv[1]](sys.argv[2:])
|