Im heads-up 3-Bet-Topf wird ein Flop-/Turn-Call ausser Position mit Stack dahinter zum Fold, wenn die Equity unter Break-even + 0,15 liegt. Echte NL2-Spots (Open + 3-Bet, beide Haende offen): Dev +15 746 bb [+8 769, +23 126], Holdout einmal +15 340 [+7 167, +23 596] (tatsaechlicher Ausgang). Pflichtfaelle 35/43, Replay 1 anders, LBR bitgleich, 6-max-Leiter -0,15 +-0,25. MDF-Untergrenze im 3-Bet-Topf schon zu (0 Faelle); Teil band (3-Bettor nach Paarung) gebaut, gemessen, verworfen. Nicht live. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
94 lines
4.2 KiB
Python
94 lines
4.2 KiB
Python
#!/usr/bin/env python3
|
|
"""3-Bet-Topf: Delta-EV der Arme gegen den Bezug (erste Datei), 95 %-Bootstrap über die Setzer (pid_o).
|
|
|
|
Maße (bb, Fold = 0, IPW): `eq` (River echter Ausgang, Flop/Turn Equity ohne Realisierung) und `real` (tatsächliches
|
|
Ergebnis ab dem Spot, wie die Population weiterspielte). Raise zählt als Weiterspielen.
|
|
Filter: alle, Straße, Straße x Rolle (o = Opener, d = 3-Bettor) x Position, ohne All-in.
|
|
|
|
python -I -X utf8 messung/dreibet_topf/boot.py <spots.jsonl> <aus.json> <bezug.jsonl> <arm.jsonl>... [--boot 1000]
|
|
[--sitzhaende N] (Umrechnung in bb/100 Sitz-Hände)
|
|
"""
|
|
import collections
|
|
import json
|
|
import os
|
|
import sys
|
|
|
|
import numpy as np
|
|
|
|
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
|
import population as P # noqa: E402
|
|
|
|
|
|
def filter_von(sp):
|
|
st = ("flop", "turn", "river")[sp["strasse"] - 1]
|
|
rolle = "o" if "db_o" in sp["linien"] else "d"
|
|
pos = "ip" if sp["ip"] else "oop"
|
|
f = ["alle", st, "%s %s/%s" % (st, rolle, pos)]
|
|
if "db_allin" not in sp["linien"]:
|
|
f.append(st + " ohne-allin")
|
|
return f
|
|
|
|
|
|
def main():
|
|
a = sys.argv[1:]
|
|
boot = int(a[a.index("--boot") + 1]) if "--boot" in a else 1000
|
|
sh = float(a[a.index("--sitzhaende") + 1]) if "--sitzhaende" in a else None
|
|
dateien = [x for x in a[2:] if x.endswith(".jsonl")]
|
|
S = [json.loads(z) for z in open(a[0], encoding="utf-8")]
|
|
A = [{json.loads(z)["id"]: str(json.loads(z).get("action") or "").upper() for z in open(d, encoding="utf-8")}
|
|
for d in dateien]
|
|
namen = [os.path.basename(d).split(".")[0].replace("antw-", "") for d in dateien]
|
|
k = len(dateien) - 1
|
|
T = {m: collections.defaultdict(lambda: collections.defaultdict(lambda: np.zeros(k))) for m in ("eq", "real")}
|
|
geaendert = collections.defaultdict(lambda: np.zeros(k))
|
|
anders = collections.Counter()
|
|
for sp in S:
|
|
i = sp["id"]
|
|
if not all(i in x for x in A):
|
|
continue
|
|
weiter = [x[i] in ("CALL", "RAISE", "ALL_IN") for x in A]
|
|
w = sp["w"]
|
|
ev = {"eq": w * P.ev_aktion(sp, "CALL", None), "real": w * sp["real_bb"]}
|
|
for m in ("eq", "real"):
|
|
d = np.array([(weiter[j + 1] - weiter[0]) * ev[m] for j in range(k)], dtype=float)
|
|
for f in filter_von(sp):
|
|
T[m][f][sp["pid_o"]] += d
|
|
for j in range(k):
|
|
if A[j + 1][i] != A[0][i]:
|
|
anders["%s %s->%s" % (namen[j + 1], A[0][i], A[j + 1][i])] += 1
|
|
for f in filter_von(sp):
|
|
geaendert[f][j] += 1
|
|
rng = np.random.default_rng(20261118)
|
|
erg = {"bezug": namen[0], "arme": namen[1:], "anders": dict(anders), "filter": {}}
|
|
zeilen = ["Bezug %s; Delta bb (Summe, IPW), 95 %%-Intervall ueber Setzer; [eq | real]%s" % (
|
|
namen[0], "; bb/100 auf %d Sitz-Haende" % sh if sh else "")]
|
|
for f in sorted(T["eq"]):
|
|
e = {}
|
|
for m in ("eq", "real"):
|
|
mat = np.array(list(T[m][f].values()))
|
|
s = mat.sum(0)
|
|
idx = rng.integers(0, len(mat), size=(boot, len(mat)))
|
|
b = np.stack([mat[j].sum(0) for j in idx])
|
|
lo, hi = np.percentile(b, 2.5, axis=0), np.percentile(b, 97.5, axis=0)
|
|
e[m] = [(round(float(s[j]), 1), round(float(lo[j]), 1), round(float(hi[j]), 1)) for j in range(k)]
|
|
erg["filter"][f] = {namen[j + 1]: {"n_anders": int(geaendert[f][j]), "eq": e["eq"][j], "real": e["real"][j]}
|
|
for j in range(k)}
|
|
z = "%-20s" % f
|
|
for j in range(k):
|
|
q, r = e["eq"][j], e["real"][j]
|
|
z += " %s(%d) eq %+.0f [%+.0f,%+.0f] real %+.0f [%+.0f,%+.0f]" % (
|
|
namen[j + 1], geaendert[f][j], q[0], q[1], q[2], r[0], r[1], r[2])
|
|
zeilen.append(z)
|
|
if sh:
|
|
zeilen.append("bb/100 (alle, real): " + ", ".join(
|
|
"%s %+.3f" % (n, erg["filter"]["alle"][n]["real"][0] * 100 / sh) for n in namen[1:]))
|
|
zeilen.append("Aenderungen: " + ", ".join("%s %d" % kv for kv in sorted(anders.items())))
|
|
text = "\n".join(zeilen)
|
|
print(text)
|
|
json.dump(erg, open(a[1], "w", encoding="utf-8", newline="\n"), indent=1)
|
|
open(a[1].replace(".json", ".txt"), "w", encoding="utf-8", newline="\n").write(text + "\n")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|