Files
pokerfreak/messung/pruef/jam_allin.py
T

42 lines
1.5 KiB
Python

"""All-in-EV des Jam-Tests (bb/100 +- SE), je Arm und Position."""
import json
import math
import os
import sys
import zlib
HIER = os.path.dirname(os.path.abspath(__file__))
sys.path[:0] = [HIER, os.path.join(HIER, "..", "..", "entscheiden")]
sys.dont_write_bytecode = True
import eval7 # noqa: E402
import slumbot as S # noqa: E402
def st(w):
m = sum(w) / len(w)
return 100 * m, 100 * math.sqrt(sum((x - m) ** 2 for x in w) / (len(w) - 1) / len(w))
for art in ("jam", "chart"):
with open(os.path.join(HIER, "slumbot", "haende-%s.jsonl" % art), encoding="utf-8") as f:
hs = [json.loads(z) for z in f if z.strip()]
ev, n = [], 0
for h in hs:
z = S.zerlege(h["aktion"])
zu = [x for s in z["strassen"] for x in s]
if zu and zu[-1][1] == "c" and max(z["gesamt"]) >= S.STACK and z["st"] < 3:
b = (h["brett"] or [])[: {0: 0, 1: 3, 2: 4}[z["st"]]]
if b:
e = eval7.equity_vs(h["loch"], b, [h["bot"]])
else:
e = eval7.equity_mc(h["loch"], [], [h["bot"]], laeufe=4000,
seed=zlib.crc32(json.dumps(h["loch"] + h["bot"]).encode()))
ev.append((2 * e - 1) * S.STACK / S.BB)
n += 1
else:
ev.append(h["gewinn"] / S.BB)
print(art, len(hs), "All-ins", n, "roh %.0f +-%.0f" % st([h["gewinn"] / S.BB for h in hs]),
"All-in-EV %.0f +-%.0f" % st(ev))
for p, name in ((1, "SB"), (0, "BB")):
print(" ", name, "%.0f +-%.0f" % st([e for e, h in zip(ev, hs) if h["pos"] == p]))