Flop-Sperre: Zaehllauf setz_pass.py (erste Setzentscheidung am Flop zu zweit je Linie, Position, Topfart, Typ) ins Repo

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-02 18:42:52 +01:00
co-authored by Claude Opus 5.5
parent b0414e07d3
commit c8a14100da
+109
View File
@@ -0,0 +1,109 @@
"""Zaehllauf fuer MOTOR_FLOP_SPERRE Scheibe 1b: setzt der Spieler am Flop zu zweit, wenn noch kein Einsatz offen ist?
Nur Summen. Typ wie im Motor (antwort_eichung::typ: ab 30 Haenden, VPIP < 22 % eng, < 45 % mittel, sonst locker).
python3 -I setz_pass.py [dateien] [prozesse] -> setz_pass.pkl
Zaehler ("setz", linie, ip, topfart, typ, aktion, band): linie 1 = C-Bet (er war letzter Erhoeher vorflop), 2 = Stab (der Erhoeher
hat vor ihm gecheckt), 3 = Donk (er zieht vor dem Erhoeher), 4 = ungeraister Topf (keiner erhoehte vorflop). ip = er ist am Flop in
Position. topfart 0/1/2/3 = Erhoehungen vorflop (3 = 3 und mehr). aktion "b" / "x"; band = Einsatz / Topf (wie pool_pass) oder "-".
"""
import collections, gzip, json, multiprocessing as mp, os, pickle, sys, time
D = "/Volumes/Alpha SSD/pokerfreak-daten/gedaechtnis2/hhd"
OUT = "/Volumes/Alpha SSD/pokerfreak-daten/pruefstand/nl2-geldkarte"
TILT = "/Volumes/Alpha SSD/pokerfreak-daten/pruefstand/tilt-geld/tilt_spieler.pkl"
ERLAUBT = set("fcxbr")
TYP = {}
def lade_typen():
d = pickle.load(open(TILT, "rb"))
for pid, o in d.items():
h = sum(a[0] for a in o["b"].values())
v = sum(a[2] for a in o["b"].values())
if h >= 30:
p = v / h
TYP[pid] = 1 if p < 0.22 else (2 if p < 0.45 else 3)
def band(frac):
for g, nme in ((0.25, "a<=25"), (0.40, "b26-40"), (0.60, "c41-60"), (0.80, "d61-80"), (1.10, "e81-110")):
if frac <= g + 1e-9:
return nme
return "f>110"
def datei(pf):
os.nice(15)
C = collections.Counter()
with gzip.open(os.path.join(D, pf), "rt") as f:
for z in f:
try:
d = json.loads(z)
except ValueError:
continue
s, bl, zz = d.get("s"), d.get("bl"), d.get("z")
if not s or not bl or zz is None or d.get("an"):
continue
n = len(s)
if n < 2 or n > 6 or (bl[1] if len(bl) > 1 else 0) <= 0 or any(x for x in bl[2:]):
continue
if any(a not in ERLAUBT or p >= n or sx > 3 for p, sx, a, amt in zz):
continue
comm = list(bl[:n]) + [0.0] * (n - len(bl[:n]))
raus, raises, pfa = set(), 0, None
for p, sx, a, amt in zz:
if sx != 0:
break
if a == "f":
raus.add(p)
elif a in "cbr":
comm[p] = max(comm[p], amt)
if a in "br":
raises, pfa = raises + 1, p
live = sorted(set(range(n)) - raus)
if len(live) != 2:
continue
flop = [(p, a, amt) for p, sx, a, amt in zz if sx == 1]
if not flop:
continue
topf = sum(comm)
# Reihenfolge am Flop: SB (0), BB (1), dann 2..n-1; der kleinere Index zieht zuerst (ausser Position)
oop, ip_ = live[0], live[1]
tart = min(raises, 3)
for i, (p, a, amt) in enumerate(flop):
if a not in "xb":
break
erster = i == 0
if tart == 0:
linie = 4
elif p == pfa:
linie = 1
elif erster:
linie = 3
else:
linie = 2
if not erster and flop[0][1] != "x":
break
typ = TYP.get(s[p]["id"], 0)
C[("setz", linie, p == ip_, tart, typ, a, band(amt / topf) if a == "b" and topf > 0 else "-")] += 1
if a == "b" or i >= 1:
break
return C
if __name__ == "__main__":
nd = int(sys.argv[1]) if len(sys.argv) > 1 else 10 ** 9
npr = int(sys.argv[2]) if len(sys.argv) > 2 else 2
t0 = time.time()
fs = sorted(os.listdir(D))[:nd]
CT = collections.Counter()
with mp.Pool(npr, initializer=lade_typen) as pool:
for k, C in enumerate(pool.imap_unordered(datei, fs), 1):
CT.update(C)
if k % 20 == 0 or k == len(fs):
print(f"{k}/{len(fs)} Dateien, {sum(CT.values())} Entscheidungen, {time.time() - t0:.0f}s", flush=True)
ziel = f"{OUT}/setz_pass{'' if nd >= len(os.listdir(D)) else '_probe'}.pkl"
pickle.dump({"zaehler": dict(CT)}, open(ziel + ".neu", "wb"))
os.replace(ziel + ".neu", ziel)
print("fertig", ziel, f"{time.time() - t0:.0f}s")