Files
pokerfreak/messung/preflop/replay.py
T
2026-11-16 00:59:06 +01:00

31 lines
1.7 KiB
Python

"""Replay: echte Preflop-Spots, Live-Kern (aus) gegen PREFLOP_VOLL=1 -- welche Aktionen kippen, in welcher Klasse."""
import json, collections
aus=[json.loads(l) for l in open('messung_preflop/aus_aus.jsonl',encoding='utf-8')]
an=[json.loads(l) for l in open('messung_preflop/aus_an.jsonl',encoding='utf-8')]
rows=[json.loads(l) for l in open('messung_preflop/nachher.jsonl',encoding='utf-8')]
spots=[json.loads(l) for l in open('messung_preflop/spots.jsonl',encoding='utf-8')]
netto={}
for l in open('messung_preflop/haende.jsonl',encoding='utf-8'):
h=json.loads(l)
if h.get('bb'): netto[str(h['hand'])]=h['netto']/h['bb']
def grob(r):
k=r['klasse'].replace(' [all-in]','')
if k.startswith('first-in'): k='first-in'
elif k.startswith('vs open HU-linie'): k='vs open HU-linie'
return k+(' >100bb' if (r.get('tiefe') or 0)>100 else '')
n=collections.Counter(); kipp=collections.Counter(); wege=collections.defaultdict(collections.Counter); bb=collections.defaultdict(float)
gesamt=0
for a,b,r,s in zip(aus,an,rows,spots):
k=grob(r); n[k]+=1
if a['action']!=b['action']:
gesamt+=1; kipp[k]+=1; wege[k][f"{a['action']}->{b['action']}"]+=1; bb[k]+=netto.get(str(s['hand']),0)
print(f"Aktion gekippt: {gesamt}/{len(aus)} = {100*gesamt/len(aus):.1f} %\n")
print("| Klasse | Spots | gekippt | Richtungen | Live BB der Haende (vorher gespielt) |\n|---|---|---|---|---|")
for k,c in sorted(kipp.items(),key=lambda kv:-kv[1]):
w=', '.join(f"{x} {m}" for x,m in wege[k].most_common(4))
print(f"| {k} | {n[k]} | {c} | {w} | {bb[k]:+.1f} |")
tot=collections.Counter()
for k in wege:
for x,m in wege[k].items(): tot[x]+=m
print("\nRichtungen gesamt:", dict(tot.most_common()))