Files
pokerfreak/messung/eichung/tor/absolut.py
T

63 lines
3.0 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env python3
"""Live-Kern gegen das Feld am River ohne Einsatz vor uns, je Zelle (Lage, Rolle, Handklasse).
Delta je Spot = w * (Preis(Kern-Zug) - Preis(echter Zug)), bb/100 der Spielerhaende der Gruppe; dazu Kern absolut
(Summe w * Preis(Kern-Zug)) und Feld absolut (Summe w * Preis(echter Zug)).
python -X utf8 absolut.py [marke=live] -> absolut_<marke>.json + Tafel"""
import sys
sys.dont_write_bytecode = True
import collections, json, os
HIER = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, HIER)
import preis as PR # noqa: E402
import tor # noqa: E402
ROLLE = {"barrel": "Aggressor", "barrel3": "Aggressor", "lead": "Caller", "stab": "Caller", "erst": "ohne", "erst_ip": "ohne"}
def klasse(k):
return "Luft" if k <= 3 else "mittel" if k <= 6 else "Wert"
def main(marke="live"):
R = PR.lade_hhd()
A = tor.antworten(marke)
out = {}
for g in ("feld", "gew"):
T = PR.Tafeln(R, g)
W = T.gewichte(R)
N = PR.BASIS[g]
z = collections.defaultdict(lambda: {"d": [], "kern": 0.0, "feld": 0.0, "w": 0.0, "kipp": 0.0})
for d in R:
w = W.get(d["id"])
if not w or d["a"] not in ("CHECK", "BET"):
continue
e = tor.kern_aktion(d, A.get(d["id"]))
if e is None:
continue
pk = T.preis(d, e[0], d["k"], e[1] or None)
pf = T.preis(d, d["a"], d["k"], d["b"] or None)
h = d["id"].split(".")[0]
kipp = e[0] != d["a"]
for key in ("alle", "IP" if d["ip"] else "OOP", ROLLE.get(d["li"], "?"), klasse(d["k"]),
"%s %s %s" % ("IP" if d["ip"] else "OOP", ROLLE.get(d["li"], "?"), klasse(d["k"])),
"Kern %s" % e[0]):
x = z[key]
x["d"].append((h, w * (pk - pf))); x["kern"] += w * pk; x["feld"] += w * pf; x["w"] += w
x["kipp"] += w * kipp
res = {}
for key, x in z.items():
res[key] = {"delta": 100 * sum(v for _, v in x["d"]) / N, "se": 100 * PR.bootstrap(x["d"]) / N,
"kern": 100 * x["kern"] / N, "feld": 100 * x["feld"] / N, "anteil_je_100": 100 * x["w"] / N,
"kipp_anteil": x["kipp"] / x["w"] if x["w"] else 0}
out[g] = res
print("\n## %s: Live-Kern minus echter Spieler, River ohne Einsatz (bb/100 aller Spielerhaende)" % g)
print("| Zelle | Spots je 100 Haende | Kern absolut | Feld absolut | Kern − Feld | ±SE | anders entschieden |")
for key in sorted(res, key=lambda k: (k != "alle", len(k.split()), k)):
v = res[key]
print("| %s | %.2f | %+.2f | %+.2f | %+.2f | %.2f | %.0f %% |" % (key, v["anteil_je_100"], v["kern"], v["feld"], v["delta"], v["se"], 100 * v["kipp_anteil"]))
json.dump(out, open(os.path.join(HIER, "absolut_%s.json" % marke), "w", encoding="utf-8"), indent=1, ensure_ascii=False)
if __name__ == "__main__":
main(*(sys.argv[1:2] or ["live"]))