Files
pokerfreak/messung/pruefstand/bb100.py
T
mmintelandClaude Opus 5.5 6e15a3cb45 Pruefstand: POSTERIOR fluss:10 besteht das Tor (+2,30 bb/100 eigene Haende), Kandidaten TURN_SPIEL_FOLD und BETTOR_GROSS, Tore der Kipp-Schalter
- fluss:<n>: S2 auf Flop/Turn nur aus, solange raiseToBet auf < n Faellen steht (raise_to_bet_n im Profil);
  Pflichtfall 178543200043 (Nit n=17) spielt wieder den Pot-Raise statt Jam; Tor BESTANDEN
- bb100.py: Gewinn je geaenderter Entscheidung auf echten Spots x Haeufigkeit in eigenen Haenden
- TURN_SPIEL_FOLD=heuristik: E3 darf eine Heuristik-Fortsetzung nicht zum Fold machen (OFFEN, holdout +508)
- BETTOR_GROSS=aus: River-Einsaetze ab 0,8 Topf ohne BETTOR-Kurve (Tor laeuft)
- Tore -MDF_UNREAD, -BETTOR, -RAKE_LIVE, -PREFLOP_MIKRO, -TURN_SPIEL; tor_echt: River nach Einsatzgroesse
- Alle neuen Schalter aus = bitgleich (23 120 Anfragen); nichts live geschaltet

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 19:33:22 +01:00

