Familie A + Bettor-Modell: Tor 17.11., UEBERSCHUSS Live-Kandidat, BETTOR verworfen

Messschalter, ungesetzt bitgleich (basis gg. basisb 0 Deals):
- UEBERSCHUSS=1 (engine/ueberschuss.rs): der ungecallte Teil eines Einsatzes, der den
  Helden all-in setzt, kommt aus dem Topf (einmal gekuerzt, keine Rekursion). Sim bitgleich
  in allen 12 Zellen, 6-max, LBR; Live-Replay 2 All-in-Folds -> kein Verlierer.
- BETTOR=<Tabelle> (exploit/bettor.rs, range_filter): P(Antwort | Brett-Perzentil) je
  Wettknoten aus PHH 8,1 Mio. + NL2. Live-Replay besser (River-Fold klein 77->53 %),
  Sim-Tor Verlierer, auch gegen tabellentreue Gegner -> verworfen.
- GEGEN_GROSS=t: Spitzenschnitt gegen grosse Einsaetze, allein Verlierer.
- SIM_BETTOR=<Tabelle> (sim/bettor_tor.rs): Pool-Gegner setzen nach der Tabelle.

Werkzeuge: bettor.py (mit Muck-Korrektur), replay.py (Live-Replay-Tor, ABSTAIN zaehlt als
Fold), familie_c.py, echtfaelle.py, lesen/phh_linien.py. Zahlen in messung/familie_a/TOR.md,
STAND §22. Keine Gegnerkennung.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 20:06:41 +01:00
co-authored by Claude Opus 5.5
parent 54d3d99aad
commit 0923eca24c
63 changed files with 41219 additions and 16 deletions
+1
View File
@@ -174,6 +174,7 @@ Es bleibt bei Heuristik plus Vetos. Erlaubt sind weiter: Fixes für in echten H
**Stand 16.11.:** `pool-nl2-echt` ist gebaut (e13658fa auf claude/pool-nl2-echt). Er trifft 32 von 40 echten Linien, `pool-nl2` nur 21, Holdout 26 von 31. Die All-in-Linie fehlt noch (Sim 1, echt 3 je 1000 Hände) und wird nachgezogen. POOL_PRIOR misst exploit-live jetzt auch gegen ihn.
**Danach (Owner 16.11.):** Der Gegner führt sich selbst nach. Nach jedem Lauf wird er aus den echten Händen neu geschätzt und als versionierte Datei abgelegt, befördert nur bei besserem Holdout. Jedes Tor nennt seine Version.
- **§8.5 Pool-Ausnutzung ab der ersten Hand** (exploit-live, parallel): Für Ungelesene gilt der Pool-Prior, aber nur auf den passiven Achsen und beim Wertanteil von Raises/Shoves. Tor auch gegen `pool-nl2-echt`. **Stand 17.11.:** `POOL_STUFE=rtb` (NL2-raiseToBet-Anker 0,105 für Ungelesene) besteht das volle Tor inkl. SIM_POOLRUF, ohne Verlierer → **live seit 17.11.** (kern_schalter, Merge auf dem Live-Branch, Pflichtfälle 19/25 wie live); `groesse` (Fold-Kurve über 2/3 Pot) Verlierer, verworfen (STAND §21). Fold-Anker 0,45 passt zu NL2 und bleibt.
- **Familie A / Bettor-Modell (engine-roentgen, 17.11. abends):** Range nach Größe/Linie (`BETTOR`) besteht das Live-Replay teilweise (River-Fold klein 77 → 53 %, Familie C +37 826 bb), verliert aber das Sim-Tor auch gegen nach NL2 nachgeeichte, tabellentreue Gegner (pool-phh −5,34 ±2,02) → verworfen; Engpass ist die Entscheidungsschicht (EV über Folgestraßen), nicht die Lesung. `UEBERSCHUSS=1` (ungecallter Überschuss aus dem Topf) kein Verlierer → Live-Kandidat beim Orchestrator (STAND §22, `messung/familie_a/TOR.md`). Range-Objekt gemeinsam mit gedaechtnis-voll (Kopplung Fold/Call-Range).
- Neuer Anlauf echter Postflop-Spieler (Grundstrategie + Echtzeit-Suche), gemessen auf M6. **16.11. vorgezogen** (Owner: „kein Run mehr, auf echte Weltklasse“): Session postflop-suche baut tiefenbegrenzte sichere Teilspiel-Suche ab dem Flop plus KL-Ausnutzung, Tor LBR S1 < 30, Leiter ohne Verlierer inkl. pool-nl2-echt.
1. **Jetzt:** nächster Micro-Lauf mit `MDF_UNREAD=0` (O2 entschieden). In den Pausen LBR vorher/nachher
+11
View File
@@ -411,3 +411,14 @@ Frage Owner: passt sich die Engine an Limit und Spielertyp an? 86 % der Live-Riv
| alte POOL_PRIOR (−8,48) | Ursache: gepoolter foldToBet 0,554 für jede Straße/Größe statt 0,45, echt foldet der Pool auf unsere Einsätze 0,33–0,47 |
**Live 17.11.:** `POOL_STUFE=rtb` in betrieb/kern_schalter.txt (Merge claude/pool-stufe auf den Live-Branch, Release gebaut, Pflichtfälle 19/25 wie live).
## 22. Nachtrag 17.11. abends: Familie A und Bettor-Modell (Auftrag Orchestrator, engine-roentgen, `messung/familie_a/TOR.md`)
| Was | Ergebnis |
|---|---|
| `BETTOR` (P(Antwort ∣ Brett-Perzentil) je Wettknoten aus PHH 8,1 Mio. + NL2) | Live-Replay (889 Spots): River-Fold klein 77 → 53 %, mittel 89 → 63 %, Pflichtregel erfüllt; Familie C (PHH, bekannte Gegnerhand) +37 826 bb gg. live. Korridor verfehlt: Turn klein 46 % [21,38], Turn mittel 59 % [36,56], River groß 80 % [34,69] |
| Sim-Tor BETTOR | Verlierer überall (Leiter −9,62 ±1,71, pool-phh −5,35 ±1,96, pool-nl2-echt −3,95 ±2,57); mit GEGEN_GROSS schlechter |
| Sim nach NL2 nachgeeicht (`SIM_BETTOR`, Pool-Gegner setzen nach der Tabelle) | **BETTOR verliert auch gegen tabellentreue Gegner** (pool-phh −5,34 ±2,02, echt −4,67 ±3,12); Check-Lesung −2,6 bis −3,2, Einsatz-Lesung −0,9 bis −2,4, nur River-Einsatz −0,79 ±0,67. Nicht die Eichung: die Entscheidungsschicht macht aus der richtigen Range schlechtere Züge → **verworfen**, nächster Hebel Call/Bet-EV über die Folgestraßen |
| Muck-Korrektur der PHH-Tabelle | passive Verlierer decken 39 % (PS) bis 55 % auf, River-Aggressoren fast immer; Tabelle ändert sich wenig, nicht die Ursache |
| **`UEBERSCHUSS=1`** (ungecallter Überschuss eines Einsatzes, der den Helden all-in setzt, aus dem Topf) | Sim bitgleich (0 Deals, 12 Zellen, 6-max, LBR), Live-Replay 2 Änderungen (beide All-in-Folds, Preis korrekt) → **kein Verlierer, Live-Kandidat** |
+1 -1
View File
@@ -44,7 +44,7 @@ BEKANNTE_SCHALTER = ("MDF_UNREAD", "RAISE_DRAWS", "RAISE_PRIOR", "TURN_SPIEL", "
"TURN_RAISE_BLUFF", "TURN_RAISE_NUR", "STATION_POSTFLOP", "POKERINTEL",
"REST_STACK", "FORTSETZUNG", "POOL_PRIOR", "POSTERIOR", "GEGNER_LINIEN",
"PREFLOP_VOLL", "PREFLOP_OHNE_ANTE", "PREFLOP_MIKRO", "PREFLOP_VOLL_TEILE",
"WERT_BRETT", "FLUSS_WERT", "PAAR_RAISE", "BRETT_PAAR", "CALLED_JAM", "ALLIN_TIEFE", "UEBERBET", "CBET_LUFT", "POOL_STUFE",
"WERT_BRETT", "FLUSS_WERT", "PAAR_RAISE", "BRETT_PAAR", "CALLED_JAM", "ALLIN_TIEFE", "UEBERBET", "CBET_LUFT", "POOL_STUFE", "GEGEN_GROSS", "BETTOR", "UEBERSCHUSS",
"TISCHWAHL", "TISCHWAHL_AB", "SITZWAHL")
# Schalter des LAEUFERS (betrieb/runner.py liest sie aus seiner eigenen Umgebung, nicht der Kern): aus der
# Datei auch in os.environ, sonst schaltete ein Eintrag hier nichts. Eine ausdrueckliche Umgebung geht vor.
+639
View File
@@ -0,0 +1,639 @@
#!/usr/bin/env python3
"""Bluff- und Wertanteile je Linie aus echten Showdowns: PHH/HandHQ (Prior) und unsere NL2-Haende.
Jede aggressive Nach-Flop-Aktion eines Spielers in einem Heads-up-Topf ist ein Fall, mit diesem
Schluessel (Format `BLUFF-LINIEN-format-exploit-live.md`):
strasse flop | turn | river
topf limp | srp | 3bet | 4bet (hoechste Vorflop-Erhoehungsstufe)
barrels aufeinanderfolgende Strassen mit eigener Aggression, diese eingeschlossen
groesse k <= 0.40 < m <= 0.80 < g <= 1.20 < u (Bet: Anteil am Topf davor; Raise: Zuschlag
am Topf nach dem Mitgehen, wie linien.stufe)
art bet | raise | allin (PHH kennt keine Stacks: dort nie allin)
pf_aggressor letzter Vorflop-Erhoeher?
position ip | oop
Gezaehlt je Schluessel:
n_alle alle Faelle
n_fold der Gegner foldete sofort (Hand ohne Showdown, die Range bleibt verdeckt)
n Faelle mit aufgedeckter Hand des Setzers
luft davon Luft: Equity gegen eine Zufallshand < 0.40 am Board ZUM ZEITPUNKT des Einsatzes
(River exakt wie zaehler.staerke; Flop/Turn Monte-Carlo ueber Gegnerhand und Rest-Board,
fester Seed je Hand)
wert davon >= 0.80
gemuckt Showdown erreicht, Setzer nicht aufgedeckt (verloren und weggeworfen): obere Schranke fuer
versteckte Luft
n_verl gezeigt und am Showdown verloren (beide Haende bekannt), luft_verl davon Luft: daraus der
Luftanteil der Weggeworfenen (`schaetzen`)
Showdown-Verzerrung (benannt, nicht wegrechenbar):
1. Gefoldete Faelle zeigen nichts. Die Entscheidung des Gegners haengt nicht an den verdeckten Karten
des Setzers, darum ist die gezeigte Haelfte fuer die Wertverteilung DESSELBEN Schluessels fair -
ausser 2. und 3.
2. Flop/Turn: aufgedeckt wird erst am Ende. Ein Flop-Bluff, der spaeter aufgibt und gefoldet wird,
fehlt. Flop-/Turn-Zeilen sind darum wertlastig; der River ist die saubere Zeile.
3. Muck: wer verliert, darf wegwerfen. `gemuckt` zaehlt das; Luft liegt zwischen luft/n und
(luft+gemuckt)/(n+gemuckt).
python -I lesen/phh_linien.py phh <roh> <aus.json> [--teil i/k] [--stufen 25,50] (NL25/50 voll, Rest 1/3)
python -I lesen/phh_linien.py nl2 <haende.jsonl> <aus.json>
python -I lesen/phh_linien.py mischen <aus.json> <teil.json>...
python -I lesen/phh_linien.py prior <phh.json> <nl2.json> <aus.json> [--lam 30] hierarchisch
"""
import json
import os
import random
import re
import struct
import sys
import zlib
_w = os.path.dirname(os.path.abspath(__file__))
_wurzel = os.path.dirname(_w)
for _p in (_w, os.path.join(_wurzel, "entscheiden")):
if _p not in sys.path:
sys.path.insert(0, _p)
import eval7 # noqa: E402
LUFT = 0.40
WERT = 0.80
STR = ("flop", "turn", "river")
MC = 150
MC_RIVER = 300
FELDER = ("n_alle", "n_fold", "n", "luft", "wert", "gemuckt", "n_verl", "luft_verl")
def stufe(f):
return "k" if f <= 0.40 else "m" if f <= 0.80 else "g" if f <= 1.20 else "u"
def topf_art(raises):
return ("limp", "srp", "3bet")[raises] if raises < 3 else "4bet"
# --- Staerke: Equity gegen eine Zufallshand am Board des Einsatzes ---
def staerke(loch, board, seed=0, laeufe=None):
"""Equity von `loch` gegen eine Zufallshand am Board `board` (3-5 Karten, eval7), Monte-Carlo mit
festem Seed: River MC_RIVER Laeufe (Fehler ~0.03 an der Luftschwelle), Flop/Turn MC Laeufe ueber
Gegnerhand und Rest-Board. `laeufe=0` rechnet den River exakt wie zaehler.staerke."""
weg = set(loch) | set(board)
rest = [c for c in eval7.VOLLDECK if c not in weg]
won = 0.0
if len(board) == 5 and laeufe == 0:
import itertools
b = list(board)
eigen = eval7.score7(list(loch) + b)
n = 0
for v in itertools.combinations(rest, 2):
g = eval7.score7(list(v) + b)
won += 1.0 if eigen > g else 0.5 if eigen == g else 0.0
n += 1
return won / n
rng = random.Random(seed)
fehlt = 5 - len(board)
if laeufe is None:
laeufe = MC_RIVER if fehlt == 0 else MC
if fehlt == 0:
b = list(board)
eigen = eval7.score7(list(loch) + b)
for _ in range(laeufe):
g = eval7.score7(rng.sample(rest, 2) + b)
won += 1.0 if eigen > g else 0.5 if eigen == g else 0.0
return won / laeufe
for _ in range(laeufe):
z = rng.sample(rest, 2 + fehlt)
voll = list(board) + z[2:]
a, g = eval7.score7(list(loch) + voll), eval7.score7(z[:2] + voll)
won += 1.0 if a > g else 0.5 if a == g else 0.0
return won / laeufe
# --- eine Hand in gemeinsamer Form ---
# hand = {"n": Spielerzahl, "blinds": [je Spieler], "akt": [(strasse 0..3, spieler, art, betrag_bis)],
# "board": [Karten je Strasse kumuliert, eval7], "gezeigt": {spieler: [2 Karten]},
# "showdown": bool, "allin": set((strasse, spieler, index))}
# art: "f" | "c" (check/call) | "r" (bet/raise auf betrag_bis, Strassen-Summe des Spielers)
# Postflop-Reihenfolge: hoeherer Index = spaeter = in Position (PHH: p1 SB, p2 BB, ... Knopf zuletzt);
# heads-up ist der SB (Index 0) der Knopf und in Position.
def faelle(hand, seed=0):
"""[(schluessel, {feld: zahl})] aller aggressiven Heads-up-Nach-Flop-Aktionen der Hand."""
n = hand["n"]
beitrag = list(hand["blinds"])
topf_vor = 0.0
strasse = 0
raises = 0
pfa = None
aktiv = set(range(n))
aggr = [[False] * 4 for _ in range(n)]
offen = [] # (index in out, spieler, strasse, antwort ausstehend)
out = []
allin = hand.get("allin") or set()
for i, (s, p, art, betrag) in enumerate(hand["akt"]):
if s != strasse:
topf_vor += sum(beitrag)
beitrag = [0.0] * n
strasse = s
if p not in aktiv:
continue
hoch = max(beitrag)
if art == "f":
aktiv.discard(p)
for o in offen:
if o[3] and o[1] != p:
o[3] = False
if len(aktiv) == 1:
out[o[0]][1]["n_fold"] = 1
continue
for o in offen:
if o[3] and o[1] != p:
o[3] = False
if art == "c":
beitrag[p] = max(beitrag[p], hoch)
continue
# r
if s == 0:
raises += 1
pfa = p
beitrag[p] = betrag
continue
aggr[p][s] = True
topf = topf_vor + sum(beitrag)
if hoch <= 0:
a, gr = "bet", betrag / max(topf, 1e-9)
else:
mit = topf + (hoch - beitrag[p])
a, gr = "raise", (betrag - hoch) / max(mit, 1e-9)
if (s, p, i) in allin:
a = "allin"
beitrag[p] = betrag
if len(aktiv) != 2:
continue
b = 0
for t in range(s, 0, -1):
if not aggr[p][t]:
break
b += 1
andere = max(aktiv - {p})
ip = p > andere if n > 2 else p == 0 # Heads-up ist der SB der Knopf
k = (STR[s - 1], topf_art(raises), b, stufe(gr), a, p == pfa, "ip" if ip else "oop")
out.append((k, dict.fromkeys(FELDER, 0), p, s))
out[-1][1]["n_alle"] = 1
offen.append([len(out) - 1, p, s, True])
gez = hand.get("gezeigt") or {}
# Wer hat den Showdown verloren (beide Haende bekannt, Heads-up, ganzes Board)?
verloren = set()
if hand.get("showdown") and len(aktiv) == 2 and len(hand["board"]) == 5 and all(q in gez for q in aktiv):
a_, b_ = sorted(aktiv)
sa = eval7.score7(list(gez[a_]) + list(hand["board"]))
sb = eval7.score7(list(gez[b_]) + list(hand["board"]))
if sa != sb:
verloren.add(a_ if sa < sb else b_)
erg = []
for k, z, p, s in out:
if p == hand.get("ohne"):
continue # unsere eigenen Einsaetze (NL2-Form)
if not z["n_fold"]:
karten = gez.get(p)
if karten and len(hand["board"]) >= s + 2:
x = staerke(karten, hand["board"][:s + 2], seed=seed * 31 + s)
z["n"] = 1
z["luft"] = int(x < LUFT)
z["wert"] = int(x >= WERT)
if p in verloren:
z["n_verl"] = 1
z["luft_verl"] = z["luft"]
elif hand.get("showdown") and p in aktiv:
z["gemuckt"] = 1
erg.append((k, z))
return erg
# --- PHH ---
_AKT = re.compile(r"actions = \[(.*?)\]", re.S)
_BL = re.compile(r"blinds_or_straddles = \[(.*?)\]")
_WIN = re.compile(r"winnings = \[(.*?)\]")
def _zahl(t):
return float(t.strip())
def phh_hand(block):
"""Ein PHH-Block -> gemeinsame Form, oder None (kein Flop)."""
if "d db" not in block:
return None
m, bl = _AKT.search(block), _BL.search(block)
if not m or not bl:
return None
blinds = [_zahl(x) for x in bl.group(1).split(",")]
n = len(blinds)
akt, board, gez = [], [], {}
s = 0
for roh in re.findall(r"'([^']*)'", m.group(1)):
t = roh.split()
if t[0] == "d":
if t[1] == "dh" and len(t) > 3 and "?" not in t[3]:
# HandHQ: am Showdown aufgedeckte Karten stehen im Austeilen, `sm` bleibt '????'
gez[int(t[2][1:]) - 1] = [eval7.karte(t[3][0:2]), eval7.karte(t[3][2:4])]
if t[1] == "db":
s += 1
kk = t[2]
board.append([eval7.karte(kk[j:j + 2]) for j in range(0, len(kk), 2)])
continue
p = int(t[0][1:]) - 1
if t[1] == "f":
akt.append((s, p, "f", 0.0))
elif t[1] == "cc":
akt.append((s, p, "c", 0.0))
elif t[1] == "cbr":
akt.append((s, p, "r", _zahl(t[2])))
elif t[1] == "sm" and len(t) > 2 and "?" not in t[2]:
gez[p] = [eval7.karte(t[2][0:2]), eval7.karte(t[2][2:4])]
flach = [c for x in board for c in x]
if s == 3 and len(flach) != 5:
return None
return {"n": n, "blinds": blinds, "akt": akt, "board": flach, "gezeigt": gez,
"showdown": s == 3 and _mehr_als_einer(akt, n)}
def _mehr_als_einer(akt, n):
raus = {p for _, p, a, _ in akt if a == "f"}
return n - len(raus) >= 2
def phh_bloecke(text):
for b in re.split(r"\n(?=\[\d+\]\n)", text):
yield b
def stake_aus(name):
m = re.search(r"_(\d+)NLH_", name)
return int(m.group(1)) if m else 0
def lauf_phh(roh, aus, teil=(0, 1), stufen=None, melden=print, voll=(25, 50), jede=3):
idx = json.load(open(os.path.join(roh, "index.json")))["eintraege"]
f = open(os.path.join(roh, "handhq.bin"), "rb")
tab = {}
haende = sd = 0
for j, e in enumerate(idx):
if j % teil[1] != teil[0]:
continue
st = stake_aus(e["name"])
if stufen and st not in stufen:
continue
if voll and st not in voll and j % jede:
continue # hoehere Stufen nur fuer den Verlauf: jede `jede`-te Datei
f.seek(e["offset"])
k = f.read(30)
if k[:4] != b"PK\x03\x04":
continue
nl, el = struct.unpack("<HH", k[26:30])
f.seek(e["offset"] + 30 + nl + el)
d = f.read(e["gepackt"])
text = (zlib.decompress(d, -15) if e["methode"] == 8 else d).decode("utf-8", "replace")
for blk in phh_bloecke(text):
haende += 1
h = phh_hand(blk)
if not h:
continue
for kk, z in faelle(h, seed=haende):
_add(tab, (st,) + kk, z)
sd += z["n"]
if j % 200 == teil[0]:
melden("%d/%d Dateien, %d Haende, %d gezeigte Faelle" % (j, len(idx), haende, sd))
_schreiben(aus, tab, {"quelle": "PHH/HandHQ", "haende": haende,
"stichprobe": "NL%s voll, uebrige Stufen jede %d. Datei" % ("+".join(map(str, voll)), jede)})
def _add(tab, k, z):
t = tab.setdefault(k, dict.fromkeys(FELDER, 0))
for f in FELDER:
t[f] += z[f]
def _schreiben(aus, tab, kopf):
zeilen = []
for k, z in sorted(tab.items(), key=lambda x: str(x[0])):
st, s, topf, b, gr, a, pfa, pos = k
zeilen.append(dict({"stufe": st, "strasse": s, "topf": topf, "barrels": b, "groesse": gr, "art": a,
"pf_aggressor": pfa, "position": pos}, **z))
with open(aus, "w", encoding="utf-8", newline="\n") as f:
json.dump(dict(kopf, luft_schwelle=LUFT, wert_schwelle=WERT, zeilen=zeilen), f, indent=0)
def _lesen(pfad):
d = json.load(open(pfad, encoding="utf-8"))
tab = {}
for z in d["zeilen"]:
k = (z["stufe"], z["strasse"], z["topf"], z["barrels"], z["groesse"], z["art"], z["pf_aggressor"],
z["position"])
_add(tab, k, z)
return d, tab
def mischen(aus, teile):
tab, kopf, haende = {}, None, 0
for t in teile:
d, tt = _lesen(t)
kopf = kopf or {k: v for k, v in d.items() if k != "zeilen"}
haende += d.get("haende", 0)
for k, z in tt.items():
_add(tab, k, z)
kopf["haende"] = haende
_schreiben(aus, tab, kopf)
# --- unsere NL2-Haende (lesen/linien.py-Form: verlauf, aufgedeckt, board) ---
_ART = {"FOLD": "f", "CHECK": "c", "CALL": "c", "BET": "r", "RAISE": "r", "ALL_IN": "r"}
_STR = {"PREFLOP": 0, "FLOP": 1, "TURN": 2, "RIVER": 3}
def _karte(c):
import zaehler
t = zaehler.karte_text(c)
return eval7.karte(t) if t else None
def nl2_hand(h):
v = [r for r in h.get("verlauf") or () if isinstance(r, dict)]
board = [_karte(c) for c in h.get("board") or ()]
if not v or None in board: # ohne Showdown fehlt das Board (Sim): Linie zaehlt, Staerke nicht
return None
sitze = []
for r in v:
if r.get("seat") is not None and int(r["seat"]) not in sitze:
sitze.append(int(r["seat"]))
# Reihenfolge: SB, BB, dann Vorflop-Reihenfolge; postflop SB zuerst. Index = Platz in der Postflop-
# Reihenfolge, wie in PHH.
sb = next((int(r["seat"]) for r in v if r.get("action") == "POST_SB"), None)
bb = next((int(r["seat"]) for r in v if r.get("action") == "POST_BB"), None)
rest = [x for x in sitze if x not in (sb, bb)]
ordnung = [x for x in (sb, bb) if x is not None] + rest
pos = {x: i for i, x in enumerate(ordnung)}
blinds = [0.0] * len(ordnung)
akt, allin, gez = [], set(), {}
hoch = {}
for r in v:
a, s = r.get("action"), _STR.get(r.get("street"))
if s is None or r.get("seat") is None:
continue
p = pos[int(r["seat"])]
betrag = float(r.get("amount") or 0.0)
if a in ("POST_SB", "POST_BB"):
blinds[p] = betrag
hoch[0] = max(hoch.get(0, 0.0), betrag)
continue
art = _ART.get(a)
if art is None:
continue
if art == "r":
# amount ist der Strassen-Gesamtbetrag (linien.py: Betraege 'bis'); fehlt er, Hand weg
if r.get("amount") is None or betrag <= 0:
return None
if betrag <= hoch.get(s, 0.0) + 1e-9:
art = "c" # All-in fuer weniger als den offenen Einsatz: ein Call
else:
hoch[s] = betrag
if a == "ALL_IN":
allin.add((s, p, len(akt)))
akt.append((s, p, art, betrag))
for sitz, karten in (h.get("aufgedeckt") or {}).items():
k = [_karte(c) for c in karten or ()]
if len(k) == 2 and None not in k and int(sitz) in pos:
gez[pos[int(sitz)]] = k
letzte = max((s for s, _, _, _ in akt), default=0)
held = h.get("held")
if held is None or int(held) not in pos:
return None # ohne eigenen Sitz koennten unsere Einsaetze als Gegner zaehlen
return {"ohne": pos[int(held)], "n": len(ordnung), "blinds": blinds, "akt": akt, "board": board, "gezeigt": gez,
"showdown": letzte == 3 and _mehr_als_einer(akt, len(ordnung)) and len(board) == 5, "allin": allin}
def lauf_nl2(pfad, aus):
tab = {}
haende = 0
for z in open(pfad, encoding="utf-8"):
h = json.loads(z)
hh = nl2_hand(h)
haende += 1
if not hh:
continue
for k, w in faelle(hh, seed=haende):
_add(tab, (2,) + k, w)
_schreiben(aus, tab, {"quelle": "NL2 eigene Tische", "haende": haende})
# --- hierarchisch: PHH als Prior, NL2 zieht nach ---
KERN = ("strasse", "topf", "barrels", "groesse", "art", "pf_aggressor")
RUECKFALL = (KERN, ("strasse", "topf", "barrels", "art", "pf_aggressor"), ("strasse", "barrels", "art", "pf_aggressor"),
("strasse", "barrels", "art"), ("strasse", "barrels"))
def geschaetzt(z):
"""(luft, n) mit den Weggeworfenen: jeder Muck traegt den Luftanteil der gezeigten Verlierer."""
q = (z["luft_verl"] + 0.5) / (z["n_verl"] + 1.0)
return z["luft"] + z["gemuckt"] * q, z["n"] + z["gemuckt"]
def _summe(zeilen, felder):
tab = {}
for z in zeilen:
k = tuple(z[f] for f in felder)
t = tab.setdefault(k, dict.fromkeys(FELDER, 0))
for f in FELDER:
t[f] += z[f]
return tab
def _ml_lambda(paare):
"""Empirisch-Bayes: das lambda, unter dem die NL2-Zaehlungen (luft, n) als Beta-Binomial um die
PHH-Mittel p am wahrscheinlichsten sind."""
from math import lgamma
def ll(lam):
s = 0.0
for luft, n, p in paare:
a, b = lam * p, lam * (1 - p)
k = luft
s += lgamma(k + a) + lgamma(n - k + b) - lgamma(n + a + b) - lgamma(a) - lgamma(b) + lgamma(a + b)
return s
gitter = [5 * 1.25 ** i for i in range(30)]
return max(gitter, key=ll)
def prior(phh_pfad, nl2_pfad, aus, stufen=(25, 50), lam=None):
phh = [z for z in json.load(open(phh_pfad, encoding="utf-8"))["zeilen"] if z["stufe"] in stufen]
nl2 = json.load(open(nl2_pfad, encoding="utf-8"))["zeilen"]
p_tab = [_summe(phh, f) for f in RUECKFALL]
n_tab = _summe(nl2, KERN)
def p_von(k):
kd = dict(zip(KERN, k))
if kd["art"] == "allin": # PHH kennt keine Stacks: All-in = Bet derselben Linie
kd["art"] = "bet"
for felder, tab in zip(RUECKFALL, p_tab):
z = tab.get(tuple(kd[f] for f in felder))
if z and z["n"] + z["gemuckt"] >= 30:
l_, n_ = geschaetzt(z)
return (l_ + 0.5) / (n_ + 1.0), z, felder
return None, None, None
paare = []
for k, z in n_tab.items():
p, _, _ = p_von(k)
l_, n_ = geschaetzt(z)
if p is not None and n_ > 0:
paare.append((l_, n_, p))
if lam is None:
lam = _ml_lambda(paare) if paare else 30.0
zeilen = []
ia = KERN.index("art")
allin = {k[:ia] + ("allin",) + k[ia + 1:] for k in p_tab[0] if k[ia] == "bet"} # HandHQ ohne Stacks
for k in sorted(set(p_tab[0]) | allin | set(n_tab), key=str):
p, zp, felder = p_von(k)
if p is None:
continue
zn = n_tab.get(k, dict.fromkeys(FELDER, 0))
l_, n_ = geschaetzt(zn)
luft = l_ + lam * p
n = n_ + lam
zp0 = p_tab[0].get(k, dict.fromkeys(FELDER, 0))
zeilen.append(dict(dict(zip(KERN, k)), luft=round(luft, 2), n=round(n, 2), anteil=round(luft / n, 4),
phh_anteil=round(p, 4), phh_n=zp0["n"], phh_gemuckt=zp0["gemuckt"],
phh_fold=round(zp0["n_fold"] / zp0["n_alle"], 3) if zp0["n_alle"] else None,
phh_alle=zp0["n_alle"], nl2_luft=zn["luft"], nl2_n=zn["n"], nl2_alle=zn["n_alle"],
nl2_fold=round(zn["n_fold"] / zn["n_alle"], 3) if zn["n_alle"] else None,
prior_aus="/".join(felder)))
kopf = {"quelle": "PHH/HandHQ NL%s (Juli 2009) als Prior, NL2 eigene Tische zieht nach" % "+".join(map(str, stufen)),
"luft": LUFT, "lambda": lam,
"hinweis": "luft/n = Pseudo-Zaehlung des Posteriors (n = NL2-Faelle + lambda). Flop/Turn sind wertlastig "
"(nur was den Showdown erreicht); der River ist die saubere Zeile. Weggeworfene tragen den "
"Luftanteil der gezeigten Verlierer.",
"zeilen": zeilen}
with open(aus, "w", encoding="utf-8", newline=chr(10)) as f:
json.dump(kopf, f, indent=0, ensure_ascii=False)
return lam
# --- pool-nl2-echt: Bluffrate je Strasse auf den Posterior eichen ---
def sim_zeilen(ordner):
"""Linien-Zeilen eines Sim-Ordners (*.linien von ab_zelle LINIEN=1), wie `lauf_nl2`."""
import glob
tab = {}
i = 0
for pfad in sorted(glob.glob(os.path.join(ordner, "*.linien"))):
for z in open(pfad, encoding="utf-8"):
i += 1
hh = nl2_hand(json.loads(z))
if hh:
for k, w in faelle(hh, seed=i):
_add(tab, (0,) + k, w)
return [dict(dict(zip(("stufe",) + KERN + ("position",), k)), **z) for k, z in tab.items()]
def ziel_je_strasse(posterior, sim):
"""Ziel-Luftanteil je Strasse: Posterior-Anteile, gewichtet mit der Linienmischung der Sim selbst
(gezeigte Faelle je Schluessel), damit die Mischung der Linien den Vergleich nicht verschiebt."""
post = {tuple(z[f] for f in KERN): z["anteil"] for z in posterior["zeilen"]}
out = {}
for s in STR:
g = w = 0.0
for z in sim:
if z["strasse"] != s or not z["n"]:
continue
k = tuple(z[f] for f in KERN)
a = post.get(k)
if a is None:
kk = dict(zip(KERN, k), art="bet" if k[4] == "allin" else k[4])
a = post.get(tuple(kk[f] for f in KERN))
if a is None:
continue
g += z["n"] * a
w += z["n"]
out[s] = g / w if w else None
return out
def sim_je_strasse(sim):
out = {}
for s in STR:
l_ = sum(geschaetzt(z)[0] for z in sim if z["strasse"] == s)
n_ = sum(geschaetzt(z)[1] for z in sim if z["strasse"] == s)
out[s] = (l_ / n_ if n_ else None, n_)
return out
def bluff_eichen(persona, posterior, arbeit, runden=3, deals=2000, draws=4, melden=print, laufen=None):
"""Passt bluff_flop/turn/river der Persona an, bis der gezeigte Luftanteil je Strasse in der Sim den
Posterior trifft: Bluffrate mal Quotenverhaeltnis Ziel/Sim (Luft ~ Bluffrate, Wert fest).
-> (persona, protokoll)."""
import pool_nachfuehren as pn
laufen = laufen or (lambda pj, ordner: pn.starten(pj, ordner, deals, draws))
p = dict(persona)
basis = p.get("bluff", 0.03)
for i, s in enumerate(STR):
p.setdefault("bluff_" + s, basis)
protokoll = []
for r in range(runden + 1):
ordner = os.path.abspath(os.path.join(arbeit, "runde%d" % r))
os.makedirs(ordner, exist_ok=True)
for f in os.listdir(ordner):
os.remove(os.path.join(ordner, f))
pj = ordner + ".json"
with open(pj, "w", encoding="utf-8", newline=chr(10)) as f:
json.dump(p, f)
laufen(pj, ordner)
sim = sim_zeilen(ordner)
ziel, ist = ziel_je_strasse(posterior, sim), sim_je_strasse(sim)
zeile = {"runde": r, "bluff": {s: round(p["bluff_" + s], 4) for s in STR},
"sim": {s: (round(ist[s][0], 4) if ist[s][0] is not None else None, ist[s][1]) for s in STR},
"ziel": {s: round(ziel[s], 4) if ziel[s] is not None else None for s in STR}}
protokoll.append(zeile)
melden(json.dumps(zeile))
if r == runden:
break
for s in STR:
a, n_ = ist[s]
z = ziel[s]
if z is None or a is None or n_ < 20:
continue
q = lambda x: min(max(x, 0.005), 0.995) / (1 - min(max(x, 0.005), 0.995))
p["bluff_" + s] = round(min(max(p["bluff_" + s] * q(z) / q(a), 0.0), 0.9), 4)
return p, protokoll
if __name__ == "__main__":
a = sys.argv[1:]
if a[0] == "phh":
teil = (0, 1)
stufen = None
if "--teil" in a:
i, k = a[a.index("--teil") + 1].split("/")
teil = (int(i), int(k))
if "--stufen" in a:
stufen = {int(x) for x in a[a.index("--stufen") + 1].split(",")}
lauf_phh(a[1], a[2], teil, stufen, melden=lambda t: print(t, flush=True))
elif a[0] == "nl2":
lauf_nl2(a[1], a[2])
elif a[0] == "mischen":
mischen(a[1], a[2:])
elif a[0] == "eichen":
# eichen <persona.json> <posterior.json> <arbeit> <aus.json> [deals draws]
pers = json.load(open(a[1], encoding="utf-8"))
post = json.load(open(a[2], encoding="utf-8"))
deals, draws = (int(a[5]), int(a[6])) if len(a) > 6 else (2000, 4)
neu, prot = bluff_eichen(pers, post, a[3], deals=deals, draws=draws, melden=lambda t: print(t, flush=True))
neu["_bluff_eichung"] = prot[-1]
with open(a[4], "w", encoding="utf-8", newline=chr(10)) as f:
json.dump(neu, f, indent=1, ensure_ascii=False)
elif a[0] == "prior":
lam = float(a[a.index("--lam") + 1]) if "--lam" in a else None
st = tuple(int(x) for x in a[a.index("--stufen") + 1].split(",")) if "--stufen" in a else (25, 50)
print("lambda", prior(a[1], a[2], a[3], st, lam))
+80
View File
@@ -0,0 +1,80 @@
# Familie A + Bettor-Modell: Tor 17.11. (Auftrag Orchestrator)
Branch `claude/engine-roentgen-c4dd78`, Basis Live-HEAD 596888ee (+ POOL_STUFE=rtb, GEGNER_POOL_STUFE=NL0.01-0.02),
alle Sim-Arme SIM_RIVERCALL=1, je Vergleich ein Binary. Keine Gegnerkennung in diesem Ordner.
## Kandidaten (alle Messschalter, ungesetzt bitgleich: basis gg. basisb 0 geänderte Deals)
| Schalter | Was |
|---|---|
| `BETTOR=<bettor-kern.txt>` | P(Antwort ∣ Brett-Perzentil) je Wettknoten (Straße, Vorflop-Aggressor, Aggression davor), Antwort Check oder Größenklasse k/m/g/u; liest den offenen Einsatz (und Check) heads-up per Bayes statt Klassenboden + Bluffanteil (`exploit/bettor.rs`, `engine/range_filter.rs`) |
| `GEGEN_GROSS=t` | Spitzenschnitt der Range gegen All-in / große River-Einsätze |
| `UEBERSCHUSS=1` | der ungecallte Teil eines Einsatzes, der den Helden all-in setzt, kommt aus dem Topf (`engine/ueberschuss.rs`). Client und Sim melden den Topf mit dem ganzen Einsatz, toCall auf den Stack gekappt: alle 17 gedeckten All-in-Calls seit 14.11. rechneten mit zu viel Topf |
| `SIM_BETTOR=<Tabelle>` (nur Sim-Gegner) | Pool-Gegner (`pool-*`) setzen/checken heads-up an ihrem offenen Knoten nach derselben Tabelle (`sim/bettor_tor.rs`) |
Tabelle: `bettor.py` aus PHH NL25/50 (8,1 Mio. Hände, 120 Gegenhände je Perzentil) mit NL2 (λ 50) gemischt →
`bettor-kern.txt`; Muck-korrigiert (Verlierer ohne Aufdecken, `muck-phh.json`) → `bettor-kern-muck.txt`.
## Tor 1: Live-Replay (eigene NL2-Hände seit 14.11., 889 Spots gegen einen Einsatz nach dem Flop)
Fold-Anteil % (damals / live / bettor; ABSTAIN zählt als Fold, wie live) gegen NL2-Korridor (Pool-Fold auf den ersten Einsatz heads-up, `korridor-nl2.json`):
| Straße / Größe | damals | live | bettor | Korridor |
|---|---|---|---|---|
| Flop klein | 50 | 42 | 40 | 36 [30,42] ✓ |
| Flop mittel | 67 | 59 | 55 | 47 [36,59] ✓ |
| Flop groß | 68 | 60 | 68 | 65 [41,83] ✓ |
| Turn klein | 44 | 46 | 45 | 29 [21,38] ✗ |
| Turn mittel | 61 | 62 | 59 | 46 [36,56] ✗ |
| Turn groß | 74 | 76 | 80 | 70 [52,84] ✓ |
| River klein | 65 | 77 | 53 | 41 [30,52] knapp ✗ |
| River mittel | 77 | 89 | 63 | 50 [36,64] ✓ |
| River groß | 67 | 78 | 80 | 52 [34,69] ✗ |
| All-in | 38 | 52 | 57 | – |
Pflichtregel (eigene Klasse ≥ Zwei Paar, ohne Board-Paar, gegen < 55 % Pot): bettor 0/11 Drillinge, 1/10 Zwei Paar
(Qd8h auf Vierflush, EV Call +0,00 – begründet); live faltete Drillinge Ah8h.
Netto-EV auf Spots mit bekannter Gegnerhand (PHH, Familie C, 49 840 Spots, muck-gewichtet, Δ gg. live):
bettor **+37 826 bb** (River +29 652, davon klein +28 764; Turn +5 728; Flop +2 446; River groß −2 069, Flop mittel −1 040).
Familie A exakt (Δ gg. live 226 783): bettor +2 309, bettor+gg +3 930; gg50 allein −916.
Echte All-in-/River-≥Pot-Fälle (63): bettor faltet die Verlierer KK (−95,5), 9c7c (−101), 6h6s (−9) und die
Gewinner AdQd (+77,5; nach Überschuss-Abzug richtig: Preis 0,44), TcQc (+59,5), Qs3s (+11,5).
## Tor 2: Sim (gepaart, bb/100, 95 %)
BETTOR gegen die alten Sim-Gegner: **Verlierer überall** – Leiter −9,62 ±1,71 (gewinnt nur gegen station +26),
Micro −3,78, pool-nl2 −8,80, Lerner −6,15, pool-nl2-echt −3,95 ±2,57, pool-phh −5,35 ±1,96, echt-hart −4,28,
Pool-Ruf nl2 −8,79 / echt −5,35. Mit GEGEN_GROSS: Leiter −12,78, Micro −8,19.
Weil Sim- und Replay-Tor gegeneinander standen, wurde die Sim nach NL2 nachgeeicht (`SIM_BETTOR`: die Pool-Gegner
setzen genau nach der Tabelle). **BETTOR verliert auch gegen tabellentreue Gegner** (gegen sbbasis):
pool-phh −5,34 ±2,02, pool-nl2-echt −4,67 ±3,12, echt-hart −4,21, Pool-Ruf echt −4,69, pool-nl2 −4,17 ±6,73 (offen).
Diagnose-Arme (pool-phh / pool-nl2-echt / Pool-Ruf echt):
| Teil | phh | echt | poolecht |
|---|---|---|---|
| nur Einsatz-Lesung | −2,39 ±1,16 | −0,93 ±2,17 | −1,44 ±2,51 |
| nur Check-Lesung | −2,61 ±1,48 | −3,08 ±2,31 | −3,18 ±2,37 |
| nur River (Einsatz+Check) | −0,89 ±0,68 | −0,91 ±1,75 | −1,22 ±2,44 |
| nur River-Einsatz | −0,79 ±0,67 | −0,19 ±1,65 | −0,39 ±2,27 (nl2 +0,96 ±2,48) |
**Befund:** Die Sim ist nicht bloß falsch geeicht. Auch wenn die Range-Lesung exakt stimmt, macht die Engine
daraus schlechtere Entscheidungen; am stärksten nach einem Check des Gegners (die Lesung „Check = schwächer“ treibt
eigene Einsätze, die die Pool-Antwort bestraft). Die Entscheidungsschicht ist auf die alten Klassenböden geeicht.
Muck-Korrektur: Verlierer decken als passive Spieler nur 39 % (PS) bis 55 % (FTP) auf, River-Aggressoren fast immer;
die Tabelle ändert sich wenig (River-Checks etwas schwächer, Einsätze etwas stärker) – nicht die Ursache.
**Urteil BETTOR / GEGEN_GROSS: kein Live-Schalten** (Tor 2 nicht bestanden, Korridor Turn klein/mittel und River
groß verfehlt). Live-Replay und Familie C zeigen, wo das Geld liegt (River klein: zu viel Fold, +28 764 bb an PHH);
der nächste Schritt ist die Entscheidungsschicht (Call/Bet-EV gegen die gelesene Range über die Folgestraßen), nicht
die Lesung.
## UEBERSCHUSS allein
Live-Replay: 2 von 889 Entscheidungen ändern sich, beide All-in-Folds (9c7c Turn, damals −101; AdQd River, damals
+77,5, Preis nach Abzug 0,44 bei Equity 0,43). Pflichtregel unverändert.
Sim (u gg. basisu, Binary -u, alle 12 Zellen + 6-max + 6-max-Pool + LBR): **bitgleich, 0 Deals bewegt** – die Sim
erzeugt keinen gedeckten All-in mit Überschuss im Topf (Einsätze dort auf den effektiven Stack begrenzt).
**Urteil UEBERSCHUSS=1: kein Verlierer, Live-Kandidat** (reine Preis-Korrektur; Schalter in BEKANNTE_SCHALTER).
Beleg nur live: 17 gedeckte All-in-Calls seit 14.11. rechneten mit zu viel Topf (78 Turn Preis 0,12 statt 0,19,
AK 0,37 statt 0,42, QQ 0,25 statt 0,40, River-Overbet 0,08 statt 0,44).
+56
View File
@@ -0,0 +1,56 @@
# P(Antwort | Brett-Perzentil) je Wettknoten: strasse pfa vorher antwort, 20 Faecher (messung/familie_a/bettor.py)
flop 0 0 g 0.0508 0.0496 0.0520 0.0442 0.0437 0.0430 0.0441 0.0453 0.0410 0.0422 0.0444 0.0460 0.0537 0.0748 0.0855 0.1161 0.1373 0.1676 0.1837 0.1461
flop 0 0 k 0.0159 0.0134 0.0155 0.0146 0.0177 0.0193 0.0209 0.0238 0.0265 0.0303 0.0308 0.0351 0.0354 0.0373 0.0440 0.0477 0.0562 0.0590 0.0609 0.0556
flop 0 0 m 0.0657 0.0643 0.0638 0.0641 0.0671 0.0663 0.0698 0.0692 0.0730 0.0788 0.0814 0.0884 0.1071 0.1318 0.1425 0.1700 0.1903 0.2071 0.2252 0.1884
flop 0 0 u 0.0155 0.0169 0.0146 0.0139 0.0155 0.0155 0.0134 0.0136 0.0154 0.0149 0.0179 0.0177 0.0207 0.0246 0.0305 0.0375 0.0460 0.0593 0.0648 0.0489
flop 0 0 x 0.8520 0.8558 0.8541 0.8631 0.8560 0.8559 0.8519 0.8481 0.8441 0.8338 0.8255 0.8128 0.7831 0.7315 0.6975 0.6286 0.5703 0.5070 0.4654 0.5610
flop 1 0 g 0.0818 0.0706 0.0703 0.0705 0.0699 0.0718 0.0635 0.0639 0.0660 0.0600 0.0651 0.0645 0.0644 0.0731 0.0646 0.0750 0.0847 0.0992 0.1350 0.1126
flop 1 0 j 0.0003 0.0003 0.0003 0.0002 0.0002 0.0002 0.0001 0.0001 0.0001 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0001 0.0000 0.0000 0.0000
flop 1 0 k 0.0612 0.0583 0.0562 0.0590 0.0680 0.0671 0.0686 0.0707 0.0645 0.0706 0.0688 0.0693 0.0664 0.0710 0.0697 0.0741 0.0800 0.0819 0.0693 0.0782
flop 1 0 m 0.4896 0.4827 0.4722 0.4734 0.4495 0.4343 0.4245 0.4115 0.4243 0.4205 0.4223 0.4369 0.4417 0.4392 0.4597 0.4996 0.5680 0.5856 0.6473 0.6150
flop 1 0 u 0.0148 0.0104 0.0135 0.0178 0.0152 0.0155 0.0159 0.0174 0.0122 0.0140 0.0163 0.0187 0.0182 0.0187 0.0186 0.0190 0.0191 0.0219 0.0228 0.0166
flop 1 0 x 0.3524 0.3777 0.3876 0.3791 0.3970 0.4112 0.4274 0.4365 0.4329 0.4348 0.4275 0.4107 0.4092 0.3980 0.3873 0.3323 0.2480 0.2114 0.1257 0.1777
river 0 0 g 0.0364 0.0349 0.0324 0.0284 0.0274 0.0264 0.0245 0.0231 0.0277 0.0271 0.0261 0.0286 0.0335 0.0405 0.0505 0.0591 0.0797 0.1130 0.1851 0.2186
river 0 0 j 0.0001 0.0001 0.0001 0.0001 0.0001 0.0002 0.0001 0.0001 0.0001 0.0001 0.0001 0.0001 0.0001 0.0001 0.0001 0.0001 0.0001 0.0002 0.0001 0.0001
river 0 0 k 0.0201 0.0194 0.0200 0.0213 0.0229 0.0284 0.0319 0.0360 0.0409 0.0463 0.0575 0.0671 0.0773 0.0962 0.1127 0.1357 0.1523 0.1597 0.1462 0.1280
river 0 0 m 0.0673 0.0622 0.0593 0.0595 0.0612 0.0618 0.0645 0.0642 0.0665 0.0677 0.0738 0.0855 0.0945 0.1131 0.1327 0.1591 0.1962 0.2485 0.3094 0.3401
river 0 0 u 0.0195 0.0161 0.0151 0.0137 0.0138 0.0117 0.0113 0.0122 0.0142 0.0129 0.0146 0.0128 0.0139 0.0149 0.0203 0.0283 0.0372 0.0676 0.1164 0.1606
river 0 0 x 0.8567 0.8674 0.8731 0.8770 0.8746 0.8715 0.8677 0.8644 0.8507 0.8459 0.8280 0.8059 0.7807 0.7353 0.6837 0.6177 0.5346 0.4110 0.2429 0.1526
river 0 1 g 0.0656 0.0626 0.0644 0.0514 0.0550 0.0530 0.0408 0.0373 0.0339 0.0292 0.0251 0.0213 0.0222 0.0204 0.0250 0.0301 0.0385 0.0644 0.1188 0.1682
river 0 1 j 0.0002 0.0002 0.0002 0.0002 0.0002 0.0001 0.0001 0.0001 0.0001 0.0001 0.0001 0.0001 0.0001 0.0001 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
river 0 1 k 0.1245 0.1238 0.1350 0.1496 0.1550 0.1758 0.1945 0.2094 0.2352 0.2452 0.2570 0.2800 0.2995 0.3235 0.3350 0.3563 0.3610 0.3426 0.2942 0.2344
river 0 1 m 0.2034 0.2021 0.2066 0.1983 0.1863 0.1763 0.1641 0.1519 0.1319 0.1220 0.1068 0.1032 0.1019 0.1080 0.1348 0.1537 0.1971 0.2712 0.3717 0.4251
river 0 1 u 0.0194 0.0242 0.0260 0.0222 0.0208 0.0169 0.0149 0.0121 0.0169 0.0128 0.0100 0.0092 0.0088 0.0090 0.0097 0.0128 0.0128 0.0243 0.0460 0.0884
river 0 1 x 0.5870 0.5871 0.5677 0.5784 0.5828 0.5778 0.5856 0.5892 0.5820 0.5906 0.6010 0.5862 0.5676 0.5390 0.4955 0.4471 0.3904 0.2975 0.1692 0.0837
river 1 0 g 0.0650 0.0703 0.0488 0.0312 0.0255 0.0245 0.0177 0.0172 0.0160 0.0128 0.0117 0.0147 0.0126 0.0104 0.0165 0.0236 0.0365 0.0537 0.1047 0.1739
river 1 0 k 0.0582 0.0494 0.0432 0.0444 0.0455 0.0448 0.0378 0.0365 0.0451 0.0461 0.0572 0.0634 0.0706 0.0945 0.1183 0.1367 0.1613 0.1807 0.1740 0.1533
river 1 0 m 0.2284 0.1895 0.1467 0.1329 0.1145 0.0993 0.0803 0.0753 0.0692 0.0624 0.0601 0.0645 0.0737 0.1003 0.1226 0.1668 0.2396 0.3178 0.3922 0.4536
river 1 0 u 0.0202 0.0160 0.0114 0.0134 0.0097 0.0092 0.0060 0.0072 0.0087 0.0063 0.0100 0.0050 0.0046 0.0057 0.0046 0.0074 0.0095 0.0170 0.0402 0.0868
river 1 0 x 0.6281 0.6748 0.7498 0.7781 0.8048 0.8222 0.8582 0.8638 0.8610 0.8724 0.8609 0.8525 0.8385 0.7891 0.7380 0.6654 0.5529 0.4308 0.2889 0.1323
river 1 1 g 0.0851 0.0612 0.0554 0.0574 0.0473 0.0416 0.0367 0.0342 0.0327 0.0255 0.0255 0.0221 0.0201 0.0196 0.0214 0.0225 0.0340 0.0508 0.0847 0.1347
river 1 1 j 0.0010 0.0009 0.0007 0.0006 0.0004 0.0003 0.0002 0.0005 0.0002 0.0002 0.0002 0.0002 0.0002 0.0002 0.0001 0.0001 0.0001 0.0001 0.0001 0.0001
river 1 1 k 0.1547 0.1444 0.1420 0.1646 0.1690 0.1715 0.1778 0.1840 0.1863 0.2116 0.2098 0.2289 0.2495 0.2654 0.2875 0.3025 0.3215 0.3289 0.3036 0.2509
river 1 1 m 0.2879 0.2953 0.2862 0.2354 0.2074 0.1792 0.1626 0.1605 0.1312 0.1189 0.1101 0.1055 0.0963 0.1049 0.1202 0.1535 0.2123 0.2773 0.3751 0.4619
river 1 1 u 0.0275 0.0318 0.0295 0.0212 0.0210 0.0212 0.0141 0.0185 0.0211 0.0133 0.0122 0.0118 0.0082 0.0096 0.0098 0.0145 0.0176 0.0232 0.0395 0.0801
river 1 1 x 0.4438 0.4665 0.4862 0.5208 0.5548 0.5863 0.6084 0.6024 0.6286 0.6305 0.6422 0.6316 0.6256 0.6003 0.5611 0.5069 0.4145 0.3197 0.1969 0.0723
turn 0 0 g 0.0412 0.0393 0.0450 0.0358 0.0374 0.0380 0.0386 0.0369 0.0368 0.0370 0.0410 0.0429 0.0517 0.0631 0.0733 0.0828 0.0972 0.1119 0.1320 0.1379
turn 0 0 k 0.0216 0.0204 0.0197 0.0216 0.0256 0.0256 0.0310 0.0320 0.0385 0.0409 0.0409 0.0452 0.0494 0.0583 0.0670 0.0777 0.0854 0.0990 0.1000 0.0968
turn 0 0 m 0.0685 0.0706 0.0661 0.0710 0.0697 0.0697 0.0749 0.0772 0.0813 0.0901 0.0920 0.1043 0.1238 0.1391 0.1510 0.1680 0.1918 0.2169 0.2380 0.2210
turn 0 0 u 0.0132 0.0126 0.0092 0.0107 0.0117 0.0108 0.0099 0.0105 0.0096 0.0092 0.0118 0.0122 0.0147 0.0186 0.0190 0.0262 0.0309 0.0349 0.0502 0.0456
turn 0 0 x 0.8555 0.8571 0.8601 0.8609 0.8557 0.8560 0.8456 0.8434 0.8338 0.8228 0.8143 0.7953 0.7604 0.7209 0.6898 0.6453 0.5946 0.5373 0.4798 0.4987
turn 0 1 g 0.0467 0.0490 0.0544 0.0447 0.0498 0.0438 0.0442 0.0454 0.0408 0.0384 0.0348 0.0332 0.0322 0.0331 0.0354 0.0430 0.0491 0.0622 0.0935 0.1234
turn 0 1 j 0.0001 0.0002 0.0002 0.0001 0.0001 0.0001 0.0001 0.0001 0.0001 0.0001 0.0001 0.0001 0.0001 0.0001 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
turn 0 1 k 0.2366 0.2201 0.2327 0.2435 0.2399 0.2488 0.2586 0.2555 0.2619 0.2709 0.2721 0.2853 0.2857 0.2945 0.3014 0.3003 0.2953 0.2979 0.2746 0.2344
turn 0 1 m 0.2268 0.2258 0.2243 0.2161 0.2324 0.2155 0.2281 0.2208 0.1958 0.1907 0.1692 0.1772 0.1722 0.1818 0.1994 0.2110 0.2531 0.2994 0.3481 0.3921
turn 0 1 u 0.0113 0.0124 0.0120 0.0106 0.0140 0.0109 0.0149 0.0118 0.0135 0.0112 0.0095 0.0099 0.0127 0.0091 0.0122 0.0139 0.0167 0.0192 0.0235 0.0280
turn 0 1 x 0.4784 0.4927 0.4764 0.4849 0.4638 0.4809 0.4542 0.4665 0.4880 0.4888 0.5142 0.4943 0.4971 0.4814 0.4515 0.4317 0.3857 0.3213 0.2603 0.2220
turn 1 0 g 0.0518 0.0337 0.0532 0.0299 0.0396 0.0310 0.0322 0.0250 0.0216 0.0209 0.0199 0.0196 0.0223 0.0220 0.0211 0.0286 0.0475 0.0619 0.0829 0.0694
turn 1 0 k 0.0644 0.0554 0.0539 0.0549 0.0647 0.0469 0.0564 0.0583 0.0608 0.0596 0.0660 0.0766 0.0690 0.0790 0.1025 0.1090 0.1201 0.1355 0.1374 0.1798
turn 1 0 m 0.2217 0.2425 0.2290 0.2171 0.1901 0.1861 0.1784 0.1649 0.1705 0.1779 0.1698 0.1582 0.1728 0.1941 0.2357 0.2902 0.3283 0.4045 0.4527 0.3840
turn 1 0 u 0.0079 0.0048 0.0047 0.0082 0.0055 0.0048 0.0033 0.0040 0.0024 0.0042 0.0030 0.0021 0.0048 0.0023 0.0048 0.0051 0.0106 0.0110 0.0119 0.0118
turn 1 0 x 0.6543 0.6636 0.6592 0.6899 0.7001 0.7312 0.7296 0.7478 0.7448 0.7374 0.7413 0.7434 0.7311 0.7026 0.6360 0.5670 0.4935 0.3871 0.3151 0.3550
turn 1 1 g 0.0522 0.0393 0.0340 0.0473 0.0344 0.0360 0.0336 0.0352 0.0308 0.0269 0.0266 0.0286 0.0229 0.0260 0.0303 0.0342 0.0397 0.0582 0.0707 0.0722
turn 1 1 k 0.1295 0.1257 0.1281 0.1344 0.1449 0.1544 0.1733 0.1764 0.1693 0.1657 0.1654 0.1635 0.1592 0.1726 0.1773 0.1838 0.2032 0.1968 0.1987 0.1925
turn 1 1 m 0.2421 0.2474 0.2338 0.2387 0.2431 0.2194 0.2162 0.2037 0.2070 0.1922 0.1818 0.1745 0.1778 0.1805 0.1977 0.2176 0.2694 0.3715 0.4264 0.4557
turn 1 1 u 0.0138 0.0145 0.0167 0.0124 0.0151 0.0115 0.0142 0.0135 0.0120 0.0105 0.0114 0.0087 0.0111 0.0080 0.0105 0.0126 0.0155 0.0204 0.0238 0.0193
turn 1 1 x 0.5624 0.5731 0.5874 0.5672 0.5625 0.5787 0.5627 0.5712 0.5810 0.6046 0.6148 0.6247 0.6289 0.6128 0.5842 0.5518 0.4723 0.3531 0.2804 0.2604
+51
View File
@@ -0,0 +1,51 @@
# P(Antwort | Brett-Perzentil) je Wettknoten: strasse pfa vorher antwort, 20 Faecher (messung/familie_a/bettor.py)
flop 0 0 g 0.0575 0.0608 0.0594 0.0515 0.0495 0.0469 0.0503 0.0523 0.0429 0.0417 0.0455 0.0462 0.0514 0.0691 0.0790 0.1136 0.1356 0.1650 0.1857 0.1438
flop 0 0 k 0.0189 0.0146 0.0172 0.0152 0.0192 0.0201 0.0205 0.0234 0.0248 0.0287 0.0288 0.0331 0.0329 0.0347 0.0401 0.0437 0.0551 0.0563 0.0600 0.0562
flop 0 0 m 0.0630 0.0610 0.0644 0.0586 0.0599 0.0621 0.0637 0.0624 0.0644 0.0686 0.0680 0.0745 0.0868 0.1096 0.1209 0.1450 0.1629 0.1796 0.1990 0.1600
flop 0 0 u 0.0236 0.0241 0.0181 0.0181 0.0205 0.0184 0.0178 0.0165 0.0177 0.0168 0.0192 0.0196 0.0214 0.0264 0.0306 0.0406 0.0509 0.0711 0.0811 0.0610
flop 0 0 x 0.8369 0.8395 0.8409 0.8567 0.8509 0.8524 0.8477 0.8455 0.8503 0.8442 0.8385 0.8265 0.8075 0.7603 0.7294 0.6571 0.5955 0.5280 0.4742 0.5790
flop 1 0 g 0.0867 0.0757 0.0810 0.0800 0.0689 0.0747 0.0615 0.0627 0.0638 0.0558 0.0636 0.0611 0.0617 0.0682 0.0577 0.0701 0.0784 0.0894 0.1282 0.1076
flop 1 0 k 0.0612 0.0541 0.0635 0.0644 0.0743 0.0760 0.0687 0.0756 0.0701 0.0700 0.0696 0.0714 0.0669 0.0742 0.0724 0.0774 0.0849 0.0899 0.0746 0.0838
flop 1 0 m 0.5022 0.5067 0.4680 0.4884 0.4513 0.4520 0.4461 0.4214 0.4367 0.4302 0.4247 0.4255 0.4325 0.4296 0.4445 0.4803 0.5572 0.5753 0.6433 0.6057
flop 1 0 u 0.0193 0.0133 0.0156 0.0215 0.0163 0.0173 0.0201 0.0170 0.0127 0.0157 0.0179 0.0198 0.0187 0.0192 0.0189 0.0204 0.0200 0.0232 0.0273 0.0202
flop 1 0 x 0.3300 0.3496 0.3713 0.3451 0.3886 0.3795 0.4033 0.4230 0.4165 0.4282 0.4243 0.4221 0.4202 0.4088 0.4064 0.3517 0.2594 0.2222 0.1267 0.1827
river 0 0 g 0.0506 0.0470 0.0437 0.0331 0.0316 0.0298 0.0264 0.0246 0.0261 0.0253 0.0227 0.0255 0.0293 0.0337 0.0387 0.0463 0.0635 0.0869 0.1483 0.1849
river 0 0 k 0.0319 0.0280 0.0272 0.0298 0.0301 0.0353 0.0367 0.0382 0.0446 0.0471 0.0552 0.0656 0.0711 0.0880 0.1032 0.1237 0.1414 0.1510 0.1478 0.1319
river 0 0 m 0.0936 0.0856 0.0764 0.0710 0.0717 0.0672 0.0663 0.0665 0.0642 0.0620 0.0663 0.0753 0.0820 0.0917 0.1037 0.1269 0.1551 0.2051 0.2685 0.3157
river 0 0 u 0.0318 0.0244 0.0218 0.0220 0.0187 0.0150 0.0138 0.0144 0.0157 0.0132 0.0153 0.0124 0.0137 0.0136 0.0188 0.0247 0.0343 0.0608 0.1148 0.1622
river 0 0 x 0.7918 0.8147 0.8307 0.8439 0.8477 0.8523 0.8566 0.8562 0.8493 0.8523 0.8404 0.8210 0.8038 0.7729 0.7354 0.6783 0.6056 0.4959 0.3205 0.2051
river 0 1 g 0.0778 0.0768 0.0776 0.0636 0.0578 0.0528 0.0427 0.0365 0.0334 0.0267 0.0243 0.0175 0.0183 0.0173 0.0181 0.0215 0.0279 0.0469 0.0934 0.1413
river 0 1 k 0.1835 0.1685 0.1886 0.2051 0.2073 0.2292 0.2481 0.2580 0.2757 0.2825 0.2838 0.3020 0.3089 0.3220 0.3353 0.3469 0.3527 0.3427 0.3050 0.2515
river 0 1 m 0.2777 0.2632 0.2575 0.2462 0.2323 0.2194 0.1997 0.1759 0.1446 0.1304 0.1127 0.1013 0.1002 0.0998 0.1179 0.1350 0.1727 0.2391 0.3480 0.4127
river 0 1 u 0.0264 0.0356 0.0322 0.0269 0.0306 0.0218 0.0192 0.0148 0.0201 0.0142 0.0109 0.0100 0.0094 0.0090 0.0083 0.0130 0.0118 0.0222 0.0442 0.0858
river 0 1 x 0.4343 0.4554 0.4438 0.4578 0.4716 0.4765 0.4900 0.5146 0.5260 0.5459 0.5681 0.5691 0.5631 0.5518 0.5203 0.4835 0.4349 0.3490 0.2094 0.1086
river 1 0 g 0.0692 0.0819 0.0415 0.0331 0.0233 0.0263 0.0154 0.0171 0.0145 0.0113 0.0088 0.0129 0.0109 0.0070 0.0150 0.0207 0.0303 0.0386 0.0838 0.1517
river 1 0 k 0.0867 0.0683 0.0649 0.0603 0.0622 0.0622 0.0504 0.0452 0.0562 0.0541 0.0621 0.0688 0.0730 0.0941 0.1195 0.1316 0.1593 0.1836 0.1867 0.1627
river 1 0 m 0.2372 0.2251 0.1686 0.1644 0.1319 0.1189 0.0929 0.0850 0.0752 0.0657 0.0620 0.0662 0.0712 0.0900 0.1075 0.1301 0.2013 0.2716 0.3507 0.4352
river 1 0 u 0.0299 0.0250 0.0208 0.0109 0.0115 0.0111 0.0071 0.0059 0.0083 0.0076 0.0126 0.0058 0.0061 0.0060 0.0043 0.0074 0.0095 0.0144 0.0342 0.0851
river 1 0 x 0.5770 0.5996 0.7042 0.7314 0.7712 0.7815 0.8342 0.8469 0.8458 0.8612 0.8545 0.8463 0.8388 0.8029 0.7536 0.7102 0.5995 0.4918 0.3446 0.1653
river 1 1 g 0.0992 0.0665 0.0445 0.0590 0.0530 0.0446 0.0326 0.0340 0.0329 0.0287 0.0268 0.0182 0.0161 0.0153 0.0174 0.0180 0.0299 0.0367 0.0658 0.1155
river 1 1 k 0.2150 0.1978 0.2042 0.2395 0.2280 0.2414 0.2381 0.2429 0.2316 0.2688 0.2581 0.2708 0.2652 0.2842 0.2994 0.3129 0.3233 0.3418 0.3230 0.2834
river 1 1 m 0.3061 0.3205 0.3165 0.2851 0.2278 0.2022 0.1964 0.1891 0.1509 0.1324 0.1236 0.1069 0.0961 0.0976 0.1049 0.1289 0.1772 0.2399 0.3376 0.4327
river 1 1 u 0.0358 0.0299 0.0260 0.0181 0.0295 0.0310 0.0221 0.0290 0.0243 0.0197 0.0146 0.0147 0.0099 0.0107 0.0076 0.0134 0.0168 0.0230 0.0364 0.0768
river 1 1 x 0.3416 0.3831 0.4071 0.3970 0.4607 0.4802 0.5102 0.5040 0.5598 0.5499 0.5765 0.5890 0.6123 0.5919 0.5704 0.5267 0.4527 0.3584 0.2370 0.0913
turn 0 0 g 0.0463 0.0398 0.0458 0.0388 0.0394 0.0376 0.0368 0.0340 0.0348 0.0358 0.0360 0.0387 0.0470 0.0575 0.0678 0.0813 0.0984 0.1093 0.1243 0.1250
turn 0 0 k 0.0235 0.0223 0.0217 0.0218 0.0256 0.0267 0.0323 0.0277 0.0364 0.0356 0.0368 0.0420 0.0450 0.0547 0.0636 0.0733 0.0845 0.0983 0.0996 0.0965
turn 0 0 m 0.0664 0.0680 0.0627 0.0672 0.0620 0.0601 0.0632 0.0660 0.0663 0.0721 0.0762 0.0850 0.0995 0.1159 0.1281 0.1432 0.1630 0.1915 0.2115 0.1953
turn 0 0 u 0.0186 0.0158 0.0128 0.0134 0.0157 0.0129 0.0116 0.0114 0.0099 0.0089 0.0118 0.0115 0.0146 0.0170 0.0192 0.0286 0.0326 0.0378 0.0565 0.0552
turn 0 0 x 0.8452 0.8542 0.8570 0.8588 0.8574 0.8628 0.8562 0.8609 0.8526 0.8476 0.8392 0.8227 0.7938 0.7549 0.7212 0.6736 0.6217 0.5630 0.5082 0.5279
turn 0 1 g 0.0406 0.0449 0.0461 0.0435 0.0386 0.0399 0.0418 0.0353 0.0360 0.0339 0.0285 0.0272 0.0242 0.0226 0.0286 0.0296 0.0357 0.0447 0.0716 0.1038
turn 0 1 k 0.2543 0.2320 0.2532 0.2647 0.2560 0.2658 0.2638 0.2828 0.2867 0.2887 0.2865 0.3074 0.3035 0.3137 0.3231 0.3187 0.3166 0.3126 0.2941 0.2449
turn 0 1 m 0.2347 0.2276 0.2276 0.2206 0.2331 0.2045 0.2246 0.2172 0.1909 0.1801 0.1622 0.1686 0.1593 0.1666 0.1785 0.1927 0.2371 0.2877 0.3384 0.3816
turn 0 1 u 0.0111 0.0142 0.0117 0.0123 0.0157 0.0108 0.0158 0.0130 0.0131 0.0121 0.0110 0.0069 0.0109 0.0085 0.0113 0.0125 0.0138 0.0187 0.0248 0.0333
turn 0 1 x 0.4590 0.4809 0.4611 0.4587 0.4564 0.4788 0.4537 0.4516 0.4731 0.4851 0.5116 0.4898 0.5020 0.4884 0.4585 0.4464 0.3967 0.3364 0.2711 0.2363
turn 1 0 g 0.0544 0.0451 0.0386 0.0304 0.0250 0.0248 0.0318 0.0229 0.0221 0.0167 0.0180 0.0160 0.0186 0.0154 0.0209 0.0311 0.0396 0.0515 0.0701 0.0579
turn 1 0 k 0.0561 0.0616 0.0546 0.0643 0.0689 0.0549 0.0653 0.0668 0.0620 0.0624 0.0612 0.0720 0.0663 0.0779 0.1002 0.1176 0.1185 0.1480 0.1475 0.1893
turn 1 0 m 0.2475 0.2501 0.2600 0.2129 0.1954 0.1944 0.1669 0.1728 0.1621 0.1707 0.1592 0.1468 0.1567 0.1950 0.2222 0.2679 0.3211 0.3932 0.4456 0.3656
turn 1 0 u 0.0087 0.0089 0.0076 0.0101 0.0062 0.0061 0.0042 0.0039 0.0031 0.0036 0.0024 0.0021 0.0040 0.0032 0.0044 0.0054 0.0095 0.0134 0.0127 0.0145
turn 1 0 x 0.6333 0.6342 0.6391 0.6823 0.7045 0.7197 0.7317 0.7337 0.7507 0.7466 0.7592 0.7631 0.7545 0.7085 0.6523 0.5780 0.5112 0.3938 0.3241 0.3726
turn 1 1 g 0.0482 0.0342 0.0349 0.0496 0.0316 0.0379 0.0292 0.0287 0.0275 0.0228 0.0211 0.0226 0.0187 0.0197 0.0215 0.0276 0.0309 0.0499 0.0614 0.0651
turn 1 1 k 0.1435 0.1512 0.1503 0.1546 0.1573 0.1764 0.1909 0.1966 0.1910 0.1835 0.1889 0.1832 0.1785 0.2006 0.2035 0.2056 0.2267 0.2248 0.2217 0.2163
turn 1 1 m 0.2537 0.2347 0.2236 0.2340 0.2396 0.2157 0.2049 0.1858 0.1862 0.1748 0.1552 0.1596 0.1565 0.1570 0.1728 0.1895 0.2357 0.3433 0.4069 0.4259
turn 1 1 u 0.0135 0.0178 0.0128 0.0176 0.0138 0.0152 0.0153 0.0136 0.0118 0.0105 0.0131 0.0085 0.0096 0.0090 0.0107 0.0118 0.0151 0.0210 0.0250 0.0233
turn 1 1 x 0.5411 0.5620 0.5784 0.5442 0.5578 0.5547 0.5598 0.5753 0.5835 0.6084 0.6217 0.6261 0.6367 0.6137 0.5916 0.5655 0.4916 0.3610 0.2851 0.2693
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+395
View File
@@ -0,0 +1,395 @@
#!/usr/bin/env python3
"""P(Einsatz | Handstaerke) je Linie: wer setzt wie gross mit welcher Hand? Aus echten Showdowns
(PHH/HandHQ NL25/50 und unsere NL2-Haende).
Ein **Wettknoten** ist jede Lage nach dem Flop in einem Heads-up-Topf, in der ein Spieler setzen darf,
weil auf der Strasse noch niemand gesetzt hat. Seine Antwort ist `x` (Check) oder eine Einsatzstufe
`k <= 0.40 < m <= 0.80 < g <= 1.20 < u` (Anteil am Topf), `j` = All-in-Einsatz. Wird seine Hand am Ende
aufgedeckt, zaehlt sein **Brett-Perzentil** zu diesem Zeitpunkt: der Anteil aller Starthaende, die er
mit seiner aktuellen gemachten Hand (beste fuenf aus Loch + Board, ohne Draws) schlaegt (Gleichstand
halb). Dieselbe Groesse misst der Kern mit `hand::showdown::judge` (`exploit::bettor`).
Schluessel: Strasse, Vorflop-Aggressor (ja/nein), eigene Aggression auf der Strasse davor (ja/nein).
Je Schluessel und Antwort ein Histogramm in FAECHER Faechern. Daraus folgt die Likelihood
P(Antwort | Perzentil) = n(Antwort, p) / Summe n(alle Antworten, p): Checks und Einsaetze werden am
Showdown gleich behandelt, die Showdown-Auswahl kuerzt sich weitgehend heraus (benannt: wer checkt und
spaeter foldet, fehlt; das macht Checks im Mittel staerker und Einsaetze im Mittel etwas bluffiger).
Muck (17.11.): am Showdown deckt der Verlierer oft nicht auf (PokerStars-River: 92 % gemuckt). Ohne Korrektur
besteht die Tabelle fast nur aus Gewinnerhaenden: Bluffs und verlorene duenne Value-Einsaetze fehlen, jeder
Einsatz liest sich zu stark (Sim: Overfold gegen Maniac/GTO/Nemesis). Der Vorlauf `muck` misst je Netz und
Rolle (letzter River-Aggressor ja/nein) den Anteil g der Showdown-Verlierer, die aufdecken; im Hauptlauf zaehlt
jede aufgedeckte, am Showdown verlorene Hand 1/g-fach (`BETTOR_MUCK=<muck.json>`).
Keine Spielerkennung in der Ausgabe.
python -I messung/familie_a/bettor.py muck <roh> <muck.json> [--stufen 25,50] [--jede 8]
python -I messung/familie_a/bettor.py phh <roh> <aus.json> --teil i/k [--stufen 25,50] (BETTOR_MUCK=<muck.json>)
python -I messung/familie_a/bettor.py nl2 <haende.jsonl> <aus.json> (lesen/linien.py client)
python -I messung/familie_a/bettor.py mischen <aus.json> <teil.json>...
python -I messung/familie_a/bettor.py tabelle <aus.json> [--stufe 2]
python -I messung/familie_a/bettor.py kern <aus.json> <kern.txt> [--nl2 <nl2.json> --lam 50]
"""
import json
import os
import random
import struct
import sys
import zlib
_hier = os.path.dirname(os.path.abspath(__file__))
_wurzel = os.path.dirname(os.path.dirname(_hier))
for _p in (os.path.join(_wurzel, "lesen"), os.path.join(_wurzel, "entscheiden")):
if _p not in sys.path:
sys.path.insert(0, _p)
import eval7 # noqa: E402
import phh_linien as pl # noqa: E402
FAECHER = 20
STICHPROBE = int(os.environ.get("BETTOR_STICHPROBE", "300")) # Gegenhaende je Fall (fester Seed): Fehler ~0.03 im Perzentil
ANTWORTEN = ("x", "k", "m", "g", "u", "j")
STR = ("flop", "turn", "river")
def wert(karten):
n = len(karten)
if n == 7:
return eval7.score7(karten)
if n == 5:
return eval7.score5(karten)
import itertools
return max(eval7.score5(list(c)) for c in itertools.combinations(karten, 5))
def perzentil(loch, board, seed):
"""Anteil der Starthaende (Stichprobe ohne Loch/Board), die `loch` am Board `board` schlaegt."""
weg = set(loch) | set(board)
rest = [c for c in eval7.VOLLDECK if c not in weg]
rng = random.Random(seed)
eigen = wert(list(loch) + list(board))
s = 0.0
for _ in range(STICHPROBE):
a, b = rng.sample(rest, 2)
g = wert([a, b] + list(board))
s += 1.0 if eigen > g else 0.5 if eigen == g else 0.0
return s / STICHPROBE
def knoten(hand):
"""[(schluessel, antwort, spieler, strasse)] aller Heads-up-Wettknoten der Hand."""
n = hand["n"]
beitrag = list(hand["blinds"])
topf_vor = 0.0
strasse = 0
pfa = None
aktiv = set(range(n))
aggr = [[False] * 4 for _ in range(n)]
allin = hand.get("allin") or set()
out = []
for i, (s, p, art, betrag) in enumerate(hand["akt"]):
if s != strasse:
topf_vor += sum(beitrag)
beitrag = [0.0] * n
strasse = s
if p not in aktiv:
continue
hoch = max(beitrag)
if art == "f":
aktiv.discard(p)
continue
if s == 0:
if art == "r":
pfa = p
beitrag[p] = betrag
else:
beitrag[p] = max(beitrag[p], hoch)
continue
offen = hoch <= 0
if art == "r":
topf = topf_vor + sum(beitrag)
gr = betrag / max(topf, 1e-9) if offen else None
aggr[p][s] = True
beitrag[p] = betrag
else:
beitrag[p] = max(beitrag[p], hoch)
if not offen or len(aktiv) != 2:
continue
if art == "r":
antwort = "j" if (s, p, i) in allin else pl.stufe(gr)
else:
antwort = "x"
k = (STR[s - 1], p == pfa, s > 1 and aggr[p][s - 1])
out.append((k, antwort, p, s))
return out
def ausgang(hand):
"""Showdown einer Hand -> ({aufgedeckter Endspieler: verloren?}, gemuckte Endspieler, letzter River-Aggressor)."""
if not hand.get("showdown") or len(hand.get("board", [])) != 5:
return {}, set(), None
raus = {x[1] for x in hand["akt"] if x[2] == "f"}
ende = [p for p in range(hand["n"]) if p not in raus]
gez = hand.get("gezeigt") or {}
w = {p: wert(list(gez[p]) + list(hand["board"])) for p in ende if p in gez}
if not w:
return {}, set(), None
best = max(w.values())
agg = None
for x in hand["akt"]:
if x[0] == 3 and x[2] == "r":
agg = x[1]
return {p: v < best for p, v in w.items()}, {p for p in ende if p not in gez}, agg
def faelle(hand, seed, g=None):
"""[(schluessel, antwort, perzentil|None, gewicht)]; `g` = {"a"|"p": Aufdeck-Anteil der Verlierer} des Netzes."""
gez = hand.get("gezeigt") or {}
ohne = hand.get("ohne")
verl, _, agg = ausgang(hand) if g else ({}, set(), None)
cache = {}
erg = []
for k, a, p, s in knoten(hand):
if p == ohne:
continue
x = None
karten = gez.get(p)
if karten and len(hand["board"]) >= s + 2:
if (p, s) not in cache:
cache[(p, s)] = perzentil(karten, hand["board"][:s + 2], seed * 31 + s * 7 + p)
x = cache[(p, s)]
w = 1.0 / g["a" if p == agg else "p"] if verl.get(p) else 1.0
erg.append((k, a, x, w))
return erg
def _add(tab, k, a, x, w=1.0):
t = tab.setdefault(k, {}).setdefault(a, {"h": [0] * FAECHER, "n": 0, "n_alle": 0})
t["n_alle"] += 1
if x is not None:
t["n"] += w
t["h"][min(FAECHER - 1, int(x * FAECHER))] += w
def _netz(e):
return e["name"].split("/")[2].split("-")[0]
def _muck_laden():
pfad = os.environ.get("BETTOR_MUCK")
if not pfad:
return None
d = json.load(open(pfad, encoding="utf-8"))["g"]
return {n: {r: d["%s|%s" % (n, r)] for r in ("a", "p")} for n in {k.split("|")[0] for k in d}}
def lauf_muck(roh, aus, stufen, jede):
"""Aufdeck-Anteil der Showdown-Verlierer je Netz und Rolle (a = letzter River-Aggressor, p = sonst)."""
idx = json.load(open(os.path.join(roh, "index.json")))["eintraege"]
f = open(os.path.join(roh, "handhq.bin"), "rb")
z = {}
haende = 0
for j, e in enumerate(idx):
if pl.stake_aus(e["name"]) not in stufen or j % jede:
continue
f.seek(e["offset"])
kk = f.read(30)
if kk[:4] != b"PK\x03\x04":
continue
nl, el = struct.unpack("<HH", kk[26:30])
f.seek(e["offset"] + 30 + nl + el)
d = f.read(e["gepackt"])
text = (zlib.decompress(d, -15) if e["methode"] == 8 else d).decode("utf-8", "replace")
netz = _netz(e)
for blk in pl.phh_bloecke(text):
h = pl.phh_hand(blk)
if not h:
continue
haende += 1
verl, gemuckt, agg = ausgang(h)
for p, v in verl.items():
if v:
z.setdefault("%s|%s" % (netz, "a" if p == agg else "p"), [0, 0])[0] += 1
for p in gemuckt:
z.setdefault("%s|%s" % (netz, "a" if p == agg else "p"), [0, 0])[1] += 1
g = {k: v[0] / max(v[0] + v[1], 1) for k, v in z.items()}
with open(aus, "w", encoding="utf-8", newline="\n") as fo:
json.dump({"quelle": "PHH/HandHQ", "stufen": list(stufen), "jede": jede, "haende": haende,
"verlierer_gezeigt_gemuckt": z, "g": g}, fo, indent=1)
print(json.dumps(z), json.dumps(g))
def _schreiben(aus, tab, kopf):
zeilen = []
for k in sorted(tab, key=str):
for a, t in sorted(tab[k].items()):
st, s, pfa, vor = k
zeilen.append(dict({"stufe": st, "strasse": s, "pf_aggressor": pfa, "vorher_aggressiv": vor,
"antwort": a}, **t))
with open(aus, "w", encoding="utf-8", newline="\n") as f:
json.dump(dict(kopf, faecher=FAECHER, zeilen=zeilen), f)
def lauf_phh(roh, aus, teil, stufen):
idx = json.load(open(os.path.join(roh, "index.json")))["eintraege"]
f = open(os.path.join(roh, "handhq.bin"), "rb")
tab = {}
haende = 0
dateien = 0
muck = _muck_laden()
for j, e in enumerate(idx):
st = pl.stake_aus(e["name"])
if st not in stufen or j % teil[1] != teil[0]:
continue
f.seek(e["offset"])
kk = f.read(30)
if kk[:4] != b"PK\x03\x04":
continue
nl, el = struct.unpack("<HH", kk[26:30])
f.seek(e["offset"] + 30 + nl + el)
d = f.read(e["gepackt"])
text = (zlib.decompress(d, -15) if e["methode"] == 8 else d).decode("utf-8", "replace")
for blk in pl.phh_bloecke(text):
haende += 1
h = pl.phh_hand(blk)
if not h:
continue
for k, a, x, w in faelle(h, haende, muck[_netz(e)] if muck else None):
_add(tab, (st,) + k, a, x, w)
dateien += 1
if dateien % 40 == 0:
print("%d/%d Dateien, %d Haende" % (j, len(idx), haende), flush=True)
_schreiben(aus, tab, {"quelle": "PHH/HandHQ", "stufen": list(stufen), "haende": haende, "teilstand": j})
_schreiben(aus, tab, {"quelle": "PHH/HandHQ", "stufen": list(stufen), "haende": haende})
def lauf_nl2(pfad, aus):
tab = {}
haende = 0
for z in open(pfad, encoding="utf-8"):
hh = pl.nl2_hand(json.loads(z))
haende += 1
if not hh:
continue
for k, a, x, w in faelle(hh, haende):
_add(tab, (2,) + k, a, x, w)
_schreiben(aus, tab, {"quelle": "NL2 eigene Tische", "haende": haende})
def _laden(pfad):
d = json.load(open(pfad, encoding="utf-8"))
tab = {}
for z in d["zeilen"]:
k = (z["stufe"], z["strasse"], z["pf_aggressor"], z["vorher_aggressiv"])
t = tab.setdefault(k, {}).setdefault(z["antwort"], {"h": [0] * FAECHER, "n": 0, "n_alle": 0})
t["n"] += z["n"]
t["n_alle"] += z["n_alle"]
t["h"] = [a + b for a, b in zip(t["h"], z["h"])]
return d, tab
def mischen(aus, teile):
tab, haende, kopf = {}, 0, {}
for p in teile:
d, t = _laden(p)
haende += d.get("haende", 0)
kopf = {k: v for k, v in d.items() if k not in ("zeilen", "haende")}
for k, je in t.items():
for a, z in je.items():
u = tab.setdefault(k, {}).setdefault(a, {"h": [0] * FAECHER, "n": 0, "n_alle": 0})
u["n"] += z["n"]
u["n_alle"] += z["n_alle"]
u["h"] = [x + y for x, y in zip(u["h"], z["h"])]
_schreiben(aus, tab, dict(kopf, haende=haende))
def likelihood(je, glatt=1.0):
"""{antwort: [P(antwort | Fach)]} aus den Histogrammen eines Schluessels.
Die gezeigten Haende einer Antwort stehen fuer alle ihre Faelle (n_alle / n): so zaehlt eine Antwort,
die selten gezeigt wird, nicht zu wenig. Laplace-Glaettung `glatt` je Fach und Antwort."""
gew = {}
for a, t in je.items():
if t["n"]:
f = t["n_alle"] / t["n"]
gew[a] = [(c + glatt) * f for c in t["h"]]
if not gew:
return {}
summe = [sum(gew[a][i] for a in gew) for i in range(FAECHER)]
return {a: [g[i] / summe[i] for i in range(FAECHER)] for a, g in gew.items()}
def tabelle(pfad, stufe=None):
_, tab = _laden(pfad)
agg = {}
for k, je in tab.items():
if stufe is not None and k[0] != stufe:
continue
for a, t in je.items():
u = agg.setdefault(k[1:], {}).setdefault(a, {"h": [0] * FAECHER, "n": 0, "n_alle": 0})
u["n"] += t["n"]
u["n_alle"] += t["n_alle"]
u["h"] = [x + y for x, y in zip(u["h"], t["h"])]
for k in sorted(agg, key=str):
je = agg[k]
lk = likelihood(je)
print("== %s pfa=%s vorher=%s " % k + " ".join("%s:%d/%d" % (a, je[a]["n"], je[a]["n_alle"]) for a in ANTWORTEN if a in je))
for a in ANTWORTEN:
if a in lk:
print(" %s " % a + " ".join("%.2f" % v for v in lk[a]))
def kern(pfad, aus, nl2=None, lam=50.0):
"""Kern-Tabelle: je Zeile `strasse pfa vorher antwort` und FAECHER Likelihood-Werte.
PHH-Zaehlungen bilden den Prior; NL2 zieht nach: je Fach und Antwort zaehlt NL2 voll, PHH mit dem
Gewicht lam / (lam + n_nl2_schluessel) (hierarchisch, wie `phh_linien.prior`)."""
_, tab = _laden(pfad)
t2 = _laden(nl2)[1] if nl2 else {}
zeilen = []
schluessel = sorted({k[1:] for k in tab} | {k[1:] for k in t2}, key=str)
for k in schluessel:
je = {}
n2 = sum(t["n"] for kk, ja in t2.items() if kk[1:] == k for t in ja.values())
w = lam / (lam + n2) if n2 else 1.0
for quelle, gewicht in ((tab, w), (t2, 1.0)):
for kk, ja in quelle.items():
if kk[1:] != k:
continue
for a, t in ja.items():
u = je.setdefault(a, {"h": [0.0] * FAECHER, "n": 0.0, "n_alle": 0.0})
u["n"] += t["n"] * gewicht
u["n_alle"] += t["n_alle"] * gewicht
u["h"] = [x + y * gewicht for x, y in zip(u["h"], t["h"])]
for a, werte in sorted(likelihood(je).items()):
zeilen.append("%s %d %d %s %s" % (k[0], int(k[1]), int(k[2]), a, " ".join("%.4f" % v for v in werte)))
with open(aus, "w", encoding="utf-8", newline="\n") as f:
f.write("# P(Antwort | Brett-Perzentil) je Wettknoten: strasse pfa vorher antwort, %d Faecher (messung/familie_a/bettor.py)\n" % FAECHER)
f.write("\n".join(zeilen) + "\n")
def _arg(a, name, default=None):
for x in a:
if x.startswith("--" + name + "="):
return x.split("=", 1)[1]
if "--" + name in a and a.index("--" + name) + 1 < len(a):
return a[a.index("--" + name) + 1]
return default
if __name__ == "__main__":
a = sys.argv[1:]
if a[0] == "muck":
lauf_muck(a[1], a[2], tuple(int(x) for x in _arg(a, "stufen", "25,50").split(",")), int(_arg(a, "jede", "8")))
elif a[0] == "phh":
teil = tuple(int(x) for x in _arg(a, "teil", "0/1").split("/"))
stufen = tuple(int(x) for x in _arg(a, "stufen", "25,50").split(","))
lauf_phh(a[1], a[2], teil, stufen)
elif a[0] == "nl2":
lauf_nl2(a[1], a[2])
elif a[0] == "mischen":
mischen(a[1], a[2:])
elif a[0] == "tabelle":
s = _arg(a, "stufe")
tabelle(a[1], int(s) if s else None)
elif a[0] == "kern":
kern(a[1], a[2], _arg(a, "nl2"), float(_arg(a, "lam", "50")))
+12
View File
@@ -0,0 +1,12 @@
# P(Antwort | Brett-Perzentil) je Wettknoten: strasse pfa vorher antwort, 20 Faecher (messung/familie_a/bettor.py)
# Diagnose: nur Check-Zeilen
flop 0 0 x 0.8369 0.8395 0.8409 0.8567 0.8509 0.8524 0.8477 0.8455 0.8503 0.8442 0.8385 0.8265 0.8075 0.7603 0.7294 0.6571 0.5955 0.5280 0.4742 0.5790
flop 1 0 x 0.3300 0.3496 0.3713 0.3451 0.3886 0.3795 0.4033 0.4230 0.4165 0.4282 0.4243 0.4221 0.4202 0.4088 0.4064 0.3517 0.2594 0.2222 0.1267 0.1827
river 0 0 x 0.7918 0.8147 0.8307 0.8439 0.8477 0.8523 0.8566 0.8562 0.8493 0.8523 0.8404 0.8210 0.8038 0.7729 0.7354 0.6783 0.6056 0.4959 0.3205 0.2051
river 0 1 x 0.4343 0.4554 0.4438 0.4578 0.4716 0.4765 0.4900 0.5146 0.5260 0.5459 0.5681 0.5691 0.5631 0.5518 0.5203 0.4835 0.4349 0.3490 0.2094 0.1086
river 1 0 x 0.5770 0.5996 0.7042 0.7314 0.7712 0.7815 0.8342 0.8469 0.8458 0.8612 0.8545 0.8463 0.8388 0.8029 0.7536 0.7102 0.5995 0.4918 0.3446 0.1653
river 1 1 x 0.3416 0.3831 0.4071 0.3970 0.4607 0.4802 0.5102 0.5040 0.5598 0.5499 0.5765 0.5890 0.6123 0.5919 0.5704 0.5267 0.4527 0.3584 0.2370 0.0913
turn 0 0 x 0.8452 0.8542 0.8570 0.8588 0.8574 0.8628 0.8562 0.8609 0.8526 0.8476 0.8392 0.8227 0.7938 0.7549 0.7212 0.6736 0.6217 0.5630 0.5082 0.5279
turn 0 1 x 0.4590 0.4809 0.4611 0.4587 0.4564 0.4788 0.4537 0.4516 0.4731 0.4851 0.5116 0.4898 0.5020 0.4884 0.4585 0.4464 0.3967 0.3364 0.2711 0.2363
turn 1 0 x 0.6333 0.6342 0.6391 0.6823 0.7045 0.7197 0.7317 0.7337 0.7507 0.7466 0.7592 0.7631 0.7545 0.7085 0.6523 0.5780 0.5112 0.3938 0.3241 0.3726
turn 1 1 x 0.5411 0.5620 0.5784 0.5442 0.5578 0.5547 0.5598 0.5753 0.5835 0.6084 0.6217 0.6261 0.6367 0.6137 0.5916 0.5655 0.4916 0.3610 0.2851 0.2693
+42
View File
@@ -0,0 +1,42 @@
# P(Antwort | Brett-Perzentil) je Wettknoten: strasse pfa vorher antwort, 20 Faecher (messung/familie_a/bettor.py)
# Diagnose: nur Einsatz-Zeilen
flop 0 0 g 0.0575 0.0608 0.0594 0.0515 0.0495 0.0469 0.0503 0.0523 0.0429 0.0417 0.0455 0.0462 0.0514 0.0691 0.0790 0.1136 0.1356 0.1650 0.1857 0.1438
flop 0 0 k 0.0189 0.0146 0.0172 0.0152 0.0192 0.0201 0.0205 0.0234 0.0248 0.0287 0.0288 0.0331 0.0329 0.0347 0.0401 0.0437 0.0551 0.0563 0.0600 0.0562
flop 0 0 m 0.0630 0.0610 0.0644 0.0586 0.0599 0.0621 0.0637 0.0624 0.0644 0.0686 0.0680 0.0745 0.0868 0.1096 0.1209 0.1450 0.1629 0.1796 0.1990 0.1600
flop 0 0 u 0.0236 0.0241 0.0181 0.0181 0.0205 0.0184 0.0178 0.0165 0.0177 0.0168 0.0192 0.0196 0.0214 0.0264 0.0306 0.0406 0.0509 0.0711 0.0811 0.0610
flop 1 0 g 0.0867 0.0757 0.0810 0.0800 0.0689 0.0747 0.0615 0.0627 0.0638 0.0558 0.0636 0.0611 0.0617 0.0682 0.0577 0.0701 0.0784 0.0894 0.1282 0.1076
flop 1 0 k 0.0612 0.0541 0.0635 0.0644 0.0743 0.0760 0.0687 0.0756 0.0701 0.0700 0.0696 0.0714 0.0669 0.0742 0.0724 0.0774 0.0849 0.0899 0.0746 0.0838
flop 1 0 m 0.5022 0.5067 0.4680 0.4884 0.4513 0.4520 0.4461 0.4214 0.4367 0.4302 0.4247 0.4255 0.4325 0.4296 0.4445 0.4803 0.5572 0.5753 0.6433 0.6057
flop 1 0 u 0.0193 0.0133 0.0156 0.0215 0.0163 0.0173 0.0201 0.0170 0.0127 0.0157 0.0179 0.0198 0.0187 0.0192 0.0189 0.0204 0.0200 0.0232 0.0273 0.0202
river 0 0 g 0.0506 0.0470 0.0437 0.0331 0.0316 0.0298 0.0264 0.0246 0.0261 0.0253 0.0227 0.0255 0.0293 0.0337 0.0387 0.0463 0.0635 0.0869 0.1483 0.1849
river 0 0 k 0.0319 0.0280 0.0272 0.0298 0.0301 0.0353 0.0367 0.0382 0.0446 0.0471 0.0552 0.0656 0.0711 0.0880 0.1032 0.1237 0.1414 0.1510 0.1478 0.1319
river 0 0 m 0.0936 0.0856 0.0764 0.0710 0.0717 0.0672 0.0663 0.0665 0.0642 0.0620 0.0663 0.0753 0.0820 0.0917 0.1037 0.1269 0.1551 0.2051 0.2685 0.3157
river 0 0 u 0.0318 0.0244 0.0218 0.0220 0.0187 0.0150 0.0138 0.0144 0.0157 0.0132 0.0153 0.0124 0.0137 0.0136 0.0188 0.0247 0.0343 0.0608 0.1148 0.1622
river 0 1 g 0.0778 0.0768 0.0776 0.0636 0.0578 0.0528 0.0427 0.0365 0.0334 0.0267 0.0243 0.0175 0.0183 0.0173 0.0181 0.0215 0.0279 0.0469 0.0934 0.1413
river 0 1 k 0.1835 0.1685 0.1886 0.2051 0.2073 0.2292 0.2481 0.2580 0.2757 0.2825 0.2838 0.3020 0.3089 0.3220 0.3353 0.3469 0.3527 0.3427 0.3050 0.2515
river 0 1 m 0.2777 0.2632 0.2575 0.2462 0.2323 0.2194 0.1997 0.1759 0.1446 0.1304 0.1127 0.1013 0.1002 0.0998 0.1179 0.1350 0.1727 0.2391 0.3480 0.4127
river 0 1 u 0.0264 0.0356 0.0322 0.0269 0.0306 0.0218 0.0192 0.0148 0.0201 0.0142 0.0109 0.0100 0.0094 0.0090 0.0083 0.0130 0.0118 0.0222 0.0442 0.0858
river 1 0 g 0.0692 0.0819 0.0415 0.0331 0.0233 0.0263 0.0154 0.0171 0.0145 0.0113 0.0088 0.0129 0.0109 0.0070 0.0150 0.0207 0.0303 0.0386 0.0838 0.1517
river 1 0 k 0.0867 0.0683 0.0649 0.0603 0.0622 0.0622 0.0504 0.0452 0.0562 0.0541 0.0621 0.0688 0.0730 0.0941 0.1195 0.1316 0.1593 0.1836 0.1867 0.1627
river 1 0 m 0.2372 0.2251 0.1686 0.1644 0.1319 0.1189 0.0929 0.0850 0.0752 0.0657 0.0620 0.0662 0.0712 0.0900 0.1075 0.1301 0.2013 0.2716 0.3507 0.4352
river 1 0 u 0.0299 0.0250 0.0208 0.0109 0.0115 0.0111 0.0071 0.0059 0.0083 0.0076 0.0126 0.0058 0.0061 0.0060 0.0043 0.0074 0.0095 0.0144 0.0342 0.0851
river 1 1 g 0.0992 0.0665 0.0445 0.0590 0.0530 0.0446 0.0326 0.0340 0.0329 0.0287 0.0268 0.0182 0.0161 0.0153 0.0174 0.0180 0.0299 0.0367 0.0658 0.1155
river 1 1 k 0.2150 0.1978 0.2042 0.2395 0.2280 0.2414 0.2381 0.2429 0.2316 0.2688 0.2581 0.2708 0.2652 0.2842 0.2994 0.3129 0.3233 0.3418 0.3230 0.2834
river 1 1 m 0.3061 0.3205 0.3165 0.2851 0.2278 0.2022 0.1964 0.1891 0.1509 0.1324 0.1236 0.1069 0.0961 0.0976 0.1049 0.1289 0.1772 0.2399 0.3376 0.4327
river 1 1 u 0.0358 0.0299 0.0260 0.0181 0.0295 0.0310 0.0221 0.0290 0.0243 0.0197 0.0146 0.0147 0.0099 0.0107 0.0076 0.0134 0.0168 0.0230 0.0364 0.0768
turn 0 0 g 0.0463 0.0398 0.0458 0.0388 0.0394 0.0376 0.0368 0.0340 0.0348 0.0358 0.0360 0.0387 0.0470 0.0575 0.0678 0.0813 0.0984 0.1093 0.1243 0.1250
turn 0 0 k 0.0235 0.0223 0.0217 0.0218 0.0256 0.0267 0.0323 0.0277 0.0364 0.0356 0.0368 0.0420 0.0450 0.0547 0.0636 0.0733 0.0845 0.0983 0.0996 0.0965
turn 0 0 m 0.0664 0.0680 0.0627 0.0672 0.0620 0.0601 0.0632 0.0660 0.0663 0.0721 0.0762 0.0850 0.0995 0.1159 0.1281 0.1432 0.1630 0.1915 0.2115 0.1953
turn 0 0 u 0.0186 0.0158 0.0128 0.0134 0.0157 0.0129 0.0116 0.0114 0.0099 0.0089 0.0118 0.0115 0.0146 0.0170 0.0192 0.0286 0.0326 0.0378 0.0565 0.0552
turn 0 1 g 0.0406 0.0449 0.0461 0.0435 0.0386 0.0399 0.0418 0.0353 0.0360 0.0339 0.0285 0.0272 0.0242 0.0226 0.0286 0.0296 0.0357 0.0447 0.0716 0.1038
turn 0 1 k 0.2543 0.2320 0.2532 0.2647 0.2560 0.2658 0.2638 0.2828 0.2867 0.2887 0.2865 0.3074 0.3035 0.3137 0.3231 0.3187 0.3166 0.3126 0.2941 0.2449
turn 0 1 m 0.2347 0.2276 0.2276 0.2206 0.2331 0.2045 0.2246 0.2172 0.1909 0.1801 0.1622 0.1686 0.1593 0.1666 0.1785 0.1927 0.2371 0.2877 0.3384 0.3816
turn 0 1 u 0.0111 0.0142 0.0117 0.0123 0.0157 0.0108 0.0158 0.0130 0.0131 0.0121 0.0110 0.0069 0.0109 0.0085 0.0113 0.0125 0.0138 0.0187 0.0248 0.0333
turn 1 0 g 0.0544 0.0451 0.0386 0.0304 0.0250 0.0248 0.0318 0.0229 0.0221 0.0167 0.0180 0.0160 0.0186 0.0154 0.0209 0.0311 0.0396 0.0515 0.0701 0.0579
turn 1 0 k 0.0561 0.0616 0.0546 0.0643 0.0689 0.0549 0.0653 0.0668 0.0620 0.0624 0.0612 0.0720 0.0663 0.0779 0.1002 0.1176 0.1185 0.1480 0.1475 0.1893
turn 1 0 m 0.2475 0.2501 0.2600 0.2129 0.1954 0.1944 0.1669 0.1728 0.1621 0.1707 0.1592 0.1468 0.1567 0.1950 0.2222 0.2679 0.3211 0.3932 0.4456 0.3656
turn 1 0 u 0.0087 0.0089 0.0076 0.0101 0.0062 0.0061 0.0042 0.0039 0.0031 0.0036 0.0024 0.0021 0.0040 0.0032 0.0044 0.0054 0.0095 0.0134 0.0127 0.0145
turn 1 1 g 0.0482 0.0342 0.0349 0.0496 0.0316 0.0379 0.0292 0.0287 0.0275 0.0228 0.0211 0.0226 0.0187 0.0197 0.0215 0.0276 0.0309 0.0499 0.0614 0.0651
turn 1 1 k 0.1435 0.1512 0.1503 0.1546 0.1573 0.1764 0.1909 0.1966 0.1910 0.1835 0.1889 0.1832 0.1785 0.2006 0.2035 0.2056 0.2267 0.2248 0.2217 0.2163
turn 1 1 m 0.2537 0.2347 0.2236 0.2340 0.2396 0.2157 0.2049 0.1858 0.1862 0.1748 0.1552 0.1596 0.1565 0.1570 0.1728 0.1895 0.2357 0.3433 0.4069 0.4259
turn 1 1 u 0.0135 0.0178 0.0128 0.0176 0.0138 0.0152 0.0153 0.0136 0.0118 0.0105 0.0131 0.0085 0.0096 0.0090 0.0107 0.0118 0.0151 0.0210 0.0250 0.0233
+22
View File
@@ -0,0 +1,22 @@
# P(Antwort | Brett-Perzentil) je Wettknoten: strasse pfa vorher antwort, 20 Faecher (messung/familie_a/bettor.py)
# Diagnose: nur River
river 0 0 g 0.0506 0.0470 0.0437 0.0331 0.0316 0.0298 0.0264 0.0246 0.0261 0.0253 0.0227 0.0255 0.0293 0.0337 0.0387 0.0463 0.0635 0.0869 0.1483 0.1849
river 0 0 k 0.0319 0.0280 0.0272 0.0298 0.0301 0.0353 0.0367 0.0382 0.0446 0.0471 0.0552 0.0656 0.0711 0.0880 0.1032 0.1237 0.1414 0.1510 0.1478 0.1319
river 0 0 m 0.0936 0.0856 0.0764 0.0710 0.0717 0.0672 0.0663 0.0665 0.0642 0.0620 0.0663 0.0753 0.0820 0.0917 0.1037 0.1269 0.1551 0.2051 0.2685 0.3157
river 0 0 u 0.0318 0.0244 0.0218 0.0220 0.0187 0.0150 0.0138 0.0144 0.0157 0.0132 0.0153 0.0124 0.0137 0.0136 0.0188 0.0247 0.0343 0.0608 0.1148 0.1622
river 0 0 x 0.7918 0.8147 0.8307 0.8439 0.8477 0.8523 0.8566 0.8562 0.8493 0.8523 0.8404 0.8210 0.8038 0.7729 0.7354 0.6783 0.6056 0.4959 0.3205 0.2051
river 0 1 g 0.0778 0.0768 0.0776 0.0636 0.0578 0.0528 0.0427 0.0365 0.0334 0.0267 0.0243 0.0175 0.0183 0.0173 0.0181 0.0215 0.0279 0.0469 0.0934 0.1413
river 0 1 k 0.1835 0.1685 0.1886 0.2051 0.2073 0.2292 0.2481 0.2580 0.2757 0.2825 0.2838 0.3020 0.3089 0.3220 0.3353 0.3469 0.3527 0.3427 0.3050 0.2515
river 0 1 m 0.2777 0.2632 0.2575 0.2462 0.2323 0.2194 0.1997 0.1759 0.1446 0.1304 0.1127 0.1013 0.1002 0.0998 0.1179 0.1350 0.1727 0.2391 0.3480 0.4127
river 0 1 u 0.0264 0.0356 0.0322 0.0269 0.0306 0.0218 0.0192 0.0148 0.0201 0.0142 0.0109 0.0100 0.0094 0.0090 0.0083 0.0130 0.0118 0.0222 0.0442 0.0858
river 0 1 x 0.4343 0.4554 0.4438 0.4578 0.4716 0.4765 0.4900 0.5146 0.5260 0.5459 0.5681 0.5691 0.5631 0.5518 0.5203 0.4835 0.4349 0.3490 0.2094 0.1086
river 1 0 g 0.0692 0.0819 0.0415 0.0331 0.0233 0.0263 0.0154 0.0171 0.0145 0.0113 0.0088 0.0129 0.0109 0.0070 0.0150 0.0207 0.0303 0.0386 0.0838 0.1517
river 1 0 k 0.0867 0.0683 0.0649 0.0603 0.0622 0.0622 0.0504 0.0452 0.0562 0.0541 0.0621 0.0688 0.0730 0.0941 0.1195 0.1316 0.1593 0.1836 0.1867 0.1627
river 1 0 m 0.2372 0.2251 0.1686 0.1644 0.1319 0.1189 0.0929 0.0850 0.0752 0.0657 0.0620 0.0662 0.0712 0.0900 0.1075 0.1301 0.2013 0.2716 0.3507 0.4352
river 1 0 u 0.0299 0.0250 0.0208 0.0109 0.0115 0.0111 0.0071 0.0059 0.0083 0.0076 0.0126 0.0058 0.0061 0.0060 0.0043 0.0074 0.0095 0.0144 0.0342 0.0851
river 1 0 x 0.5770 0.5996 0.7042 0.7314 0.7712 0.7815 0.8342 0.8469 0.8458 0.8612 0.8545 0.8463 0.8388 0.8029 0.7536 0.7102 0.5995 0.4918 0.3446 0.1653
river 1 1 g 0.0992 0.0665 0.0445 0.0590 0.0530 0.0446 0.0326 0.0340 0.0329 0.0287 0.0268 0.0182 0.0161 0.0153 0.0174 0.0180 0.0299 0.0367 0.0658 0.1155
river 1 1 k 0.2150 0.1978 0.2042 0.2395 0.2280 0.2414 0.2381 0.2429 0.2316 0.2688 0.2581 0.2708 0.2652 0.2842 0.2994 0.3129 0.3233 0.3418 0.3230 0.2834
river 1 1 m 0.3061 0.3205 0.3165 0.2851 0.2278 0.2022 0.1964 0.1891 0.1509 0.1324 0.1236 0.1069 0.0961 0.0976 0.1049 0.1289 0.1772 0.2399 0.3376 0.4327
river 1 1 u 0.0358 0.0299 0.0260 0.0181 0.0295 0.0310 0.0221 0.0290 0.0243 0.0197 0.0146 0.0147 0.0099 0.0107 0.0076 0.0134 0.0168 0.0230 0.0364 0.0768
river 1 1 x 0.3416 0.3831 0.4071 0.3970 0.4607 0.4802 0.5102 0.5040 0.5598 0.5499 0.5765 0.5890 0.6123 0.5919 0.5704 0.5267 0.4527 0.3584 0.2370 0.0913
+18
View File
@@ -0,0 +1,18 @@
# P(Antwort | Brett-Perzentil) je Wettknoten: strasse pfa vorher antwort, 20 Faecher (messung/familie_a/bettor.py)
# Diagnose: nur River-Einsaetze
river 0 0 g 0.0506 0.0470 0.0437 0.0331 0.0316 0.0298 0.0264 0.0246 0.0261 0.0253 0.0227 0.0255 0.0293 0.0337 0.0387 0.0463 0.0635 0.0869 0.1483 0.1849
river 0 0 k 0.0319 0.0280 0.0272 0.0298 0.0301 0.0353 0.0367 0.0382 0.0446 0.0471 0.0552 0.0656 0.0711 0.0880 0.1032 0.1237 0.1414 0.1510 0.1478 0.1319
river 0 0 m 0.0936 0.0856 0.0764 0.0710 0.0717 0.0672 0.0663 0.0665 0.0642 0.0620 0.0663 0.0753 0.0820 0.0917 0.1037 0.1269 0.1551 0.2051 0.2685 0.3157
river 0 0 u 0.0318 0.0244 0.0218 0.0220 0.0187 0.0150 0.0138 0.0144 0.0157 0.0132 0.0153 0.0124 0.0137 0.0136 0.0188 0.0247 0.0343 0.0608 0.1148 0.1622
river 0 1 g 0.0778 0.0768 0.0776 0.0636 0.0578 0.0528 0.0427 0.0365 0.0334 0.0267 0.0243 0.0175 0.0183 0.0173 0.0181 0.0215 0.0279 0.0469 0.0934 0.1413
river 0 1 k 0.1835 0.1685 0.1886 0.2051 0.2073 0.2292 0.2481 0.2580 0.2757 0.2825 0.2838 0.3020 0.3089 0.3220 0.3353 0.3469 0.3527 0.3427 0.3050 0.2515
river 0 1 m 0.2777 0.2632 0.2575 0.2462 0.2323 0.2194 0.1997 0.1759 0.1446 0.1304 0.1127 0.1013 0.1002 0.0998 0.1179 0.1350 0.1727 0.2391 0.3480 0.4127
river 0 1 u 0.0264 0.0356 0.0322 0.0269 0.0306 0.0218 0.0192 0.0148 0.0201 0.0142 0.0109 0.0100 0.0094 0.0090 0.0083 0.0130 0.0118 0.0222 0.0442 0.0858
river 1 0 g 0.0692 0.0819 0.0415 0.0331 0.0233 0.0263 0.0154 0.0171 0.0145 0.0113 0.0088 0.0129 0.0109 0.0070 0.0150 0.0207 0.0303 0.0386 0.0838 0.1517
river 1 0 k 0.0867 0.0683 0.0649 0.0603 0.0622 0.0622 0.0504 0.0452 0.0562 0.0541 0.0621 0.0688 0.0730 0.0941 0.1195 0.1316 0.1593 0.1836 0.1867 0.1627
river 1 0 m 0.2372 0.2251 0.1686 0.1644 0.1319 0.1189 0.0929 0.0850 0.0752 0.0657 0.0620 0.0662 0.0712 0.0900 0.1075 0.1301 0.2013 0.2716 0.3507 0.4352
river 1 0 u 0.0299 0.0250 0.0208 0.0109 0.0115 0.0111 0.0071 0.0059 0.0083 0.0076 0.0126 0.0058 0.0061 0.0060 0.0043 0.0074 0.0095 0.0144 0.0342 0.0851
river 1 1 g 0.0992 0.0665 0.0445 0.0590 0.0530 0.0446 0.0326 0.0340 0.0329 0.0287 0.0268 0.0182 0.0161 0.0153 0.0174 0.0180 0.0299 0.0367 0.0658 0.1155
river 1 1 k 0.2150 0.1978 0.2042 0.2395 0.2280 0.2414 0.2381 0.2429 0.2316 0.2688 0.2581 0.2708 0.2652 0.2842 0.2994 0.3129 0.3233 0.3418 0.3230 0.2834
river 1 1 m 0.3061 0.3205 0.3165 0.2851 0.2278 0.2022 0.1964 0.1891 0.1509 0.1324 0.1236 0.1069 0.0961 0.0976 0.1049 0.1289 0.1772 0.2399 0.3376 0.4327
river 1 1 u 0.0358 0.0299 0.0260 0.0181 0.0295 0.0310 0.0221 0.0290 0.0243 0.0197 0.0146 0.0147 0.0099 0.0107 0.0076 0.0134 0.0168 0.0230 0.0364 0.0768
+69
View File
@@ -0,0 +1,69 @@
"""Familie A auf echten Live-Haenden: jede NL2-Entscheidung gegen einen Einsatz, der den Helden all-in
setzt, oder gegen einen River-Einsatz >= 1x Pot, neu gerechnet mit Live und Kandidaten-Armen.
Ausgabe nur Hand-ID, Karten, Linie, Aktionen, Netto (keine Gegnerkennung).
python -I messung/familie_a/echtfaelle.py <live-wurzel> <kern> ARM=K=V[;K=V] ...
"""
import json, os, subprocess, sys
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', '..', 'lesen'))
import roentgen
L, K = sys.argv[1], os.path.abspath(sys.argv[2])
arme = {'live': {}}
for a in sys.argv[3:]:
n, kv = a.split('=', 1)
arme[n] = dict(x.split('=', 1) for x in kv.split(';') if x)
base = dict(os.environ); base.update(roentgen.lies_schalter(os.path.join(L, 'betrieb', 'kern_schalter.txt')))
H = {}
for h in roentgen.jsonl(os.path.join(L, 'archiv', 'lauf', 'haende.jsonl')):
if h.get('stake') == '0.01/0.02':
H[str(h['hand'])] = h
RANG = {'ACE': 'A', 'KING': 'K', 'QUEEN': 'Q', 'JACK': 'J', 'TEN': 'T', 'NINE': '9', 'EIGHT': '8', 'SEVEN': '7',
'SIX': '6', 'FIVE': '5', 'FOUR': '4', 'THREE': '3', 'TWO': '2'}
def kz(xs): return ''.join(RANG.get(x.get('rank'), '?') + x.get('suit', '')[:1].lower() for x in (xs or []) if isinstance(x, dict))
def brett(b):
if isinstance(b, dict):
return [c for s in ('FLOP', 'TURN', 'RIVER') for c in (b.get(s) or [])]
return b or []
faelle = []
gesehen = set()
for z in roentgen.jsonl(os.path.join(L, 'archiv', 'lauf', 'zuege.jsonl')):
h = str(z.get('hand'))
if h not in H: continue
a = roentgen._als_dict(z.get('spot'))
if not isinstance(a, dict) or a.get('street') in (None, 'PREFLOP') or not a.get('legalActions'): continue
tc, pot, st = a.get('toCall') or 0, a.get('pot') or 0, a.get('heroStack') or 0
if tc <= 0: continue
vor = pot - tc # `pot` includes the bet facing hero; the call share of it is at most `tc`
allin = tc >= st - 1e-9
gross = a.get('street') == 'RIVER' and vor > 0 and tc / vor >= 1.0
if not (allin or gross): continue
k = (h, a.get('street'), tc)
if k in gesehen: continue
gesehen.add(k)
faelle.append((h, a, z))
def lauf(env, spots):
p = subprocess.Popen([K], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, env=env)
out = p.communicate(''.join(json.dumps(s) + '\n' for s in spots).encode())[0].decode().splitlines()
return [json.loads(x) for x in out]
ant = {}
for n, ov in arme.items():
e = dict(base); e.update(ov)
ant[n] = lauf(e, [a for _, a, _ in faelle])
summe = {n: 0.0 for n in arme}
print('hand street karten brett toCall pot rest damals netto_bb |', ' '.join(arme))
for i, (h, a, z) in enumerate(faelle):
bb = H[h].get('bb') or 0.02
netto = (H[h].get('netto') or 0) / bb
akt = {n: ant[n][i]['action'] for n in arme}
zeile = f"{h} {a['street']} {kz(a.get('heroCards'))} {kz(brett(a.get('board')))} {a['toCall']} {a['pot']} {a['heroStack']} {z.get('aktion')} {netto:+.1f} | " + ' '.join(f"{n}={akt[n]}" for n in arme)
if any(akt[n] != akt['live'] for n in arme) or akt['live'] == 'CALL' or os.environ.get('ALLE'):
print(zeile + (' <-- anders' if any(akt[n] != akt['live'] for n in arme) else ''))
for n in arme:
if akt[n] == 'CALL': summe[n] += 1
print('faelle', len(faelle), 'calls je arm', summe)
+107
View File
@@ -0,0 +1,107 @@
"""Familie C des Leck-Finders: Entscheidungen gegen einen Einsatz nach dem Flop, der NICHT all-in setzt, an
PHH-Spots mit bekannter Gegnerhand (der echte Spieler callte, beide Haende spaeter offen).
EV(call) gegen die echte Hand, EV(fold) = 0, Raise zaehlt wie Call (untere Schranke fuer den Raise):
River: echter Ausgang am Brett (Rake 5 %, hoechstens 10 bb).
Flop/Turn: Equity gegen die echte Hand (`eq`) mal Topf nach dem Call minus Call - ohne spaetere Einsaetze.
Muck: verlorene Calls sind unterzaehlt (der Verlierer muckt am River-Showdown); jede am Ende verlorene Hand zaehlt
mit dem River-Muck-Faktor ihres Netzes (`konfrontation` aus jams-nl25.json). Verzerrung gegen das Callen bleibt auf
Flop/Turn: ein Setzer, der spaeter aufgibt, zeigt nie; die Spots halten zu starke Setzer-Haende.
python -I messung/familie_a/familie_c.py <spots.jsonl> <jams.json> <aus.json> <antworten.jsonl>...
(erste Antwortdatei = Bezug, meist live)
"""
import collections
import json
import os
import sys
G = os.environ.get("LECKFINDER_WURZEL", os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..", "..",
"gedaechtnis-voll-1f97d3"))
sys.path.insert(0, os.path.join(G, "lesen"))
sys.path.insert(0, os.path.join(G, "entscheiden"))
import eval7 # noqa: E402
import leckfinder as lf # noqa: E402
import poolruf_eichung as pe # noqa: E402
def eimer(r):
return "klein" if r < 0.55 else "mittel" if r < 1.0 else "gross"
def main(spots, jams_pfad, aus, antworten):
jams = json.load(open(jams_pfad, encoding="utf-8"))
kf = jams["konfrontation"]
sp_by = {}
for z in open(spots, encoding="utf-8"):
sp = json.loads(z)
if sp["strasse"] < 1 or sp["tc"] <= 1e-9 or sp["echt"] != "call" or lf.gegen_allin(sp):
continue
if len(sp["board"]) != 5:
continue
sp.pop("req", None)
a_ = eval7.score7(eval7.karten(sp["held"]) + eval7.karten(sp["board"]))
b_ = eval7.score7(eval7.karten(sp["gegner"]) + eval7.karten(sp["board"]))
ausg = 1.0 if a_ > b_ else 0.5 if a_ == b_ else 0.0
w = lf.muck_faktor(kf.get("3|%s" % sp["netz"], {}), "verl_gezeigt", "verl_gemuckt") if ausg == 0.0 else 1.0
if sp["strasse"] == 3:
ev = ausg * lf.nach_rake(sp["topf"] + sp["tc"]) - sp["tc"]
else:
ev = sp["eq"] * lf.nach_rake(sp["topf"] + sp["tc"]) - sp["tc"]
sp_by[sp["id"]] = (sp, w, ev)
arme = []
tab = collections.defaultdict(lambda: collections.defaultdict(lambda: [0.0, 0.0, 0, 0])) # w-n, w-ev, n, folds
for sp, w, ev in sp_by.values(): # feste Alternative: immer callen
st = ("flop", "turn", "river")[sp["strasse"] - 1]
kl = pe.KLASSEN[pe.klasse(sp["held"], sp["brett"])]
g = eimer(sp["tc"] / max(sp["topf"] - sp["tc"], 1e-9))
for key in ((st, g, kl), (st, g, "*"), ("alle", g, "*"), ("alle", "*", "*"), (st, "*", "*")):
c = tab[key]["immer_call"]
c[0] += w
c[1] += w * ev
c[2] += 1
for pfad in antworten:
arm = os.path.basename(pfad).split(".")[0]
arme.append(arm)
for z in open(pfad, encoding="utf-8"):
a = json.loads(z)
t = sp_by.get(a["id"])
if t is None:
continue
sp, w, ev = t
act = a.get("action")
if act not in ("FOLD", "CALL", "RAISE"):
continue
e = 0.0 if act == "FOLD" else ev
st = ("flop", "turn", "river")[sp["strasse"] - 1]
kl = pe.KLASSEN[pe.klasse(sp["held"], sp["brett"])]
g = eimer(sp["tc"] / max(sp["topf"] - sp["tc"], 1e-9))
for key in ((st, g, kl), (st, g, "*"), ("alle", g, "*"), ("alle", "*", "*"), (st, "*", "*")):
c = tab[key][arm]
c[0] += w
c[1] += w * e
c[2] += 1
c[3] += act == "FOLD"
erg = {"spots": len(sp_by), "arme": arme, "zeilen": {}}
bezug = arme[0]
for key in sorted(tab, key=lambda k: (k[0] != "alle", k[0], k[1] != "*", k[1], k[2] != "*", k[2])):
erg["zeilen"][" ".join(key)] = {arm: {"n": tab[key][arm][2], "ev_bb": round(tab[key][arm][1], 1),
"fold": tab[key][arm][3]} for arm in arme + ["immer_call"]}
with open(aus, "w", encoding="utf-8", newline="\n") as f:
json.dump(erg, f, indent=1)
print("spots", len(sp_by), "| EV in bb (muck-gewichtet), Delta gegen", bezug)
print("%-30s %7s" % ("strasse groesse klasse", "n") + "".join("%22s" % a for a in arme + ["immer_call"]))
for key in sorted(tab, key=lambda k: (k[0] != "alle", k[0], k[1] != "*", k[1], k[2] != "*", k[2])):
n = tab[key][bezug][2]
if key[2] != "*" and n < 200:
continue
zeile = "%-30s %7d" % (" ".join(key), n)
for arm in arme + ["immer_call"]:
c = tab[key][arm]
d = c[1] - tab[key][bezug][1]
zeile += "%22s" % ("%+9.0f f%3.0f%%" % (d if arm != bezug else c[1], 100.0 * c[3] / max(c[2], 1)))
print(zeile)
if __name__ == "__main__":
main(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4:])
+110
View File
@@ -0,0 +1,110 @@
{
"FLOP gross": {
"fold": 11,
"n": 17,
"anteil": 0.647,
"w95": [
0.413,
0.827
]
},
"FLOP klein": {
"fold": 82,
"n": 228,
"anteil": 0.36,
"w95": [
0.3,
0.424
]
},
"FLOP mittel": {
"fold": 34,
"n": 72,
"anteil": 0.472,
"w95": [
0.361,
0.586
]
},
"RIVER gross": {
"fold": 15,
"n": 29,
"anteil": 0.517,
"w95": [
0.344,
0.686
]
},
"RIVER klein": {
"fold": 30,
"n": 74,
"anteil": 0.405,
"w95": [
0.301,
0.519
]
},
"RIVER mittel": {
"fold": 24,
"n": 48,
"anteil": 0.5,
"w95": [
0.364,
0.636
]
},
"TURN gross": {
"fold": 19,
"n": 27,
"anteil": 0.704,
"w95": [
0.515,
0.841
]
},
"TURN klein": {
"fold": 32,
"n": 110,
"anteil": 0.291,
"w95": [
0.214,
0.382
]
},
"TURN mittel": {
"fold": 42,
"n": 92,
"anteil": 0.457,
"w95": [
0.359,
0.558
]
},
"alle klein": {
"fold": 144,
"n": 412,
"anteil": 0.35,
"w95": [
0.305,
0.397
]
},
"alle mittel": {
"fold": 100,
"n": 212,
"anteil": 0.472,
"w95": [
0.406,
0.539
]
},
"alle gross": {
"fold": 45,
"n": 73,
"anteil": 0.616,
"w95": [
0.502,
0.719
]
}
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+5
View File
@@ -0,0 +1,5 @@
gg35 fertig 2026-11-17T18:04:08
gg50 fertig 2026-11-17T18:04:14
live fertig 2026-11-17T18:05:21
bettor fertig 2026-11-17T18:39:12
bettorgg fertig 2026-11-17T18:39:21
+9
View File
@@ -0,0 +1,9 @@
(Get-Process -Id $PID).PriorityClass='Idle'
$G='D:\Projects\pokerfreak\.claude\worktrees\gedaechtnis-voll-1f97d3'
$O='D:\Projects\pokerfreak\.claude\worktrees\mock-poker-client-11c1fe\messung\familie_a\leck'
$K='D:\Projects\pokerfreak\.claude\worktrees\mock-poker-client-11c1fe\messung\familie_a\bin\pokerbench-familiea-bettor.exe'
Remove-Item Env:UEBERBET -ErrorAction SilentlyContinue
Remove-Item Env:GEGEN_GROSS -ErrorAction SilentlyContinue
Remove-Item Env:BETTOR -ErrorAction SilentlyContinue
& python -I "$G\lesen\leckfinder.py" entscheiden "$G\messung\leckfinder\spots-nl25.jsonl" "$O\bettor.jsonl" $K bettor --prozesse 6 --zusatz "BETTOR=D:/Projects/pokerfreak/.claude/worktrees/mock-poker-client-11c1fe/messung/familie_a/bettor-kern.txt" *> "$O\entscheiden-bettor.log"
"bettor fertig $(Get-Date -Format s)" | Out-File -Append -Encoding utf8 "$O\fertig.txt"
+9
View File
@@ -0,0 +1,9 @@
(Get-Process -Id $PID).PriorityClass='Idle'
$G='D:\Projects\pokerfreak\.claude\worktrees\gedaechtnis-voll-1f97d3'
$O='D:\Projects\pokerfreak\.claude\worktrees\mock-poker-client-11c1fe\messung\familie_a\leck'
$K='D:\Projects\pokerfreak\.claude\worktrees\mock-poker-client-11c1fe\messung\familie_a\bin\pokerbench-familiea-bettor.exe'
Remove-Item Env:UEBERBET -ErrorAction SilentlyContinue
Remove-Item Env:GEGEN_GROSS -ErrorAction SilentlyContinue
Remove-Item Env:BETTOR -ErrorAction SilentlyContinue
& python -I "$G\lesen\leckfinder.py" entscheiden "$G\messung\leckfinder\spots-nl25.jsonl" "$O\bettorgg.jsonl" $K bettorgg --prozesse 6 --zusatz "BETTOR=D:/Projects/pokerfreak/.claude/worktrees/mock-poker-client-11c1fe/messung/familie_a/bettor-kern.txt;GEGEN_GROSS=0.5" *> "$O\entscheiden-bettorgg.log"
"bettorgg fertig $(Get-Date -Format s)" | Out-File -Append -Encoding utf8 "$O\fertig.txt"
+10
View File
@@ -0,0 +1,10 @@
(Get-Process -Id $PID).PriorityClass='Idle'
$G='D:\Projects\pokerfreak\.claude\worktrees\gedaechtnis-voll-1f97d3'
$O='D:\Projects\pokerfreak\.claude\worktrees\mock-poker-client-11c1fe\messung\familie_a\leck'
$K='D:\Projects\pokerfreak\.claude\worktrees\mock-poker-client-11c1fe\messung\familie_a\bin\pokerbench-familiea-replay-u.exe'
Remove-Item Env:UEBERBET -ErrorAction SilentlyContinue
Remove-Item Env:GEGEN_GROSS -ErrorAction SilentlyContinue
Remove-Item Env:BETTOR -ErrorAction SilentlyContinue
Remove-Item Env:UEBERSCHUSS -ErrorAction SilentlyContinue
& python -I "$G\lesen\leckfinder.py" entscheiden "$G\messung\leckfinder\spots-nl25.jsonl" "$O\bgu.jsonl" $K bgu --prozesse 6 --zusatz "BETTOR=D:/Projects/pokerfreak/.claude/worktrees/mock-poker-client-11c1fe/messung/familie_a/bettor-kern.txt;GEGEN_GROSS=0.5;UEBERSCHUSS=1" *> "$O\entscheiden-bgu.log"
"bgu fertig $(Get-Date -Format s)" | Out-File -Append -Encoding utf8 "$O\fertig.txt"
+8
View File
@@ -0,0 +1,8 @@
(Get-Process -Id $PID).PriorityClass='Idle'
$G='D:\Projects\pokerfreak\.claude\worktrees\gedaechtnis-voll-1f97d3'
$O='D:\Projects\pokerfreak\.claude\worktrees\mock-poker-client-11c1fe\messung\familie_a\leck'
$K='D:\Projects\pokerfreak\.claude\worktrees\mock-poker-client-11c1fe\messung\familie_a\bin\pokerbench-familiea-leckfinder.exe'
Remove-Item Env:UEBERBET -ErrorAction SilentlyContinue
Remove-Item Env:GEGEN_GROSS -ErrorAction SilentlyContinue
& python -I "$G\lesen\leckfinder.py" entscheiden "$G\messung\leckfinder\spots-nl25.jsonl" "$O\gg35.jsonl" $K gg35 --prozesse 4 --zusatz "GEGEN_GROSS=0.35" *> "$O\entscheiden-gg35.log"
"gg35 fertig $(Get-Date -Format s)" | Out-File -Append -Encoding utf8 "$O\fertig.txt"
+8
View File
@@ -0,0 +1,8 @@
(Get-Process -Id $PID).PriorityClass='Idle'
$G='D:\Projects\pokerfreak\.claude\worktrees\gedaechtnis-voll-1f97d3'
$O='D:\Projects\pokerfreak\.claude\worktrees\mock-poker-client-11c1fe\messung\familie_a\leck'
$K='D:\Projects\pokerfreak\.claude\worktrees\mock-poker-client-11c1fe\messung\familie_a\bin\pokerbench-familiea-leckfinder.exe'
Remove-Item Env:UEBERBET -ErrorAction SilentlyContinue
Remove-Item Env:GEGEN_GROSS -ErrorAction SilentlyContinue
& python -I "$G\lesen\leckfinder.py" entscheiden "$G\messung\leckfinder\spots-nl25.jsonl" "$O\gg50.jsonl" $K gg50 --prozesse 4 --zusatz "GEGEN_GROSS=0.5" *> "$O\entscheiden-gg50.log"
"gg50 fertig $(Get-Date -Format s)" | Out-File -Append -Encoding utf8 "$O\fertig.txt"
+8
View File
@@ -0,0 +1,8 @@
(Get-Process -Id $PID).PriorityClass='Idle'
$G='D:\Projects\pokerfreak\.claude\worktrees\gedaechtnis-voll-1f97d3'
$O='D:\Projects\pokerfreak\.claude\worktrees\mock-poker-client-11c1fe\messung\familie_a\leck'
$K='D:\Projects\pokerfreak\.claude\worktrees\mock-poker-client-11c1fe\messung\familie_a\bin\pokerbench-familiea-leckfinder.exe'
Remove-Item Env:UEBERBET -ErrorAction SilentlyContinue
Remove-Item Env:GEGEN_GROSS -ErrorAction SilentlyContinue
& python -I "$G\lesen\leckfinder.py" entscheiden "$G\messung\leckfinder\spots-nl25.jsonl" "$O\live.jsonl" $K live --prozesse 4 *> "$O\entscheiden-live.log"
"live fertig $(Get-Date -Format s)" | Out-File -Append -Encoding utf8 "$O\fertig.txt"
+53
View File
@@ -0,0 +1,53 @@
{
"quelle": "PHH/HandHQ",
"stufen": [
25,
50
],
"jede": 4,
"haende": 1164808,
"verlierer_gezeigt_gemuckt": {
"FTP|p": [
11380,
9275
],
"FTP|a": [
2344,
0
],
"PS|p": [
107618,
165600
],
"PS|a": [
35034,
0
],
"PTY|p": [
29347,
37743
],
"PTY|a": [
7607,
422
],
"ABS|p": [
9752,
10447
],
"ABS|a": [
2400,
0
]
},
"g": {
"FTP|p": 0.550956184943113,
"FTP|a": 1.0,
"PS|p": 0.39389059285991407,
"PS|a": 1.0,
"PTY|p": 0.43742733641377257,
"PTY|a": 0.9474405280856893,
"ABS|p": 0.4827961780286153,
"ABS|a": 1.0
}
}
+8
View File
@@ -0,0 +1,8 @@
teil2 fertig 2026-11-17T18:35:35
teil3 fertig 2026-11-17T18:35:59
teil0 fertig 2026-11-17T18:36:03
teil1 fertig 2026-11-17T18:36:10
muck1 fertig 2026-11-17T19:49:50
muck2 fertig 2026-11-17T19:49:52
muck0 fertig 2026-11-17T19:49:54
muck3 fertig 2026-11-17T19:49:55
+4
View File
@@ -0,0 +1,4 @@
(Get-Process -Id $PID).PriorityClass='Idle'
$env:BETTOR_STICHPROBE='120'
& python -I "D:\Projects\pokerfreak\.claude\worktrees\mock-poker-client-11c1fe\messung\familie_a\bettor.py" phh "D:\Projects\pokerfreak\.claude\worktrees\gedaechtnis-voll-1f97d3\daten\phh\roh" "D:\Projects\pokerfreak\.claude\worktrees\mock-poker-client-11c1fe\messung\familie_a\phh\teil0.json" --teil 0/4 --stufen 25,50 *> "D:\Projects\pokerfreak\.claude\worktrees\mock-poker-client-11c1fe\messung\familie_a\phh\teil0.log"
"teil0 fertig $(Get-Date -Format s)" | Out-File -Append -Encoding utf8 "D:\Projects\pokerfreak\.claude\worktrees\mock-poker-client-11c1fe\messung\familie_a\phh\fertig.txt"
+4
View File
@@ -0,0 +1,4 @@
(Get-Process -Id $PID).PriorityClass='Idle'
$env:BETTOR_STICHPROBE='120'
& python -I "D:\Projects\pokerfreak\.claude\worktrees\mock-poker-client-11c1fe\messung\familie_a\bettor.py" phh "D:\Projects\pokerfreak\.claude\worktrees\gedaechtnis-voll-1f97d3\daten\phh\roh" "D:\Projects\pokerfreak\.claude\worktrees\mock-poker-client-11c1fe\messung\familie_a\phh\teil1.json" --teil 1/4 --stufen 25,50 *> "D:\Projects\pokerfreak\.claude\worktrees\mock-poker-client-11c1fe\messung\familie_a\phh\teil1.log"
"teil1 fertig $(Get-Date -Format s)" | Out-File -Append -Encoding utf8 "D:\Projects\pokerfreak\.claude\worktrees\mock-poker-client-11c1fe\messung\familie_a\phh\fertig.txt"
+4
View File
@@ -0,0 +1,4 @@
(Get-Process -Id $PID).PriorityClass='Idle'
$env:BETTOR_STICHPROBE='120'
& python -I "D:\Projects\pokerfreak\.claude\worktrees\mock-poker-client-11c1fe\messung\familie_a\bettor.py" phh "D:\Projects\pokerfreak\.claude\worktrees\gedaechtnis-voll-1f97d3\daten\phh\roh" "D:\Projects\pokerfreak\.claude\worktrees\mock-poker-client-11c1fe\messung\familie_a\phh\teil2.json" --teil 2/4 --stufen 25,50 *> "D:\Projects\pokerfreak\.claude\worktrees\mock-poker-client-11c1fe\messung\familie_a\phh\teil2.log"
"teil2 fertig $(Get-Date -Format s)" | Out-File -Append -Encoding utf8 "D:\Projects\pokerfreak\.claude\worktrees\mock-poker-client-11c1fe\messung\familie_a\phh\fertig.txt"
+4
View File
@@ -0,0 +1,4 @@
(Get-Process -Id $PID).PriorityClass='Idle'
$env:BETTOR_STICHPROBE='120'
& python -I "D:\Projects\pokerfreak\.claude\worktrees\mock-poker-client-11c1fe\messung\familie_a\bettor.py" phh "D:\Projects\pokerfreak\.claude\worktrees\gedaechtnis-voll-1f97d3\daten\phh\roh" "D:\Projects\pokerfreak\.claude\worktrees\mock-poker-client-11c1fe\messung\familie_a\phh\teil3.json" --teil 3/4 --stufen 25,50 *> "D:\Projects\pokerfreak\.claude\worktrees\mock-poker-client-11c1fe\messung\familie_a\phh\teil3.log"
"teil3 fertig $(Get-Date -Format s)" | Out-File -Append -Encoding utf8 "D:\Projects\pokerfreak\.claude\worktrees\mock-poker-client-11c1fe\messung\familie_a\phh\fertig.txt"
+5
View File
@@ -0,0 +1,5 @@
(Get-Process -Id $PID).PriorityClass='Idle'
$env:BETTOR_STICHPROBE='120'
$env:BETTOR_MUCK='D:\Projects\pokerfreak\.claude\worktrees\mock-poker-client-11c1fe\messung\familie_a\muck-phh.json'
& python -I "D:\Projects\pokerfreak\.claude\worktrees\mock-poker-client-11c1fe\messung\familie_a\bettor.py" phh "D:\Projects\pokerfreak\.claude\worktrees\gedaechtnis-voll-1f97d3\daten\phh\roh" "D:\Projects\pokerfreak\.claude\worktrees\mock-poker-client-11c1fe\messung\familie_a\phh\muck0.json" --teil 0/4 --stufen 25,50 *> "D:\Projects\pokerfreak\.claude\worktrees\mock-poker-client-11c1fe\messung\familie_a\phh\muck0.log"
"muck0 fertig $(Get-Date -Format s)" | Out-File -Append -Encoding utf8 "D:\Projects\pokerfreak\.claude\worktrees\mock-poker-client-11c1fe\messung\familie_a\phh\fertig.txt"
+5
View File
@@ -0,0 +1,5 @@
(Get-Process -Id $PID).PriorityClass='Idle'
$env:BETTOR_STICHPROBE='120'
$env:BETTOR_MUCK='D:\Projects\pokerfreak\.claude\worktrees\mock-poker-client-11c1fe\messung\familie_a\muck-phh.json'
& python -I "D:\Projects\pokerfreak\.claude\worktrees\mock-poker-client-11c1fe\messung\familie_a\bettor.py" phh "D:\Projects\pokerfreak\.claude\worktrees\gedaechtnis-voll-1f97d3\daten\phh\roh" "D:\Projects\pokerfreak\.claude\worktrees\mock-poker-client-11c1fe\messung\familie_a\phh\muck1.json" --teil 1/4 --stufen 25,50 *> "D:\Projects\pokerfreak\.claude\worktrees\mock-poker-client-11c1fe\messung\familie_a\phh\muck1.log"
"muck1 fertig $(Get-Date -Format s)" | Out-File -Append -Encoding utf8 "D:\Projects\pokerfreak\.claude\worktrees\mock-poker-client-11c1fe\messung\familie_a\phh\fertig.txt"
+5
View File
@@ -0,0 +1,5 @@
(Get-Process -Id $PID).PriorityClass='Idle'
$env:BETTOR_STICHPROBE='120'
$env:BETTOR_MUCK='D:\Projects\pokerfreak\.claude\worktrees\mock-poker-client-11c1fe\messung\familie_a\muck-phh.json'
& python -I "D:\Projects\pokerfreak\.claude\worktrees\mock-poker-client-11c1fe\messung\familie_a\bettor.py" phh "D:\Projects\pokerfreak\.claude\worktrees\gedaechtnis-voll-1f97d3\daten\phh\roh" "D:\Projects\pokerfreak\.claude\worktrees\mock-poker-client-11c1fe\messung\familie_a\phh\muck2.json" --teil 2/4 --stufen 25,50 *> "D:\Projects\pokerfreak\.claude\worktrees\mock-poker-client-11c1fe\messung\familie_a\phh\muck2.log"
"muck2 fertig $(Get-Date -Format s)" | Out-File -Append -Encoding utf8 "D:\Projects\pokerfreak\.claude\worktrees\mock-poker-client-11c1fe\messung\familie_a\phh\fertig.txt"
+5
View File
@@ -0,0 +1,5 @@
(Get-Process -Id $PID).PriorityClass='Idle'
$env:BETTOR_STICHPROBE='120'
$env:BETTOR_MUCK='D:\Projects\pokerfreak\.claude\worktrees\mock-poker-client-11c1fe\messung\familie_a\muck-phh.json'
& python -I "D:\Projects\pokerfreak\.claude\worktrees\mock-poker-client-11c1fe\messung\familie_a\bettor.py" phh "D:\Projects\pokerfreak\.claude\worktrees\gedaechtnis-voll-1f97d3\daten\phh\roh" "D:\Projects\pokerfreak\.claude\worktrees\mock-poker-client-11c1fe\messung\familie_a\phh\muck3.json" --teil 3/4 --stufen 25,50 *> "D:\Projects\pokerfreak\.claude\worktrees\mock-poker-client-11c1fe\messung\familie_a\phh\muck3.log"
"muck3 fertig $(Get-Date -Format s)" | Out-File -Append -Encoding utf8 "D:\Projects\pokerfreak\.claude\worktrees\mock-poker-client-11c1fe\messung\familie_a\phh\fertig.txt"
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+306
View File
@@ -0,0 +1,306 @@
"""Live-Replay-Tor (Auftrag 17.11.): die eigenen NL2-Echtgeld-Entscheidungen gegen einen Einsatz nach dem Flop,
neu gerechnet mit Live und Kandidaten-Armen. Ausgabe nur Zaehler, Hand-IDs, Karten (keine Gegnerkennung).
python -I messung/familie_a/replay.py korridor <echt.jsonl> <aus.json>
NL2-Pool: Fold-Anteil heads-up auf den ersten Einsatz einer Strasse je Groessenklasse (aus den Rohlogs).
python -I messung/familie_a/replay.py replay <live-wurzel> <kern.exe> <aus.json> [ARM=K=V;K=V ...] [--roh <rohlog-dir>]
Fold-Anteil je Groesse x Klasse je Arm, geaenderte Entscheidungen, Pflichtregel (keine Klasse >= TwoPair
faltet gegen < 55 % Pot).
Groesse = toCall / (pot - toCall), der offene Einsatz relativ zum Topf davor: klein < 0.55, mittel < 1.0,
gross >= 1.0; allin = der Call setzt den Helden all-in.
"""
import collections
import json
import math
import os
import subprocess
import sys
_w = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, os.path.join(_w, "..", "..", "lesen"))
STARK = ("TwoPair", "Trips", "Set", "Straight", "Flush", "FullHouse", "Quads", "StraightFlush")
def ist_fold(aktion):
"""Gegen einen Einsatz faltet live auch ABSTAIN (nicht bepreisbar): beides zaehlt als Fold."""
return str(aktion or "").upper() in ("FOLD", "ABSTAIN")
def klasse_groesse(f, allin):
if allin:
return "allin"
return "klein" if f < 0.55 else "mittel" if f < 1.0 else "gross"
def wilson(k, n, z=1.96):
if n == 0:
return (0.0, 1.0)
p = k / n
d = 1 + z * z / n
m = (p + z * z / (2 * n)) / d
h = z * math.sqrt(p * (1 - p) / n + z * z / (4 * n * n)) / d
return (max(0.0, m - h), min(1.0, m + h))
def korridor(pfad, aus):
"""Heads-up, erster Einsatz der Strasse (offen), Antwort des anderen: Fold oder weiter."""
z = collections.defaultdict(lambda: [0, 0])
for zeile in open(pfad, encoding="utf-8"):
h = json.loads(zeile)
v = [r for r in h.get("verlauf") or () if isinstance(r, dict) and r.get("seat") is not None]
held = h.get("held")
aktiv = {int(r["seat"]) for r in v}
topf, strasse, bei = 0.0, None, {}
offen = None # (setzer, groesse) des ersten Einsatzes der Strasse
for r in v:
s, a, p = r.get("street"), r.get("action"), int(r["seat"])
if s != strasse:
topf += sum(bei.values())
bei, strasse, offen = {}, s, None
if p not in aktiv:
continue
hoch = max(bei.values(), default=0.0)
betrag = float(r.get("amount") or 0.0)
if a in ("POST_SB", "POST_BB"):
bei[p] = betrag
continue
if a == "FOLD":
if offen and s != "PREFLOP" and p != offen[0] and len(aktiv) == 2 and p != held:
z[(s, offen[1])][0] += 1
z[(s, offen[1])][1] += 1
offen = None
aktiv.discard(p)
continue
if a in ("BET", "RAISE", "ALL_IN") and betrag > hoch + 1e-9:
if s != "PREFLOP" and hoch <= 0 and len(aktiv) == 2 and p != held:
t = topf + sum(bei.values())
offen = (p, klasse_groesse(betrag / t if t > 0 else 1.0, False)) if t > 0 else None
elif offen and p != offen[0] and p != held:
z[(s, offen[1])][1] += 1 # Raise: weiter
offen = None
bei[p] = betrag
continue
if a in ("CALL", "ALL_IN"):
if offen and p != offen[0] and p != held:
z[(s, offen[1])][1] += 1
offen = None
bei[p] = max(bei.get(p, 0.0), hoch)
erg = {}
for (s, g), (f, n) in sorted(z.items()):
lo, hi = wilson(f, n)
erg["%s %s" % (s, g)] = {"fold": f, "n": n, "anteil": round(f / n, 3), "w95": [round(lo, 3), round(hi, 3)]}
# ueber die Strassen zusammen je Groesse
for g in ("klein", "mittel", "gross"):
f = sum(v[0] for (s, gg), v in z.items() if gg == g)
n = sum(v[1] for (s, gg), v in z.items() if gg == g)
if n:
lo, hi = wilson(f, n)
erg["alle " + g] = {"fold": f, "n": n, "anteil": round(f / n, 3), "w95": [round(lo, 3), round(hi, 3)]}
with open(aus, "w", encoding="utf-8", newline="\n") as fh:
json.dump(erg, fh, indent=1)
for k, v in erg.items():
print("%-14s fold %4d / %4d = %.2f [%.2f, %.2f]" % (k, v["fold"], v["n"], v["anteil"], *v["w95"]))
def faelle(L):
import roentgen
H = {}
for h in roentgen.jsonl(os.path.join(L, "archiv", "lauf", "haende.jsonl")):
if h.get("stake") == "0.01/0.02":
H[str(h["hand"])] = h
out, gesehen = [], set()
for z in roentgen.jsonl(os.path.join(L, "archiv", "lauf", "zuege.jsonl")):
h = str(z.get("hand"))
if h not in H:
continue
a = roentgen._als_dict(z.get("spot"))
if not isinstance(a, dict) or a.get("street") in (None, "PREFLOP") or not a.get("legalActions"):
continue
tc, pot, st = a.get("toCall") or 0, a.get("pot") or 0, a.get("heroStack") or 0
if tc <= 0 or pot - tc <= 0:
continue
k = (h, a.get("street"), round(tc, 4), round(pot, 4))
if k in gesehen:
continue
gesehen.add(k)
out.append((h, a, z, klasse_groesse(tc / (pot - tc), tc >= st - 1e-9)))
return H, out
def flop_roh(roh, H, zuege_pfad):
"""Flop-Spots aus den Rohlogs (`zuege` traegt am Flop keinen ganzen Spot). Gegnerprofile wie live: aus dem
passenden `zuege`-Eintrag (Hand, Strasse, toCall), sonst das Tisch-HUD aus dem Log."""
import ast
import glob
import linien
import roentgen
import spot_from_log as sfl
prof = {}
for z in roentgen.jsonl(zuege_pfad):
if z.get("street") != "FLOP" or not z.get("gegner"):
continue
try:
g = ast.literal_eval(z["gegner"]) if isinstance(z["gegner"], str) else z["gegner"]
prof[(str(z.get("hand")), round(float(z.get("toCall") or 0), 4))] = (g, z.get("aktion"))
except (ValueError, SyntaxError):
pass
out, gesehen = [], set()
for p in sorted(glob.glob(os.path.join(roh, "*.log.gz")), key=os.path.getmtime):
for zeile, _, _, hand, _ in sfl.spots(linien._lesen(p)):
a = json.loads(zeile)
h = str(hand)
if h not in H or a.get("street") != "FLOP" or not a.get("legalActions"):
continue
tc, pot, st = a.get("toCall") or 0, a.get("pot") or 0, a.get("heroStack") or 0
if tc <= 0 or pot - tc <= 0:
continue
k = (h, "FLOP", round(tc, 4), round(pot, 4))
if k in gesehen:
continue
gesehen.add(k)
a.pop("_sitze", None)
g, akt = prof.get((h, round(tc, 4)), (None, None))
for v in a.get("villains") or ():
v.pop("kennung", None)
q = (g or {}).get(str(v.get("seat")))
if isinstance(q, dict):
v["profile"] = {kk: vv for kk, vv in q.items() if kk != "folded"}
out.append((h, a, {"aktion": akt}, klasse_groesse(tc / (pot - tc), tc >= st - 1e-9)))
return out
RANG = {"ACE": "A", "KING": "K", "QUEEN": "Q", "JACK": "J", "TEN": "T", "NINE": "9", "EIGHT": "8", "SEVEN": "7",
"SIX": "6", "FIVE": "5", "FOUR": "4", "THREE": "3", "TWO": "2"}
def kz(xs):
return "".join(RANG.get(x.get("rank"), "?") + x.get("suit", "")[:1].lower() for x in (xs or []) if isinstance(x, dict))
ECHT = {2: "TwoPair", 3: "Trips", 4: "Straight", 5: "Flush", 6: "FullHouse", 7: "Quads", 8: "StraightFlush"}
def echte_klasse(a):
"""Eigene Klasse >= TwoPair, zu der die Lochkarten beitragen (Kategorie ueber der des Bretts allein; ein
Brettpaar plus eigenes Paar zaehlt nicht als Two Pair), sonst None."""
sys.path.insert(0, os.path.join(_w, "..", "..", "entscheiden"))
import eval7
b = a.get("board")
b = [c for s_ in ("FLOP", "TURN", "RIVER") for c in (b.get(s_) or [])] if isinstance(b, dict) else (b or [])
brett = [eval7.karte(kz([c])) for c in b]
loch = [eval7.karte(kz([c])) for c in a.get("heroCards") or []]
if len(loch) != 2 or len(brett) < 3:
return None
held = eval7.best7(loch + brett)[0]
zahl = sorted(collections.Counter(r for r, _ in brett).values(), reverse=True)
br = eval7.score5(brett)[0] if len(brett) == 5 else (7 if zahl[0] == 4 else 3 if zahl[0] == 3 else
2 if zahl[:2] == [2, 2] else 1 if zahl[0] == 2 else 0)
if held < 2 or held <= br or (held == 2 and br == 1):
return None
return ECHT.get(held)
def lauf(kern, env, spots):
p = subprocess.Popen([kern], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, env=env)
out = p.communicate("".join(json.dumps(s) + "\n" for s in spots).encode())[0].decode().splitlines()
return [json.loads(x) for x in out]
def replay(L, kern, aus, arm_args, roh=None):
import roentgen
arme = {"live": {}}
for a in arm_args:
n, kv = a.split("=", 1)
arme[n] = dict(x.split("=", 1) for x in kv.split(";") if x)
base = dict(os.environ)
base.update(roentgen.lies_schalter(os.path.join(L, "betrieb", "kern_schalter.txt")))
H, fs = faelle(L)
if roh:
fs = flop_roh(roh, H, os.path.join(L, "archiv", "lauf", "zuege.jsonl")) + fs
spots = [a for _, a, _, _ in fs]
ant = {}
for n, ov in arme.items():
e = dict(base)
e.update(ov)
ant[n] = lauf(kern, e, spots)
assert len(ant[n]) == len(spots), (n, len(ant[n]), len(spots))
# Klasse aus dem Live-Arm (gleiche Lesart fuer alle Arme)
tab = {n: collections.defaultdict(lambda: [0, 0]) for n in arme}
tab["damals"] = collections.defaultdict(lambda: [0, 0])
anders = []
echt_regel = {n: collections.defaultdict(lambda: [0, 0]) for n in arme}
echt_folds = []
for i, (h, a, z, g) in enumerate(fs):
ek = echte_klasse(a) if g == "klein" else None
if ek:
for n in arme:
echt_regel[n][ek][0] += ist_fold(ant[n][i]["action"])
echt_regel[n][ek][1] += 1
if any(ist_fold(ant[n][i]["action"]) for n in arme):
echt_folds.append({"hand": h, "strasse": a["street"].lower(), "karten": kz(a.get("heroCards")),
"klasse": ek, "aktion": {n: ant[n][i]["action"] for n in arme},
"grund": {n: ant[n][i].get("reason", "")[:120] for n in arme}})
kl = ant["live"][i].get("category") or "?"
s = a["street"].lower()
for n in arme:
fold = ist_fold(ant[n][i]["action"])
for key in ((s, g, kl), ("alle", g, kl), (s, g, "*"), ("alle", g, "*")):
tab[n][key][0] += fold
tab[n][key][1] += 1
d = str(z.get("aktion") or "").upper()
if d:
for key in ((s, g, kl), ("alle", g, kl), (s, g, "*"), ("alle", g, "*")):
tab["damals"][key][0] += ist_fold(d)
tab["damals"][key][1] += 1
if any(ant[n][i]["action"] != ant["live"][i]["action"] for n in arme):
bb = H[h].get("bb") or 0.02
anders.append({"hand": h, "strasse": s, "groesse": g, "klasse": kl, "karten": kz(a.get("heroCards")),
"toCall_bb": round(a["toCall"] / bb, 2), "pot_bb": round(a["pot"] / bb, 2),
"netto_bb": round((H[h].get("netto") or 0) / bb, 2),
"aktion": {n: ant[n][i]["action"] for n in arme},
"equity": {n: ant[n][i].get("equity") for n in arme}})
erg = {"spots": len(fs), "arme": list(arme), "tabelle": {}, "anders": anders}
for n, t in tab.items():
erg["tabelle"][n] = {" ".join(k): v for k, v in sorted(t.items())}
# Pflichtregel: Klassen >= TwoPair gegen klein
regel = {}
for n in arme:
regel[n] = {kl: tab[n][("alle", "klein", kl)] for kl in STARK if tab[n][("alle", "klein", kl)][1]}
erg["regel_stark_klein"] = regel
erg["regel_echt_klein"] = {n: {k: v for k, v in t.items()} for n, t in echt_regel.items()}
erg["echt_folds"] = echt_folds
with open(aus, "w", encoding="utf-8", newline="\n") as fh:
json.dump(erg, fh, indent=1)
namen = ["damals"] + list(arme)
print("spots", len(fs))
print("%-28s" % "strasse groesse klasse" + "".join("%16s" % n for n in namen))
keys = sorted({k for t in tab.values() for k in t}, key=lambda k: (k[0] != "alle", k[0], k[1], k[2] != "*", k[2]))
for k in keys:
if k[2] != "*" and tab["live"][k][1] < 8:
continue
print("%-28s" % " ".join(k) + "".join(
"%16s" % ("%3d/%-4d %4.0f%%" % (tab[n][k][0], tab[n][k][1], 100.0 * tab[n][k][0] / tab[n][k][1]) if tab[n][k][1] else "-")
for n in namen))
print("geaendert:", len(anders))
for n in arme:
print("regel %s:" % n, {kl: "%d/%d" % tuple(v) for kl, v in regel[n].items()})
for n in arme:
print("regel echt %s:" % n, {kl: "%d/%d" % tuple(v) for kl, v in echt_regel[n].items()})
for f in echt_folds:
print(" echt-fold", f["hand"], f["strasse"], f["karten"], f["klasse"], f["aktion"],
f["grund"][list(arme)[-1]].encode("ascii", "replace").decode())
if __name__ == "__main__":
a = sys.argv[1:]
if a[0] == "korridor":
korridor(a[1], a[2])
elif a[0] == "replay":
roh = None
if "--roh" in a:
i = a.index("--roh")
roh = a[i + 1]
a = a[:i] + a[i + 2:]
replay(a[1], os.path.abspath(a[2]), a[3], a[4:], roh)
+10
View File
@@ -235,6 +235,16 @@ pub fn decide(spot: &Spot) -> Decision {
/// `decide` with an optional tournament situation (`icm`). Without one: cash. With one
/// that cannot be priced: ABSTAIN.
pub fn decide_with(spot: &Spot, lage: Option<&Turnierlage>) -> Decision {
// UEBERSCHUSS=1: a bet that covers hero prices only the part hero can match (`engine::ueberschuss`),
// trimmed once (the history still shows the whole bet).
match super::ueberschuss::trimmed(spot) {
Some(trimmed) => decide_matched(&trimmed, lage),
None => decide_matched(spot, lage),
}
}
/// `decide_with` on a spot whose pot holds only what hero can win.
fn decide_matched(spot: &Spot, lage: Option<&Turnierlage>) -> Decision {
use crate::exploit::style::{set_station_postflop_override as force, station_demoted, station_narrow, station_postflop_override};
// STATION_POSTFLOP=schmal: against a villain the postflop gate would demote, decide with the
// station read and blind (demoted) and play the less aggressive action (`exploit::style`).
+1
View File
@@ -38,6 +38,7 @@ pub mod texture_stance;
pub mod thin_value;
pub mod turn_game;
pub mod turn_subgame;
pub mod ueberschuss;
pub mod uncertainty;
/// One lock for every unit test that flips a process-wide solver switch (`set_river_spieler`,
+50 -12
View File
@@ -19,22 +19,56 @@ const SAMPLE_SEED: u64 = 0xB1FF_5EED;
/// Strength order of a hand for `Continuation::top_share`: made hand, then draw, then a fixed ticket
/// (own salt, so ties do not correlate with the bluff tickets of the same step).
type Key = (Made, Draw, f64);
/// Under `GEGEN_GROSS` the river key leads with the showdown strength (`None` elsewhere).
type Key = (Option<crate::hand::strength::Strength>, Made, Draw, f64);
/// Salt of the tie-break ticket of `Key`, apart from the bluff tickets (`ticket(hand, step)`).
const TOP_SALT: usize = 0x5_0000;
/// Salt of the acceptance ticket of a `likelihood` step (`BETTOR`).
const LK_SALT: usize = 0x6_0000;
/// Showdown strengths of every holding on a step's board, sorted: the board percentile of a hand.
type Ranking = Rc<Vec<crate::hand::strength::Strength>>;
/// The ranking a `likelihood` step reads its percentiles from; `None` for every other step.
fn ranking(rules: &Rules, c: &Continuation, board: &[Card]) -> Option<Ranking> {
c.likelihood?;
let seen = &board[..c.board_len.min(board.len())];
let mut all: Vec<_> =
population(rules, seen).iter().filter_map(|h| crate::hand::showdown::judge(rules, h, seen).ok()).collect();
all.sort_unstable();
(!all.is_empty()).then(|| Rc::new(all))
}
/// Share of the holdings in `ranking` that `hand` beats on the step's board (ties half).
fn board_percentile(rules: &Rules, c: &Continuation, ranking: &[crate::hand::strength::Strength], hand: &[Card], board: &[Card]) -> Option<f64> {
let seen = &board[..c.board_len.min(board.len())];
let s = crate::hand::showdown::judge(rules, hand, seen).ok()?;
let less = ranking.partition_point(|x| *x < s);
let upto = ranking.partition_point(|x| *x <= s);
Some((less as f64 + 0.5 * (upto - less) as f64) / ranking.len() as f64)
}
fn key(rules: &Rules, c: &Continuation, hand: &[Card], board: &[Card], step: usize) -> Option<Key> {
glance(rules, hand, &board[..c.board_len.min(board.len())]).ok().map(|(made, draw)| (made, draw, ticket(hand, step + TOP_SALT)))
let seen = &board[..c.board_len.min(board.len())];
let strength = (seen.len() == 5 && crate::exploit::street_continuation::gegen_gross_enabled())
.then(|| crate::hand::showdown::judge(rules, hand, seen).ok())
.flatten();
glance(rules, hand, seen).ok().map(|(made, draw)| (strength, made, draw, ticket(hand, step + TOP_SALT)))
}
fn above(k: &Key, cut: &Key) -> bool {
(k.0, k.1).cmp(&(cut.0, cut.1)).then(k.2.total_cmp(&cut.2)).is_ge()
(k.0, k.1, k.2).cmp(&(cut.0, cut.1, cut.2)).then(k.3.total_cmp(&cut.3)).is_ge()
}
/// Does `hand` meet the floor of `c` on its part of the board (and, with a strength cut from
/// `top_share`, lie at or above it)? `None` when unreadable.
fn meets(rules: &Rules, c: &Continuation, hand: &[Card], board: &[Card], step: usize, cut: Option<&Key>) -> Option<bool> {
fn meets(rules: &Rules, c: &Continuation, hand: &[Card], board: &[Card], step: usize, cut: Option<&Key>, rank: Option<&Ranking>) -> Option<bool> {
if let (Some(lk), Some(rank)) = (c.likelihood.as_ref(), rank) {
let p = board_percentile(rules, c, rank, hand, board)?;
return Some(ticket(hand, step + LK_SALT) < crate::exploit::bettor::accept(lk, p));
}
let seen = &board[..c.board_len.min(board.len())];
glance(rules, hand, seen).ok().map(|(made, draw)| {
let strong = c.min_strength.is_none_or(|cut| crate::hand::showdown::judge(rules, hand, seen).is_ok_and(|s| s >= cut));
@@ -60,9 +94,9 @@ fn strength_cut(rules: &Rules, c: &Continuation, alive: &[Vec<Card>], board: &[C
let share = c.top_share.filter(|t| t.is_finite() && *t < 1.0)?;
let mut keys: Vec<Key> = alive.iter().filter_map(|h| key(rules, c, h, board, step)).collect();
if draws_free() {
keys.retain(|k| k.0 >= c.min_made);
keys.retain(|k| k.1 >= c.min_made);
}
keys.sort_by(|a, b| (b.0, b.1).cmp(&(a.0, a.1)).then(b.2.total_cmp(&a.2)));
keys.sort_by(|a, b| (b.0, b.1, b.2).cmp(&(a.0, a.1, a.2)).then(b.3.total_cmp(&a.3)));
let pool = if draws_free() { keys.len() } else { alive.len() };
let n = ((share.max(0.0) * pool as f64).ceil() as usize).clamp(1, keys.len().max(1));
keys.get(n - 1).copied()
@@ -125,7 +159,7 @@ fn admitted(c: &Continuation, value: usize, alive: usize) -> usize {
/// Ticket threshold per continuation for hands below its floor: the `admitted` lowest tickets
/// pass; and the strength cut of its `top_share`. Second value: `true` when some continuation has
/// no value hand at all in what is left (the band contradicts the action).
fn acceptances(spec: &RangeSpec, rules: &Rules, variant: Variant, board: &[Card]) -> (Vec<(f64, Option<Key>)>, bool) {
fn acceptances(spec: &RangeSpec, rules: &Rules, variant: Variant, board: &[Card]) -> (Vec<Accept>, bool) {
if spec.continues.is_empty() {
return (Vec::new(), false);
}
@@ -136,13 +170,14 @@ fn acceptances(spec: &RangeSpec, rules: &Rules, variant: Variant, board: &[Card]
let init = (start, Vec::new(), false);
let (_, qs, starved) = spec.continues.iter().enumerate().fold(init, |(alive, mut qs, starved), (step, c)| {
let cut = strength_cut(rules, c, &alive, board, step);
let rank = ranking(rules, c, board);
let judged: Vec<(Vec<Card>, Option<bool>)> =
alive.into_iter().map(|h| { let m = meets(rules, c, &h, board, step, cut.as_ref()); (h, m) }).collect();
alive.into_iter().map(|h| { let m = meets(rules, c, &h, board, step, cut.as_ref(), rank.as_ref()); (h, m) }).collect();
let value = judged.iter().filter(|(_, m)| *m == Some(true)).count();
let below: Vec<f64> =
judged.iter().filter(|(_, m)| *m == Some(false)).map(|(h, _)| ticket(h, step)).collect();
let q = threshold(below, admitted(c, value, judged.len()));
qs.push((q, cut));
qs.push((q, cut, rank));
let next = judged
.into_iter()
.filter(|(h, m)| *m == Some(true) || (*m == Some(false) && ticket(h, step) < q))
@@ -153,6 +188,9 @@ fn acceptances(spec: &RangeSpec, rules: &Rules, variant: Variant, board: &[Card]
(qs, starved)
}
/// Per step: bluff ticket threshold, strength cut of `top_share`, board ranking of `likelihood`.
type Accept = (f64, Option<Key>, Option<Ranking>);
/// Upper end of the relaxed band (see `range_filter`).
const RELAXED_HI: f64 = 0.5;
@@ -202,7 +240,7 @@ thread_local! {
/// verdict per ordered two-card hand once asked (0 = not yet, 1 = out, 2 = in).
struct Kept {
spec: RangeSpec,
qs: Vec<(f64, Option<Key>)>,
qs: Vec<Accept>,
rules: Rules,
variant: Variant,
board: Vec<Card>,
@@ -227,8 +265,8 @@ impl Kept {
let p = percentile(self.variant, hand);
p >= self.spec.lo
&& p <= self.spec.hi
&& self.spec.continues.iter().zip(&self.qs).enumerate().all(|(step, (c, (q, cut)))| {
match meets(&self.rules, c, hand, &self.board, step, cut.as_ref()) {
&& self.spec.continues.iter().zip(&self.qs).enumerate().all(|(step, (c, (q, cut, rank)))| {
match meets(&self.rules, c, hand, &self.board, step, cut.as_ref(), rank.as_ref()) {
Some(true) => true,
Some(false) => *q > 0.0 && ticket(hand, step) < *q,
None => false,
+86
View File
@@ -0,0 +1,86 @@
//! Messschalter `UEBERSCHUSS=1`: the uncalled part of a bet that covers hero goes back, it is no pot hero can win.
//!
//! The client sends `pot` with the villain's whole bet in it, `toCall` capped at hero's stack. When the call puts hero
//! all-in for less, the excess (the villain's street contribution above hero's street contribution plus the call,
//! and above every other live player's) returns to the villain at showdown. Live 17.11.: all 17 covered all-in calls
//! of our NL2 hands since 14.11. priced it as winnable: 78 on the turn break-even 0.12 instead of 0.19 (called,
//! -100 BB), AK 0.37 instead of 0.42 (-77 BB), QQ 0.25 instead of 0.40, a 46-pot river overbet 0.08 instead of 0.44.
//! Unset: off, bit-identical.
use crate::game::{SeenAction, Spot};
fn enabled() -> bool {
use std::sync::OnceLock;
static ON: OnceLock<bool> = OnceLock::new();
*ON.get_or_init(|| std::env::var("UEBERSCHUSS").as_deref() == Ok("1"))
}
/// The street contribution of `seat` so far (the largest amount it reached on the street).
fn street_total(spot: &Spot, seat: u8) -> f64 {
spot.history
.iter()
.filter(|r| r.street == spot.street && r.seat == seat && r.action != SeenAction::Fold)
.filter_map(|r| r.amount)
.fold(0.0, f64::max)
}
/// Uncalled excess in `spot.pot` when calling puts hero all-in for less than the bet faced: the top contribution on
/// the street above what hero (street total plus the call) and every other live player match. `0` otherwise.
pub fn excess(spot: &Spot) -> f64 {
if spot.to_call <= 0.0 || spot.to_call < spot.hero_stack - 1e-9 {
return 0.0;
}
let mut totals: Vec<f64> = spot.live_villains().map(|v| street_total(spot, v.seat)).collect();
totals.sort_by(|a, b| b.total_cmp(a));
let Some(&top) = totals.first() else { return 0.0 };
let matched = (street_total(spot, spot.hero_seat) + spot.to_call).max(totals.get(1).copied().unwrap_or(0.0));
let x = top - matched;
if x > 1e-9 && x < spot.pot { x } else { 0.0 }
}
/// The spot with the uncalled excess taken out of the pot, when the switch is on and there is one.
pub fn trimmed(spot: &Spot) -> Option<Spot> {
if !enabled() {
return None;
}
let x = excess(spot);
(x > 0.0).then(|| Spot { pot: spot.pot - x, ..spot.clone() })
}
#[cfg(test)]
mod tests {
use super::*;
use crate::game::{ActionRecord, Street};
fn rec(street: Street, seat: u8, action: SeenAction, amount: Option<f64>) -> ActionRecord {
ActionRecord { street, seat, action, amount }
}
#[test]
fn covered_all_in_returns_the_excess() {
// 179390200206: river pot 0.39, villain bets 17.88, hero has 1.5 behind.
let mut spot = Spot {
variant: crate::variant::Variant::Nlhe,
big_blind: 0.02,
seats: 2,
hero_seat: 1,
button_seat: Some(1),
hero_cards: crate::card::Card::parse_list("Ad Qd").unwrap(),
board: crate::card::Card::parse_list("Td Jc Qh As Ts").unwrap(),
street: Street::River,
pot: 18.27,
to_call: 1.5,
hero_stack: 1.5,
min_raise_to: None,
max_raise_to: None,
legal: vec![crate::game::ActionKind::Fold, crate::game::ActionKind::Call],
allowed_sizes: None,
villains: vec![crate::game::Villain { seat: 2, stack: 1.48, folded: false, profile: None }],
seed: 1,
history: vec![rec(Street::River, 1, SeenAction::Check, None), rec(Street::River, 2, SeenAction::Bet, Some(17.88))],
};
assert!((excess(&spot) - 16.38).abs() < 1e-9);
spot.hero_stack = 20.0;
assert_eq!(excess(&spot), 0.0);
}
}
+141
View File
@@ -0,0 +1,141 @@
//! Messschalter `BETTOR=<Tabelle>`: what a player holds when he bets (or checks) at a decision where he
//! could bet, measured from real showdowns (`messung/familie_a/bettor.py`, PHH NL25/50 plus our NL2).
//!
//! The made-class floors of `street_continuation` read every bet the same way up to a size notch: a
//! river bet keeps top pair good kicker or better, a flop bet middle pair or better. Real NL2 does not
//! play like that: it stabs small with almost anything and overbets only strong. The model here is the
//! likelihood P(answer | board percentile) per decision node (street, preflop aggressor, own aggression
//! on the street before), answer `x` (check) or a size `k <= 0.40 < m <= 0.80 < g <= 1.20 < u` (pots),
//! `j` an all-in bet. The board percentile of a holding is the share of all two-card holdings its best
//! five on the current board beats (ties half). A hand stays in the range with probability `L(p) / max L`
//! (`engine::range_filter`): the posterior over the hands that were still in, by Bayes.
//!
//! Live 17.11.: against small bets (< 55 % pot) 50 % folds, two pair 24 %; against a 1.5-pot river bet
//! of a passive player KK on Ad7hAh7sJc called as "equity 0.66". Both are this missing size condition.
use crate::game::Street;
/// Bins of the likelihood (percentile 0..1).
pub const BINS: usize = 20;
/// Acceptance per bin, normalized to a maximum of 1.
pub type Likelihood = [f64; BINS];
/// Decision-node key: street, preflop aggressor, own aggression on the street before.
pub type Key = (Street, bool, bool);
fn table() -> Option<&'static Vec<(Key, char, Likelihood)>> {
use std::sync::OnceLock;
static T: OnceLock<Option<Vec<(Key, char, Likelihood)>>> = OnceLock::new();
T.get_or_init(|| {
let path = std::env::var("BETTOR").ok().filter(|p| !p.is_empty())?;
let text = std::fs::read_to_string(&path).ok()?;
let rows: Vec<_> = text.lines().filter_map(parse_row).collect();
(!rows.is_empty()).then_some(rows)
})
.as_ref()
}
fn parse_row(line: &str) -> Option<(Key, char, Likelihood)> {
let (key, answer, mut lk) = parse_raw(line)?;
let top = lk.iter().cloned().fold(0.0, f64::max);
if top <= 0.0 {
return None;
}
for slot in lk.iter_mut() {
*slot /= top;
}
Some((key, answer, lk))
}
/// A table row as written: `P(answer | percentile bin)` at the node (`sim::bettor_tor` samples from it).
pub fn parse_raw(line: &str) -> Option<(Key, char, Likelihood)> {
let line = line.trim();
if line.is_empty() || line.starts_with('#') {
return None;
}
let mut it = line.split_whitespace();
let street = match it.next()? {
"flop" => Street::Flop,
"turn" => Street::Turn,
"river" => Street::River,
_ => return None,
};
let pfa = it.next()? == "1";
let before = it.next()? == "1";
let answer = it.next()?.chars().next()?;
let mut lk = [0.0; BINS];
for slot in lk.iter_mut() {
*slot = it.next()?.parse::<f64>().ok().filter(|v| v.is_finite() && *v >= 0.0)?;
}
Some(((street, pfa, before), answer, lk))
}
/// Is `BETTOR` on (a readable table)?
pub fn enabled() -> bool {
table().is_some()
}
/// The size class of a bet of `ratio` pots (`None`: unknown size), or `j` for an all-in bet.
pub fn answer_of(ratio: Option<f64>, all_in: bool) -> Option<char> {
if all_in {
return Some('j');
}
let r = ratio.filter(|r| r.is_finite() && *r > 0.0)?;
Some(if r <= 0.40 {
'k'
} else if r <= 0.80 {
'm'
} else if r <= 1.20 {
'g'
} else {
'u'
})
}
/// The acceptance curve for `answer` at this node, if the table has it.
pub fn likelihood(street: Street, pfa: bool, before: bool, answer: char) -> Option<Likelihood> {
table()?.iter().find(|(k, a, _)| *k == (street, pfa, before) && *a == answer).map(|(_, _, lk)| *lk)
}
/// Acceptance at board percentile `p` (linear between bin centres, flat at the ends).
pub fn accept(lk: &Likelihood, p: f64) -> f64 {
let x = (p.clamp(0.0, 1.0) * BINS as f64 - 0.5).clamp(0.0, (BINS - 1) as f64);
let i = x.floor() as usize;
let j = (i + 1).min(BINS - 1);
let t = x - i as f64;
lk[i] * (1.0 - t) + lk[j] * t
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn sizes_map_to_classes() {
assert_eq!(answer_of(Some(0.3), false), Some('k'));
assert_eq!(answer_of(Some(0.66), false), Some('m'));
assert_eq!(answer_of(Some(1.0), false), Some('g'));
assert_eq!(answer_of(Some(1.5), false), Some('u'));
assert_eq!(answer_of(Some(0.3), true), Some('j'));
assert_eq!(answer_of(None, false), None);
}
#[test]
fn rows_parse_and_normalize() {
let row = format!("river 0 1 u {}", (0..BINS).map(|i| format!("{}", i as f64 / 10.0)).collect::<Vec<_>>().join(" "));
let ((s, pfa, before), a, lk) = parse_row(&row).expect("row");
assert_eq!((s, pfa, before, a), (Street::River, false, true, 'u'));
assert!((lk[BINS - 1] - 1.0).abs() < 1e-12 && lk[0] == 0.0);
assert!(parse_row("# comment").is_none());
}
#[test]
fn accept_interpolates() {
let mut lk = [0.0; BINS];
lk[BINS - 1] = 1.0;
assert_eq!(accept(&lk, 1.0), 1.0);
assert_eq!(accept(&lk, 0.0), 0.0);
assert!(accept(&lk, 1.0 - 0.75 / BINS as f64) > 0.0);
}
}
+2
View File
@@ -27,6 +27,7 @@ pub fn call_continuation(villain: &Villain, street: Street, ratio: f64, facing_r
continue_share: Some(1.0 - sized_fold_on(fold_base(villain.profile.as_ref()), ratio, facing_raise, Some(street))),
top_share: None,
min_strength: None,
likelihood: None,
}
}
@@ -44,5 +45,6 @@ pub fn top_call_continuation(villain: &Villain, street: Street, ratio: f64, faci
continue_share: None,
top_share: Some(1.0 - sized_fold_on(fold_base(villain.profile.as_ref()), ratio, facing_raise, Some(street))),
min_strength: None,
likelihood: None,
}
}
+1
View File
@@ -4,6 +4,7 @@ pub mod adjust;
pub mod band_bounds;
pub mod band_stretch;
pub mod bet_ratio;
pub mod bettor;
pub mod bluff_share;
pub mod brett_floor;
pub mod call_floor;
+3
View File
@@ -37,6 +37,9 @@ pub struct Continuation {
/// board (`WERT_BRETT=river`, `exploit::brett_floor`): the board-relative river floor, an exact
/// percentile of all holdings instead of a made class.
pub min_strength: Option<crate::hand::strength::Strength>,
/// `likelihood`, when set, replaces the floor: a hand stays with probability `L(p)` (a fixed per-hand
/// ticket below it), `p` its board percentile on this step's board (`BETTOR`, `exploit::bettor`).
pub likelihood: Option<crate::exploit::bettor::Likelihood>,
}
impl RangeSpec {
+91 -3
View File
@@ -19,6 +19,50 @@ const RAISE_RUNG: [i32; 3] = [4, 5, 6];
/// Draws are still in on flop and turn, not on the river.
const DRAWS: [bool; 3] = [true, true, false];
/// Messschalter (einmal gelesen) `GEGEN_GROSS=<t>[,akt]`: the range behind a bet that puts hero all-in
/// (any street) or a river bet of at least `GROSS_RATIO` pots keeps only its strongest `t` as value
/// (`Continuation::top_share`; on the river ranked by showdown strength, `engine::range_filter`), the
/// line's bluff share below it. `akt` scales `t` by the villain's aggression read against the pool
/// (`t * a / 0.30`, clamped to `[0.5 t, 2 t]`; no read: `t`). Live 17.11. KK on Ad7hAh7sJc called a
/// passive player's 1.5-pot river bet at "equity 0.66": the made-class floor kept 88-TT (18 of 28
/// combos) as value. Leak finder family A (calls against all-ins). Unset: off, bit-identical.
fn gegen_gross() -> Option<(f64, bool)> {
use std::sync::OnceLock;
static G: OnceLock<Option<(f64, bool)>> = OnceLock::new();
*G.get_or_init(|| {
let v = std::env::var("GEGEN_GROSS").ok()?;
let mut parts = v.split(',');
let t = parts.next()?.trim().parse::<f64>().ok().filter(|t| t.is_finite() && *t > 0.0 && *t < 1.0)?;
Some((t, parts.any(|p| p.trim() == "akt")))
})
}
/// Is `GEGEN_GROSS` on (the river ranking of `top_share` by showdown strength follows it)?
pub fn gegen_gross_enabled() -> bool {
gegen_gross().is_some()
}
/// River bet size (pots) from which `GEGEN_GROSS` narrows.
const GROSS_RATIO: f64 = 1.0;
/// Pool aggression the `akt` scaling is relative to.
const GROSS_POOL_AGGRESSION: f64 = 0.30;
/// The value share of `GEGEN_GROSS` for the villain's aggression on the current `street`, or `None`
/// when the switch is off or the bet is neither all-in for hero nor a big river bet.
fn gegen_gross_share(spot: &Spot, villain: &Villain, ratios: &[Option<f64>], street: Street) -> Option<f64> {
let (t, akt) = gegen_gross()?;
let (_, ratio) = own_aggression(&spot.history, ratios, street, villain.seat)?;
let last_is_villain = spot.history.iter().rev().find(|r| r.street == street && r.action.is_aggressive()).is_some_and(|r| r.seat == villain.seat);
let hero_all_in = last_is_villain && spot.to_call > 0.0 && spot.to_call >= spot.hero_stack - 1e-9;
let villain_all_in = spot.history.iter().any(|r| r.street == street && r.seat == villain.seat && r.action == SeenAction::AllIn);
let big_river = street == Street::River && ratio.is_some_and(|r| r >= GROSS_RATIO);
if !(hero_all_in || villain_all_in || big_river) {
return None;
}
let a = villain.profile.as_ref().and_then(|p| p.aggression).filter(|a| a.is_finite() && akt);
Some(a.map_or(t, |a| (t * a / GROSS_POOL_AGGRESSION).clamp(0.5 * t, (2.0 * t).min(1.0))))
}
/// Bet = 0, raise (RAISE or ALL_IN) = 1.
fn level(action: SeenAction) -> Option<usize> {
match action {
@@ -244,6 +288,32 @@ fn aggressed_earlier(history: &[ActionRecord], street: Street, seat: u8) -> bool
})
}
/// `BETTOR`: the likelihood of the villain's answer at his open decision on `street` (nobody had bet
/// before him there): his check, or his bet by size class (`exploit::bettor`). Only heads-up (the
/// table is measured on heads-up nodes) and only with a table. Second value: the answer was a bet.
fn bettor_node(spot: &Spot, villain: &Villain, ratios: &[Option<f64>], street: Street) -> Option<(super::bettor::Likelihood, bool)> {
if !super::bettor::enabled() || spot.villains.iter().filter(|v| !v.folded).count() != 1 {
return None;
}
let (i, rec) = spot.history.iter().enumerate().find(|(_, r)| {
r.street == street && (r.action.is_aggressive() || (r.seat == villain.seat && r.action == SeenAction::Check))
})?;
if rec.seat != villain.seat {
return None;
}
let bet = rec.action.is_aggressive();
// An all-in bet is read by its size: PHH has no stacks, our own NL2 all-in bets are too few for a curve.
let answer = if bet {
super::bettor::answer_of(ratios.get(i).copied().flatten(), false)?
} else {
'x'
};
let pfa = spot.history.iter().rev().find(|r| r.street == Street::Preflop && r.action.is_aggressive()).is_some_and(|r| r.seat == villain.seat);
let before = street != Street::Flop
&& spot.history.iter().any(|r| r.seat == villain.seat && r.street as usize + 1 == street as usize && r.action.is_aggressive());
super::bettor::likelihood(street, pfa, before, answer).map(|lk| (lk, bet))
}
/// One continuation for the villain on `street`, if their actions there say anything.
fn on_street(
spot: &Spot,
@@ -253,8 +323,12 @@ fn on_street(
) -> Vec<Continuation> {
let slot = street as usize - 1;
let sustained = aggressed_earlier(&spot.history, street, villain.seat);
// BETTOR: the open bet (or check) is read by its measured likelihood; a bet's class floor and
// bluff share then fall away, a later raise of the villain on the street keeps its floor.
let node = bettor_node(spot, villain, ratios, street);
let lk_bet = node.is_some_and(|(_, bet)| bet);
let made_bet =
own_aggression(&spot.history, ratios, street, villain.seat).map(|(lvl, ratio)| {
own_aggression(&spot.history, ratios, street, villain.seat).filter(|(lvl, _)| !(lk_bet && *lvl == 0)).map(|(lvl, ratio)| {
let bluff = bluff_share(villain.profile.as_ref(), ratio, street);
let tight = (lvl == 1 && street == Street::Turn && tighten_for(villain))
.then(turn_raise_bluff)
@@ -293,11 +367,14 @@ fn on_street(
min_draw,
bluff_share,
continue_share: None,
top_share: None,
// GEGEN_GROSS: a bet that puts hero all-in, or a river bet of at least a pot, keeps only the
// strongest share of the range as value (`gegen_gross_share`); the bluff share stays below it.
top_share: (made_bet.is_some() && street == spot.street).then(|| gegen_gross_share(spot, villain, ratios, street)).flatten(),
// WERT_BRETT=river: a river bet/raise floor means the same relative strength on every board.
min_strength: (street == Street::River && made_bet.is_some() && super::brett_floor::enabled())
.then(|| super::brett_floor::strength_cut(&spot.rules(), &spot.board, min_made))
.flatten(),
likelihood: None,
});
// Each further aggression on the street keeps the strongest r^(k-1) of what the first left, with
// the plain size bluff share below it (a sustained line earns no population over-bluff prior).
@@ -312,7 +389,18 @@ fn on_street(
},
..c
});
first.into_iter().chain(deeper).collect()
let measured = node.map(|(lk, _)| Continuation {
board_len: street.board_len(),
min_made: Made::Air,
draws_continue: false,
min_draw: Draw::Gutshot,
bluff_share: 0.0,
continue_share: None,
top_share: None,
min_strength: None,
likelihood: Some(lk),
});
measured.into_iter().chain(first).chain(deeper).collect()
}
/// Postflop narrowing from the villain own actions, one entry per dealt street
+137
View File
@@ -0,0 +1,137 @@
//! Messschalter `SIM_BETTOR=<Tabelle>`: die Pool-Gegner der Sim setzen (oder checken) an ihrem offenen
//! Wettknoten wie echte Spieler, nach derselben gemessenen Tabelle P(Antwort | Brett-Perzentil) je Knoten
//! (`messung/familie_a/bettor.py`, PHH NL25/50 mit NL2 geeicht), die `exploit::bettor` zum Lesen nimmt.
//!
//! Auftrag 17.11.: steht das Sim-Tor gegen das Live-Replay, ist die Sim falsch geeicht und ihr Setzverhalten
//! wird nach NL2 nachgeeicht. Die Personas setzen nach eigenen Regeln (Stärke-Schwellen, feste Größenmischung);
//! echte NL2-Spieler setzen klein mit fast allem und überbetten fast nur stark. Dieses Tor ersetzt, nur heads-up
//! und nur bei einem `pool-*`-Gegner, an der ersten Entscheidung einer Nach-Flop-Straße, auf der noch niemand
//! gesetzt hat, Check/Einsatz durch eine Ziehung aus der Tabellenzeile seines Knotens (Straße, Preflop-Aggressor,
//! eigene Aggression auf der Straße davor) am Perzentil seiner Hand (Anteil aller Starthände ohne Loch und Brett,
//! die sie am Brett schlägt, Gleichstand halb). Die Größe liegt gleichverteilt in der Klasse
//! (k 0.25-0.40, m 0.45-0.75, g 0.85-1.15, u 1.3-2.0 Pot), gekappt auf den Stack.
//!
//! Nur die Gegner ändern sich, eigener Zufall je Hand, Straße und Sitz (der Tisch-Rng bleibt unberührt).
//! Ungesetzt: aus, jede Sim bitgleich.
use super::opponent::{Act, View};
use crate::card::Card;
use crate::exploit::bettor::{parse_raw, Key, Likelihood, BINS};
use crate::hand::fast7::{mask, score};
type Row = (Key, char, Likelihood);
fn table() -> Option<&'static Vec<Row>> {
use std::sync::OnceLock;
static T: OnceLock<Option<Vec<Row>>> = OnceLock::new();
T.get_or_init(|| {
let path = std::env::var("SIM_BETTOR").ok().filter(|p| !p.is_empty())?;
let text = std::fs::read_to_string(&path).ok()?;
let rows: Vec<Row> = text.lines().filter_map(parse_raw).filter(|(_, a, _)| "xkmgu".contains(*a)).collect();
(!rows.is_empty()).then_some(rows)
})
.as_ref()
}
/// Is `SIM_BETTOR` on (a readable table)?
pub fn enabled() -> bool {
table().is_some()
}
/// Does the gate act for this opponent label? Only the calibrated pool personas.
pub fn gilt(label: &str) -> bool {
label.starts_with("pool-")
}
/// Share of all two-card holdings (without `hole` and `board`) that `hole` beats on `board`, ties half.
pub fn percentile(hole: &[Card], board: &[Card]) -> f64 {
let bm = mask(board);
let dead = bm | mask(hole);
let own = score(mask(hole) | bm);
let deck: Vec<u64> = (0..4).flat_map(|s| (0..13).map(move |r| 1u64 << (16 * s + r))).filter(|b| dead & b == 0).collect();
let (mut s, mut n) = (0.0, 0.0);
for i in 0..deck.len() {
for j in i + 1..deck.len() {
let o = score(deck[i] | deck[j] | bm);
s += if own > o { 1.0 } else if own == o { 0.5 } else { 0.0 };
n += 1.0;
}
}
if n > 0.0 { s / n } else { 0.5 }
}
/// The answer drawn at node `key` for percentile `p` with uniform `u` (`None`: node not in the table).
pub fn answer(key: Key, p: f64, u: f64) -> Option<char> {
let bin = ((p.clamp(0.0, 1.0) * BINS as f64) as usize).min(BINS - 1);
let rows: Vec<(char, f64)> = table()?.iter().filter(|(k, _, _)| *k == key).map(|(_, a, lk)| (*a, lk[bin])).collect();
draw(&rows, u)
}
fn draw(rows: &[(char, f64)], u: f64) -> Option<char> {
let total: f64 = rows.iter().map(|(_, w)| w).sum();
if total <= 0.0 {
return None;
}
let mut acc = 0.0;
for (a, w) in rows {
acc += w / total;
if u < acc {
return Some(*a);
}
}
rows.last().map(|(a, _)| *a)
}
/// Pot ratio of a bet of class `a` at uniform `v`.
pub fn ratio(a: char, v: f64) -> Option<f64> {
let (lo, hi) = match a {
'k' => (0.25, 0.40),
'm' => (0.45, 0.75),
'g' => (0.85, 1.15),
'u' => (1.3, 2.0),
_ => return None,
};
Some(lo + (hi - lo) * v.clamp(0.0, 1.0))
}
/// The act for answer `a` into `pot` (`None`: the opponent cannot bet, keep its own act).
pub fn act_of(a: char, v: f64, pot: f64, view: View) -> Option<Act> {
if a == 'x' {
return Some(Act::Check);
}
let (min, max) = view.min_raise_to.zip(view.max_raise_to)?;
Some(Act::RaiseTo((ratio(a, v)? * pot).clamp(min, max)))
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn draw_follows_weights() {
let rows = [('x', 0.5), ('k', 0.25), ('u', 0.25)];
assert_eq!(draw(&rows, 0.1), Some('x'));
assert_eq!(draw(&rows, 0.6), Some('k'));
assert_eq!(draw(&rows, 0.9), Some('u'));
assert_eq!(draw(&[], 0.5), None);
}
#[test]
fn nuts_rank_top_air_low() {
let board = Card::parse_list("Ah Kh Qh 2c 7d").unwrap();
let royal = Card::parse_list("Jh Th").unwrap();
let air = Card::parse_list("3s 4d").unwrap();
assert!(percentile(&royal, &board) > 0.999);
assert!(percentile(&air, &board) < 0.05);
}
#[test]
fn sizes_stay_in_class() {
assert_eq!(ratio('k', 0.0), Some(0.25));
assert_eq!(ratio('u', 1.0), Some(2.0));
assert_eq!(ratio('x', 0.5), None);
let v = View { to_call: 0.0, min_raise_to: Some(1.0), max_raise_to: Some(5.0) };
assert_eq!(act_of('u', 1.0, 10.0, v), Some(Act::RaiseTo(5.0)));
assert_eq!(act_of('x', 0.0, 10.0, v), Some(Act::Check));
}
}
+1
View File
@@ -6,6 +6,7 @@ pub mod arm_env;
pub mod adaptive;
pub mod aivat;
pub mod benchmark;
pub mod bettor_tor;
pub mod exploit_pop;
pub mod exploit_river;
pub mod gto;
+32
View File
@@ -562,11 +562,43 @@ impl Table<'_> {
blind => blind.act(view, self.rng),
};
self.rng = rng;
let act = self.bettor_tor(i, view, act);
let act = self.river_call(i, view, act);
self.pool_ruf(i, view, act)
}
}
/// Das geeichte Setzverhalten (`sim::bettor_tor`, `SIM_BETTOR`): an der offenen Entscheidung einer
/// Nach-Flop-Straße heads-up ersetzt es Check/Einsatz eines Pool-Gegners durch eine Ziehung aus der
/// gemessenen Tabelle. Aus (Standard) gibt es `act` unverändert zurück; der Tisch-Rng wird nie berührt.
fn bettor_tor(&self, i: usize, view: View, act: Act) -> Act {
if self.street == Street::Preflop || view.to_call > EPS || i == self.hero || self.live() != 2 || self.folded[self.hero] {
return act;
}
if !super::bettor_tor::enabled() {
return act;
}
match self.opps[i] {
Opponent::Welt(p) if super::bettor_tor::gilt(p.label) => {}
_ => return act,
}
let seat = i as u8 + 1;
if self.history.iter().any(|r| r.street == self.street && r.action.is_aggressive()) {
return act;
}
let pfa = self.history.iter().rev().find(|r| r.street == Street::Preflop && r.action.is_aggressive()).is_some_and(|r| r.seat == seat);
let before = self.street != Street::Flop
&& self.history.iter().any(|r| r.seat == seat && r.street as usize + 1 == self.street as usize && r.action.is_aggressive());
let board = &self.setup.deal.board[..self.street.board_len()];
let p = super::bettor_tor::percentile(&self.setup.deal.holes[i], board);
let salz = self.setup.seed ^ 0x4245_5454_4f52 ^ ((self.street as u64 + 1) << 40) ^ (i as u64 + 1).wrapping_mul(0x9E37_79B9_7F4A_7C15);
let (u, rng) = Rng::seeded(salz).unit();
let (v, _) = rng.unit();
let Some(a) = super::bettor_tor::answer((self.street, pfa, before), p, u) else { return act };
let pot: f64 = self.total.iter().sum();
super::bettor_tor::act_of(a, v, pot, view).unwrap_or(act)
}
/// Die stärkebewusste NL2-Antwort (`sim::poolruf`): auf den ersten Einsatz einer Nach-Flop-Straße (oder einen
/// Raise über den eigenen Einsatz) ersetzt sie Call/Fold eines Pool-Gegners durch die Call-Wahrscheinlichkeit
/// seiner Handklasse. Ein Raise bleibt. Aus (Standard) und ohne Mitschrift gibt sie `act` unverändert zurück;
+1
View File
@@ -28,6 +28,7 @@ fn spec(bluff_share: f64) -> RangeSpec {
continue_share: None,
top_share: None,
min_strength: None,
likelihood: None,
}],
}
}
+1
View File
@@ -45,6 +45,7 @@ fn floor_spec(min_made: Made, continue_share: Option<f64>) -> RangeSpec {
continue_share,
top_share: None,
min_strength: None,
likelihood: None,
}],
}
}
+1
View File
@@ -36,6 +36,7 @@ fn spec(top_share: Option<f64>, bluff_share: f64) -> RangeSpec {
continue_share: None,
top_share,
min_strength: None,
likelihood: None,
}],
}
}