#!/usr/bin/env python3 """Spots, an denen der Setzer auf einer frueheren Strasse einen grossen Einsatz (>= ab Topf) des Callers gecallt hat. python -I -X utf8 messung/stackoff/nach_gross_call.py [--ab 0.75] """ import json import sys SO = {"FLOP": 1, "TURN": 2, "RIVER": 3} def gecallt(sp, ab): r = sp.get("req") or {} hs = r.get("heroSeat") topf, st_cur, quote = 0.0, None, None for x in r.get("history") or []: st = x["street"] if st != st_cur: st_cur, quote = st, None a, b = x["action"], x.get("amount") or 0 if st in SO and a in ("BET", "RAISE", "ALL_IN"): quote = b / max(topf, 1e-9) if x["seat"] == hs else None elif st in SO and a == "CALL" and x["seat"] != hs and quote is not None and quote >= ab and SO[st] < sp["strasse"]: return True topf += b return False if __name__ == "__main__": a = sys.argv[1:] ab = float(a[a.index("--ab") + 1]) if "--ab" in a else 0.75 n = 0 with open(a[1], "w", encoding="utf-8", newline="\n") as o: for z in open(a[0], encoding="utf-8"): if gecallt(json.loads(z), ab): o.write(z) n += 1 print(n)