116 lines
5.3 KiB
Python
116 lines
5.3 KiB
Python
#!/usr/bin/env python3
|
|
"""Tor `VORFLOP_FIX=splash` auf unseren echten Splash-Anfragen (Schatten-Logs, nur lesen): Kern mit den Live-Schaltern
|
|
gegen den Arm, je gekippter Anfrage die Untergrenze aus `splash_preis.py` (Fold = 0):
|
|
- erster im Topf: Open auf 2,5 bb, P(alle folden) x Topf - (1 - P) x Einsatz (Nachflop-Wert 0);
|
|
- gegen ein All-in: Equity gegen die NL2-Jam-Range (Stufe, Tiefe) x Endtopf mit Splash (Rake 5 %, Deckel 10 bb) - Call.
|
|
Ausgabe nur Summen, Klassen, Splash-Hoehe (keine Gegnerkennung).
|
|
|
|
python -I -X utf8 lesen/vorflop/splash_tor.py <kern.exe> <kern_schalter.txt> <hhd.pkl> <aus.json> <shadow.jsonl> ...
|
|
[--arm "VORFLOP_FIX=splash"] [--prozesse 4]
|
|
"""
|
|
import collections
|
|
import json
|
|
import os
|
|
import pickle
|
|
import sys
|
|
|
|
_HIER = os.path.dirname(os.path.abspath(__file__))
|
|
_BAUM = os.path.dirname(os.path.dirname(_HIER))
|
|
sys.path.insert(0, _HIER)
|
|
sys.path.insert(0, os.path.join(os.path.dirname(_HIER), "vorflop_population"))
|
|
sys.path.insert(0, os.path.join(_BAUM, "werkzeuge"))
|
|
import kippliste as KL # noqa: E402
|
|
import klassen as K # noqa: E402
|
|
import jamall_tabelle as JT # noqa: E402
|
|
import stackoff_linien as SL # noqa: E402
|
|
import splash_preis as SP # noqa: E402
|
|
|
|
BB = 0.02
|
|
P_ALLE = {1: 0.48, 2: 0.42, 3: 0.35, 4: 0.29, 5: 0.25}
|
|
|
|
|
|
def main():
|
|
args = [a for a in sys.argv[1:]]
|
|
arm = args[args.index("--arm") + 1] if "--arm" in args else "VORFLOP_FIX=splash"
|
|
pz = int(args[args.index("--prozesse") + 1]) if "--prozesse" in args else 4
|
|
pos = [a for i, a in enumerate(args) if not a.startswith("--") and (i == 0 or args[i - 1] not in ("--arm", "--prozesse"))]
|
|
kern, schalter, hhdf, aus, logs = pos[0], pos[1], pos[2], pos[3], pos[4:]
|
|
SL._bremse()
|
|
ev = pickle.load(open(hhdf, "rb"))["ev"]
|
|
E = JT.equities(JT.zaehler(ev, 0) + JT.zaehler(ev, 1))
|
|
gesehen, spots = 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 = r.get("anfrage") or {}
|
|
if a.get("street") != "PREFLOP" or not any(h.get("splash") for h in a.get("history", [])):
|
|
continue
|
|
if not a.get("legalActions"):
|
|
continue
|
|
key = json.dumps([a.get("heroCards"), a.get("history"), a.get("heroSeat")], sort_keys=True)
|
|
if key in gesehen:
|
|
continue
|
|
gesehen.add(key)
|
|
req = {k: v for k, v in a.items() if not k.startswith("_")}
|
|
spots.append({"req": req})
|
|
basis = KL.lies_schalter(schalter)
|
|
A = KL.kern_lauf(kern, spots, KL.arm_env(basis, ""), prozesse=pz)
|
|
B = KL.kern_lauf(kern, spots, KL.arm_env(basis, arm), prozesse=pz)
|
|
z = collections.Counter()
|
|
kipps = []
|
|
for s, a, b in zip(spots, A, B):
|
|
r = s["req"]
|
|
ka, kb = KL.art(a, r), KL.art(b, r)
|
|
z["anfragen"] += 1
|
|
if ka == kb:
|
|
continue
|
|
z["%s->%s" % (ka, kb)] += 1
|
|
D = float(next(h for h in r["history"] if h.get("splash"))["amount"]) / BB
|
|
pot, tc, st = float(r["pot"]) / BB, float(r["toCall"]) / BB, float(r["heroStack"]) / BB
|
|
kl = SL.klasse(SP.karten(r))
|
|
hist = [h for h in r["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")]
|
|
drin = max([float(h["amount"]) / BB for h in r["history"]
|
|
if h.get("seat") == r.get("heroSeat") and not h.get("splash") and h.get("amount") is not None] or [0.0])
|
|
wert = None
|
|
if not raises and not [h for h in hist if h["action"] == "CALL"]:
|
|
hinter = sum(1 for v in r.get("villains", []) if not v.get("folded"))
|
|
p = P_ALLE[min(max(hinter, 1), 5)]
|
|
wert = p * pot - (1 - p) * (2.5 - drin)
|
|
lage = "erster im Topf"
|
|
elif 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)
|
|
lage = "gegen All-in"
|
|
if t is not None and kl is not None:
|
|
eq = float(E[zeile, t, K.id_von_name(kl)])
|
|
call = min(tc, st)
|
|
endtopf = pot + call
|
|
wert = eq * (endtopf - min(0.05 * endtopf, 10.0)) - call
|
|
else:
|
|
lage = "sonst"
|
|
delta = None if wert is None else (wert if ka == "FOLD" else -wert)
|
|
z["bepreist"] += delta is not None
|
|
z["untergrenze_bb"] += delta or 0.0
|
|
kipps.append({"D": round(D, 1), "lage": lage, "klasse": kl, "live": ka, "arm": kb,
|
|
"untergrenze_bb": None if delta is None else round(delta, 2),
|
|
"grund": (b.get("reason") or "")[-140:]})
|
|
erg = {"arm": arm, "zaehl": {k: (round(v, 1) if isinstance(v, float) else v) for k, v in z.items()},
|
|
"kipps": sorted(kipps, key=lambda k: -(k["untergrenze_bb"] or 0))}
|
|
with open(aus, "w", encoding="utf-8", newline="\n") as f:
|
|
json.dump(erg, f, ensure_ascii=False, indent=1)
|
|
print(json.dumps(erg["zaehl"], ensure_ascii=False))
|
|
for k in erg["kipps"][:25]:
|
|
print(k)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|