104 lines
4.3 KiB
Python
104 lines
4.3 KiB
Python
#!/usr/bin/env python3
|
|
"""Wer hat wirklich gespielt? Anteil der Entscheidungen je Quelle, je A/B-Arm (30.11.: SHARINGAN lief im Hybrid nur bei 26 % der
|
|
Entscheidungen, ohne dass es jemand sah; dieser Bericht gehoert nach jeden Lauf).
|
|
|
|
Quelle je gespieltem Zug (Feld `grund` in archiv/lauf/zuege.jsonl):
|
|
S-Suche "sharingan search ..."
|
|
S-Blueprint "sharingan blueprint ..." / sonstige "sharingan ..."
|
|
S+Preis "NL2-Stackoff ...; sharingan ..." (MOTOR_REIN_STACKOFF: sein Zug, von der Stack-off-Bepreisung geaendert)
|
|
Rein-Ausfall "[rein-ausfall: ...]" (MOTOR_SHARINGAN_REIN: SHARINGAN-Hand, doch unser Motor; Grund steht dabei)
|
|
Motor alles andere
|
|
Arm einer Hand: der erste Zug mit `ab.arm` A oder B (die Muenze haengt an der Hand). Ohne AB_SPOT steht alles unter "-".
|
|
Gemischt heisst: eine Hand des Arms B, in der ein Zug nicht aus B kam (`nicht_gezogen`, B zu spaet) oder ein Rein-Ausfall war.
|
|
Keine Hand-Ebene in der Ausgabe, nur Zaehlungen.
|
|
|
|
python lesen/arm_anteil.py [zuege.jsonl] [--ab 2026-11-30T23:00]
|
|
"""
|
|
import collections
|
|
import json
|
|
import os
|
|
import sys
|
|
|
|
_WURZEL = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
|
|
|
|
def quelle(grund):
|
|
g = str(grund or "")
|
|
if g.startswith("[rein-ausfall"):
|
|
return "Rein-Ausfall"
|
|
if g.startswith("NL2-Stackoff") and "; sharingan" in g:
|
|
return "S+Preis"
|
|
if g.startswith("sharingan search"):
|
|
return "S-Suche"
|
|
if g.startswith("sharingan"):
|
|
return "S-Blueprint"
|
|
return "Motor"
|
|
|
|
|
|
def lies(pfad, ab):
|
|
haende = collections.OrderedDict()
|
|
for z in open(pfad, "rb"):
|
|
if b'"grund"' not in z:
|
|
continue
|
|
try:
|
|
r = json.loads(z)
|
|
except ValueError:
|
|
continue
|
|
zeit = str(r.get("zeit") or "").replace(" ", "T")
|
|
if ab and zeit < ab:
|
|
continue
|
|
h = haende.setdefault(str(r.get("hand")), {"arm": None, "zuege": []})
|
|
x = r.get("ab") if isinstance(r.get("ab"), dict) else {}
|
|
if h["arm"] is None and x.get("arm") in ("A", "B"):
|
|
h["arm"] = x["arm"]
|
|
h["zuege"].append((r.get("street"), r.get("grund"), x))
|
|
# Quelle erst, wenn der Arm der Hand feststeht: bei gleicher Antwort beider Arme steht in `grund` die Begruendung von A,
|
|
# die von B in ab.b (01.12.: Arm B zeigte so 30 % "Motor", obwohl jeder Zug von SHARINGAN kam)
|
|
for h in haende.values():
|
|
neu = []
|
|
for st, g, x in h["zuege"]:
|
|
if h["arm"] == "B" and isinstance(x.get("b"), dict) and x["b"].get("reason"):
|
|
g = x["b"]["reason"]
|
|
neu.append((st, quelle(g), x.get("art"), str(g or "")))
|
|
h["zuege"] = neu
|
|
return haende
|
|
|
|
|
|
def bericht(haende):
|
|
z = []
|
|
je = collections.defaultdict(collections.Counter)
|
|
gemischt = collections.Counter()
|
|
ausfall = collections.Counter()
|
|
for h in haende.values():
|
|
arm = h["arm"] or "-"
|
|
for st, q, art, g in h["zuege"]:
|
|
je[(arm, st)][q] += 1
|
|
je[(arm, "alle")][q] += 1
|
|
if q == "Rein-Ausfall":
|
|
ausfall[g.split("]", 1)[0][:70]] += 1
|
|
if arm == "B" and any(art == "nicht_gezogen" or q == "Rein-Ausfall" for _, q, art, _ in h["zuege"]):
|
|
gemischt["B"] += 1
|
|
arme = collections.Counter(h["arm"] or "-" for h in haende.values())
|
|
z.append(f"Haende je Arm: {dict(arme)}; Arm-B-Haende gemischt (nicht gezogen oder Rein-Ausfall): {gemischt['B']}")
|
|
quellen = ("S-Suche", "S-Blueprint", "S+Preis", "Motor", "Rein-Ausfall")
|
|
z.append(f"{'Arm':4s} {'Strasse':8s} {'Zuege':>7s} " + " ".join(f"{q:>13s}" for q in quellen))
|
|
for (arm, st) in sorted(je, key=lambda k: (k[0], ("PREFLOP", "FLOP", "TURN", "RIVER", "alle").index(k[1]) if k[1] in ("PREFLOP", "FLOP", "TURN", "RIVER", "alle") else 9)):
|
|
c = je[(arm, st)]
|
|
n = sum(c.values())
|
|
z.append(f"{arm:4s} {str(st):8s} {n:7d} " + " ".join(f"{c[q] / n:13.1%}" for q in quellen))
|
|
if ausfall:
|
|
z.append("Rein-Ausfaelle: " + json.dumps(ausfall.most_common(8), ensure_ascii=False))
|
|
return z
|
|
|
|
|
|
def main():
|
|
a = sys.argv[1:]
|
|
ab = a[a.index("--ab") + 1] if "--ab" in a else None
|
|
pos = [x for i, x in enumerate(a) if not x.startswith("--") and (i == 0 or a[i - 1] != "--ab")]
|
|
pfad = pos[0] if pos else os.path.join(_WURZEL, "archiv", "lauf", "zuege.jsonl")
|
|
print("\n".join(bericht(lies(pfad, ab))))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|