Files
pokerfreak/lesen/vorflop/splash_preis.py
T
mmintelandClaude Opus 5.5 39c23f6555 Stack-off-Ranges des Kerns gegen hhDealer-Gewinner, Splash-Preis: Bericht messung/vorflop/STACKOFF-KERN.md, PLAN/STATUS/STAND
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>
2026-11-23 09:25:00 +01:00

166 lines
8.1 KiB
Python

#!/usr/bin/env python3
"""Splash-Haende (totes Geld des Hauses im Topf, CoinPoker 0.01/0.02): was der Kern vorflop tut und was ihn das
mindestens kostet. Nur lesen (Schatten-Logs des Live-Baums), Ausgabe nur Summen.
Der Kern rechnet den Splash wie eine Ante heraus (`advise::pot_without_antes`), Tabellen und CFR spielen also wie ohne
totes Geld. Untergrenzen je Anfrage (bb, ab jetzt, Fold = 0), bewusst vorsichtig:
- Erster im Topf (nur Folds vor uns): Open auf 2,5 bb gewinnt mindestens P(alle folden) x Topf, verliert hoechstens
den Einsatz, wenn jemand weiterspielt (Nachflop-Wert 0 gesetzt). P(alle folden) gegen ein Open je Zahl der
Gegner dahinter aus hhDealer (normale Toepfe ohne Splash; in Splash-Toepfen verteidigt das Feld eher weiter).
- Gegen ein All-in / Call >= 90 % des Stacks: Equity gegen die gezeigte NL2-Jam-Range (Stufe, Tiefe; `jamall`-
Tabelle, normale Toepfe) x Endtopf mit Splash - Call.
- Sonst (Call / Raise ohne All-in): nicht bepreist, nur gezaehlt.
python -I -X utf8 lesen/vorflop/splash_preis.py <hhd.zip> <hhd.pkl> <aus.json> <shadow.jsonl> ...
"""
import collections
import io
import json
import os
import pickle
import re
import sys
import zipfile
_HIER = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, _HIER)
sys.path.insert(0, os.path.join(os.path.dirname(_HIER), "vorflop_population"))
import klassen as K # noqa: E402
import jamall_tabelle as JT # noqa: E402
import stackoff_linien as SL # noqa: E402
BB = 0.02
OPEN = 2.5
RANG = {"ACE": "A", "KING": "K", "QUEEN": "Q", "JACK": "J", "TEN": "T", "NINE": "9", "EIGHT": "8", "SEVEN": "7",
"SIX": "6", "FIVE": "5", "FOUR": "4", "THREE": "3", "TWO": "2"}
FARBE = {"SPADES": "s", "HEARTS": "h", "DIAMONDS": "d", "CLUBS": "c"}
def p_alle_folden(zipf, jede=12):
"""P(alle folden) gegen ein Erst-Open (kein All-in, 2-3,5 bb) je Zahl der Spieler dahinter, jede `jede`-te Tagesdatei."""
za = zipfile.ZipFile(zipf)
z = collections.Counter()
for name in sorted(za.namelist())[::jede]:
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 or "Ante" in blk.split("\n", 1)[0]:
continue
vor = blk.split("*** HOLE CARDS ***", 1)
if len(vor) < 2:
continue
sitze = len(re.findall(r"^Seat \d+: .+ in chips", vor[0], re.M))
zeilen = vor[1].split("*** ")[0].strip().splitlines()
folds = 0
for k, x in enumerate(zeilen):
a = SL.RE_AKT.match(x)
if not a:
continue
if a.group(2) == "folds":
folds += 1
continue
if a.group(2) != "raises" or x.endswith("all-in"):
break
to = SL.zahl(a.group(4)) / BB
if not 2.0 <= to <= 3.5:
break
hinter = sitze - folds - 1
rest = [y for y in zeilen[k + 1:] if SL.RE_AKT.match(y)]
alle_fold = all(SL.RE_AKT.match(y).group(2) == "folds" for y in rest) and len(rest) >= hinter
z[(hinter, "n")] += 1
z[(hinter, "f")] += alle_fold
break
return {h: z[(h, "f")] / z[(h, "n")] for h in range(1, 6) if z[(h, "n")] >= 50}, dict(z)
def karten(req):
return [RANG[c["rank"]] + FARBE[c["suit"]] for c in req["heroCards"]]
def main():
zipf, hhdf, aus, logs = sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4:]
SL._bremse()
pf, roh = p_alle_folden(zipf)
ev = pickle.load(open(hhdf, "rb"))["ev"]
E = JT.equities(JT.zaehler(ev, 0) + JT.zaehler(ev, 1))
gesehen, zeilen = set(), []
for f in logs:
for z in open(f, encoding="utf-8"):
if '"splash"' not in z or '"anfrage"' not in z:
continue
try:
r = json.loads(z)
except ValueError:
continue
a, ant = r.get("anfrage") or {}, r.get("antwort") or {}
if a.get("street") != "PREFLOP":
continue
sp = [h for h in a.get("history", []) if h.get("splash")]
if not sp:
continue
key = json.dumps([a.get("heroCards"), a.get("history"), a.get("heroSeat")], sort_keys=True)
if key in gesehen:
continue
gesehen.add(key)
D = float(sp[0]["amount"]) / BB
pot, tc, st = float(a["pot"]) / BB, float(a["toCall"]) / BB, float(a["heroStack"]) / BB
hist = [h for h in a["history"] if h.get("action") not in ("POST_SB", "POST_BB", "POST_ANTE")]
raises = [h for h in hist if h["action"] in ("RAISE", "ALL_IN", "BET")]
calls = [h for h in hist if h["action"] == "CALL"]
aktion = str(ant.get("action") or "FOLD").upper()
kl = SL.klasse(karten(a))
e = {"D": D, "aktion": aktion, "klasse": kl, "grund": (ant.get("reason") or "")[:70]}
drin = 0.0
for h in a["history"]:
if h.get("seat") == a.get("heroSeat") and not h.get("splash") and h.get("amount") is not None:
drin = max(drin, float(h["amount"]) / BB)
if not raises and not calls:
hinter = sum(1 for v in a.get("villains", []) if not v.get("folded"))
p = pf.get(min(max(hinter, 1), 5))
e["lage"] = "erster im Topf"
e["ev_open_lb"] = p * pot - (1 - p) * (OPEN - drin) if p is not None else None
e["kern_bedauern_lb"] = max(0.0, e["ev_open_lb"]) if aktion == "FOLD" and e["ev_open_lb"] is not None else 0.0
elif tc >= 0.9 * st or any(h["action"] == "ALL_IN" for h in raises):
stufe = len(raises)
zeile = JT.zeile_jam({"linie": "jam L%s" % (stufe - 1 if stufe <= 3 else "3+"), "idx": 1})
eff = min(st + drin, float(raises[-1]["amount"]) / BB)
t = JT.tiefe(eff)
e["lage"] = "gegen All-in"
if t is None or kl is None:
e["ev_call"] = None
else:
eq = float(E[zeile, t, K.id_von_name(kl)])
call = min(tc, st)
endtopf = pot + call
e["ev_call"] = eq * (endtopf - min(0.05 * endtopf, 10.0)) - call
e["kern_bedauern_lb"] = max(0.0, e["ev_call"]) if aktion == "FOLD" and e["ev_call"] is not None else 0.0
else:
e["lage"] = "gegen Raise/Limp (nicht bepreist)"
e["kern_bedauern_lb"] = 0.0
zeilen.append(e)
sto = collections.defaultdict(lambda: collections.Counter())
for e in zeilen:
b = "D<5" if e["D"] < 5 else "D 5-10" if e["D"] < 15 else "D 20-25" if e["D"] < 40 else "D>=50"
c = sto[(e["lage"], b)]
c["n"] += 1
c["fold"] += e["aktion"] == "FOLD"
c["bedauern_lb_bb"] += e["kern_bedauern_lb"]
c["positiv_gefoldet"] += e["kern_bedauern_lb"] > 0
erg = {"p_alle_folden_gegen_open": pf, "p_roh": {"%d %s" % k: v for k, v in roh.items()},
"anfragen": len(zeilen), "summe_bedauern_lb_bb": round(sum(e["kern_bedauern_lb"] for e in zeilen), 1),
"je_lage": {"%s | %s" % k: {kk: (round(vv, 1) if isinstance(vv, float) else vv) for kk, vv in c.items()}
for k, c in sorted(sto.items())},
"groesste": sorted(({k: (round(v, 2) if isinstance(v, float) else v) for k, v in e.items()} for e in zeilen
if e["kern_bedauern_lb"] > 0), key=lambda e: -e["kern_bedauern_lb"])[:15]}
with open(aus, "w", encoding="utf-8", newline="\n") as f:
json.dump(erg, f, ensure_ascii=False, indent=1)
print(json.dumps({k: erg[k] for k in ("p_alle_folden_gegen_open", "anfragen", "summe_bedauern_lb_bb", "je_lage")},
ensure_ascii=False, indent=1))
for e in erg["groesste"]:
print(e)
if __name__ == "__main__":
main()