130 lines
5.3 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
"""Gewinn eines Kandidaten in bb/100 UNSERER Hände (nicht als Summe über Population-Spots).
bb/100 = Σ_Richtung n_eigen(Richtung) × Δ je geänderter Entscheidung(Richtung) / eigene Hände × 100
- n_eigen: wie oft der Kandidat in unseren eigenen Kern-Anfragen (Schatten-Logs, echte Live-Reads) anders
entscheidet, je Richtung ("FLOP FOLD->CALL").
- Δ je geänderter Entscheidung: auf echten NL2-Spots (Caller-Sicht, Muck-IPW w), mittlerer EV-Unterschied
Kandidat minus live über die Spots, in denen der Kandidat in dieser Richtung anders entscheidet (bb).
Eigene Richtung ohne passende echte Spots: Mittel derselben Aktionsänderung über alle Straßen, sonst 0 (gemeldet).
- Eigene Hände: verschiedene Hand-Nummern in den Schatten-Logs.
- 95 %-Intervall: Bootstrap über die Erhöher der echten Spots und Poisson auf die eigenen Zählungen.
python -I -X utf8 messung/pruefstand/bb100.py --arm "POSTERIOR=bluff,schutz,beleg,fluss:10" --spots <post-holdout.jsonl> --spots <spots2.holdout.jsonl>@5
"""
import argparse
import collections
import json
import os
import re
import sys
import numpy as np
_HIER = os.path.dirname(os.path.abspath(__file__))
_W = os.path.join(_HIER, "..", "..", "werkzeuge")
sys.path.insert(0, _W)
import tor_echt as T # noqa: E402
KL = T.KL
def eigene_haende(anfragen):
ids = set()
for s in anfragen:
m = re.search(r"\|(\d{9,})\|", s.get("zug") or "")
if m:
ids.add(m.group(1))
return len(ids)
def main(argv=None):
ap = argparse.ArgumentParser()
ap.add_argument("--arm", required=True)
ap.add_argument("--spots", action="append", required=True)
ap.add_argument("--kern", default=os.path.join(T.BAUM, "target", "release", "rechner.exe"))
ap.add_argument("--schalter", default=os.path.join(T.BAUM, "betrieb", "kern_schalter.txt"))
ap.add_argument("--live-wurzel", default=T.LIVE_WURZEL)
ap.add_argument("--prozesse", type=int, default=8)
ap.add_argument("--aus")
a = ap.parse_args(argv)
import population as P
os.makedirs(a.aus or ".", exist_ok=True)
kern = KL.kern_kopie(a.kern, a.aus or ".")
live = KL.lies_schalter(a.schalter)
live.pop("TISCHWAHL", None)
env_arm = T.env_mit(live, T.arm_aenderung(a.arm))
eigen = T.eigene_anfragen(a.live_wurzel)
haende = eigene_haende(eigen)
x = KL.kern_lauf(kern, eigen, live, a.prozesse)
y = KL.kern_lauf(kern, eigen, env_arm, a.prozesse)
n_eigen = collections.Counter()
for s, p, q in zip(eigen, x, y):
pa, qa = KL.art(p, s["req"]), KL.art(q, s["req"])
if pa != qa:
n_eigen["%s %s->%s" % (s["req"].get("street"), pa, qa)] += 1
spots = []
for p in a.spots: # "datei" oder "datei@5" (jede 5. Zeile)
pfad, _, jede = p.partition("@")
spots += T.spots_laden(pfad, int(jede or 1))
x = KL.kern_lauf(kern, spots, live, a.prozesse)
y = KL.kern_lauf(kern, spots, env_arm, a.prozesse)
# je Richtung: Liste (pid_o, w, Δ)
je = collections.defaultdict(list)
for sp, p, q in zip(spots, x, y):
pa, qa = KL.art(p, sp["req"]), KL.art(q, sp["req"])
if pa == qa:
continue
d = P.ev_aktion(sp, q.get("action"), q.get("size")) - P.ev_aktion(sp, p.get("action"), p.get("size"))
st = ("FLOP", "TURN", "RIVER")[sp["strasse"] - 1]
je["%s %s->%s" % (st, pa, qa)].append((sp["pid_o"], sp["w"], d))
def quelle(richtung):
if je.get(richtung):
return je[richtung], richtung
aend = richtung.split(" ", 1)[1]
alle = [t for k, v in je.items() if k.split(" ", 1)[1] == aend for t in v]
return alle, ("alle Straßen " + aend if alle else None)
rng = np.random.default_rng(7)
B = 2000
gesamt = np.zeros(B)
zeilen = []
punkt = 0.0
for richtung, n in n_eigen.most_common():
werte, herkunft = quelle(richtung)
if not werte:
zeilen.append({"richtung": richtung, "n_eigen": n, "delta_je": None, "herkunft": "keine echten Spots (0 gesetzt)"})
continue
pids = collections.defaultdict(list)
for pid, w, d in werte:
pids[pid].append((w, d))
gruppen = [np.array(v) for v in pids.values()]
sw = sum(g[:, 0].sum() for g in gruppen)
mittel = sum((g[:, 0] * g[:, 1]).sum() for g in gruppen) / sw
punkt += n * mittel
gw = np.array([g[:, 0].sum() for g in gruppen])
gwd = np.array([(g[:, 0] * g[:, 1]).sum() for g in gruppen])
idx = rng.integers(0, len(gruppen), size=(B, len(gruppen)))
m_b = gwd[idx].sum(1) / gw[idx].sum(1)
n_b = rng.poisson(n, size=B)
gesamt += n_b * m_b
zeilen.append({"richtung": richtung, "n_eigen": n, "delta_je": round(float(mittel), 3),
"spots": len(werte), "herkunft": herkunft})
f = 100.0 / max(haende, 1)
erg = {"arm": a.arm, "eigene_anfragen": len(eigen), "eigene_haende": haende,
"bb100": round(punkt * f, 3),
"ci95": [round(float(np.percentile(gesamt, 2.5)) * f, 3), round(float(np.percentile(gesamt, 97.5)) * f, 3)],
"richtungen": zeilen}
print(json.dumps(erg, ensure_ascii=False, indent=1))
if a.aus:
json.dump(erg, open(os.path.join(a.aus, "bb100.json"), "w", encoding="utf-8", newline="\n"), ensure_ascii=False, indent=1)
if __name__ == "__main__":
main()