Pruefstand: Vetos in der Begruendung, POSTERIOR auf echten Spots, Kandidaten fluss/ENTHALTUNG, Werkzeuge tor_echt + kippliste

- vermerk.rs: jede Regel, die eine Aktion nach der Grundrechnung ueberstimmt, haengt sich an reason;
  bitgleich auf 48 672 Anfragen (0 Abweichungen ausser reason)
- POSTERIOR=...,fluss (S2 nur am River): echte NL2-Spots holdout +53 276 bb eq; Tor wegen Pflichtfall offen
- ENTHALTUNG=passiv: gehaltener Raise im Fehler -> beste passive Linie statt ABSTAIN (Laeufer foldete +EV-Calls)
- livefaelle: Kommawerte (POSTERIOR=bluff,schutz,beleg) wurden abgeschnitten
- Alle neuen Schalter aus = Live-Stand bitgleich; nichts live geschaltet

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-18 18:00:02 +01:00
co-authored by Claude Opus 5.5
parent 1591d981ac
commit 031c550014
25 changed files with 4854 additions and 18 deletions
+6
View File
@@ -64,3 +64,9 @@ messung/leckfinder/*.teil/
messung/leckfinder/*.jsonl
messung/leckfinder/*.log
messung/grosse_calls/bin/
# Pruefstand (werkzeuge/kippliste.py, tor_echt.py): Kern-Kopien sind aus target/ reproduzierbar
messung/pruefstand/**/pokerbench-*.exe
messung/pruefstand/kipp/basis.jsonl
messung/pruefstand/kipp/kipp-*.json
messung/pruefstand/tor/*/kipp.json
+1 -1
View File
@@ -45,7 +45,7 @@ BEKANNTE_SCHALTER = ("MDF_UNREAD", "RAISE_DRAWS", "RAISE_PRIOR", "TURN_SPIEL", "
"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", "GEGEN_GROSS", "BETTOR", "VETO_AB", "UEBERSCHUSS", "VORFLOP_BAND", "VORFLOP_POP", "DREIBET_TOPF", "CHECK_FALLE", "CHECK_FALLE_AGGR", "CHECK_FALLE_VERTRAUEN", "CHECK_FALLE_EQ",
"TISCHWAHL", "TISCHWAHL_AB", "SITZWAHL", "GEGNER_GEDAECHTNIS", "ZEIGT_KIPP", "STATION_ZUG", "RAISE_FOLD_DECKEL", "STEAL_BREITE", "INFO_KONSISTENT", "EINSATZ_BLUFF", "WETT_KURVE", "UEBERWERT")
"TISCHWAHL", "TISCHWAHL_AB", "SITZWAHL", "GEGNER_GEDAECHTNIS", "ZEIGT_KIPP", "STATION_ZUG", "RAISE_FOLD_DECKEL", "STEAL_BREITE", "INFO_KONSISTENT", "EINSATZ_BLUFF", "WETT_KURVE", "UEBERWERT", "ENTHALTUNG")
# 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.
# GEGNER_GEDAECHTNIS (die Uebergabe hier in `_gedaechtnis`) liest os.environ: ohne diesen Eintrag
+77
View File
@@ -0,0 +1,77 @@
# POSTERIOR auf echten NL2-Spots: Top-Paar+ gegen Flop-/Turn-Raise eines selten Erhöhenden
Prüfstand 18.11.
**Frage.** Ist es richtig, Top-Paar oder besser gegen einen Raise auf Flop oder Turn zu folden, wenn der Gegner selten erhöht? Das tut der Live-Stand mit `POSTERIOR=bluff,schutz,beleg` + `GEGNER_LINIEN` + `POOL_STUFE=rtb`.
**Antwort: Nein, auf dem Flop klar falsch; auf dem Turn neutral.** Der Kandidat `POSTERIOR=bluff,schutz,beleg,fluss` wirkt nur am River. Er nimmt den Schaden vollständig heraus.
## Daten und Methode
Wie `messung/grosse_calls`:
- **Daten:** hhDealer CoinPoker NL2 6-max, 12,4 Mio. Hände (`nl2-6max-1jahr.zip`).
- **Spots:** Caller-Sicht (`spots2.jsonl` / `spots2.holdout.jsonl`, Spieler-Holdout), Muck-IPW-Gewicht `w`.
- **Filter:** Der Entscheider hat auf dieser Straße gesetzt und wurde erhöht (Linie `geraist`). Nur Flop und Turn, Handklasse Top-Paar oder besser.
- **Erzeugung:** `posterior_spots.py`, ausgewertet mit `posterior_bewerten.py`.
- **Gegner-Read:** Die Profile der Spots tragen keine Reads. Eingesetzt ist `reads.raiseToBet {n:1, k:0}`, also genau der Live-Zustand im Owner-Fall: ein Raise-Versuch gezählt, keiner erhöht. Das ist der Fall, gegen den S2 + `beleg` voll greifen.
- **Ergebnis:** 10 737 Spots dev (2 863 Setzer), 12 340 Spots holdout (3 358 Setzer). Holdout wurde einmal ausgewertet, nach der Wahl des Kandidaten auf dev.
- **Zwei Maße.** EV jeweils minus EV live in bb, Summe über die Spots, 95 %-Bootstrap über die Erhöher.
- `eq`: Equity gegen die gezeigte Hand × Topf nach Rake − Call.
- `real`: was die Population mit dem Weiterspielen wirklich gewann.
## Fold-Anteile (gewichtet)
| | vorne (Equity ≥ 0,5) | Fold live | Fold ohne POSTERIOR = `fluss` |
|---|---|---|---|
| Flop gesamt (dev / holdout) | 64 % / 64 % | 21 % / 27 % | 7 % / 7 % |
| Flop Top-Paar | 47 % / 48 % | 34 % / 43 % | 12 % / 11 % |
| Flop Overpair | 66 % / 65 % | 17 % / 20 % | 5 % / 5 % |
| Flop Zwei Paar | 77 % / 79 % | 18 % / 19 % | 3 % / 3 % |
| Flop Drilling | 87 % / 89 % | 5 % / 6 % | 2 % / 2 % |
| Turn gesamt | 59 % / 59 % | 27 % / 26 % | 27 % / 26 % |
Auf dem Turn entscheidet POSTERIOR praktisch nichts. Die Turn-Folds kommen aus `TURN_RAISE_NUR`.
## EV-Differenz gegen Live (bb, Summe, 95 %)
| Arm | dev `eq` | dev `real` | holdout `eq` | holdout `real` |
|---|---|---|---|---|
| POSTERIOR aus | +37 261 [+30 789, +45 052] | +30 395 [+20 591, +40 874] | +53 276 [+45 250, +61 451] | +38 323 [+24 970, +51 085] |
| **`POSTERIOR=bluff,schutz,beleg,fluss`** | **+37 261 (identisch)** | **+30 395** | **+53 276** | **+38 323** |
| `GEGNER_LINIEN` aus | +15 170 | | +44 411 [+37 186, +52 074] | +29 470 [+18 710, +40 786] |
| `POOL_STUFE` aus | +20 486 | | +30 286 [+24 652, +36 805] | +18 716 [+9 357, +28 502] |
| `flussnur` (nur die Linientabelle auf den River) | +15 170 [+10 932, +19 725] | +14 204 | – | – |
Nach Straße und Klasse:
- **Flop** dev `eq` +36 712, holdout +53 464.
- **Turn** dev +549 [+56, +1 191], holdout −188 [−497, +24]: neutral.
- **Flop Top-Paar** holdout `eq` +22 058 [+17 269, +26 971].
- `real` +6 964 [−1 780, +16 449]: Top-Paar allein ist im echten Ausgang nicht signifikant.
- Overpair, Zwei Paar und Drilling sind es je einzeln.
- **Regulars als Erhöher** (n = 61 / 90): `eq` dev +2 031, holdout +2 003, beide signifikant. `real` schließt 0 ein.
## Warum
S2 (`glaube::bluff`) setzt den Bluff-Anteil eines Raises nach Linie und Read. Gegen „hebt selten“ drückt es ihn unter 0,05; im Owner-Fall war er 0,013, ohne POSTERIOR 0,400. Danach greift `bluff_catch_blocked`: Eine Hand unter der Wertgrenze (Overpair) darf nicht mehr bluff-fangen. Der Call fällt weg, obwohl die Equity weit über Break-even liegt.
Auf dem Flop ist das falsch:
- Ein NL2-Flop-Raise kommt aus einer breiten Range: Werte, Draws, Top-Paar-Schutz-Raises.
- Die Bluff-Fang-Logik ist für den River gebaut. Dort ist eine Range ohne Bluffs wirklich nur Wert.
- Auf dem Flop hat Top-Paar+ gegen Draws und schwächere Paare Equity, auch ohne einen einzigen Bluff.
## Kandidat
`POSTERIOR=bluff,schutz,beleg,fluss`. Neues Token `fluss`: S2 nur am River, Flop und Turn behalten den eingehenden Bluff-Anteil.
- Aus (ohne `fluss`) bitgleich zum Live-Stand.
- Am River bleibt S2 wie live; dort hat es nemesis-3 und die River-Folds getragen.
- Owner-Hand 180165100008 (KsJs, J24, Flop-Raise):
- live FOLD „EV call +0,16 | POSTERIOR: Raise selten geblufft (Bluffanteil 0.013, ohne POSTERIOR 0.400) …“
- Kandidat CALL.
- Tor: `tor/posterior-fluss/TOR.md`.
## Grenzen
- **Caller-Sicht.** Nur Hände, in denen der Erhöhte weiterspielte oder zeigte, korrigiert durch Muck-IPW.
- **`eq` ohne spätere Straßen.** Dass wir nach dem Call auf dem Turn noch folden können, fehlt.
- **Eingesetzter Read** (n = 1). Echte Reads mit vielen Raises schwächen S2 über `schutz` ab.
- Die Zahlen sind Summen über die Spots, nicht bb/100.
+67
View File
@@ -0,0 +1,67 @@
#!/usr/bin/env python3
"""Bitgleich bis auf den Text: zwei Kern-Binaries mit denselben Schaltern auf denselben Anfragen; verglichen werden alle
Antwortfelder außer `reason` (Aktion, Größe, Konfidenz, Equity, Kategorie, Reads, EVs).
python3 messung/pruefstand/bitgleich.py <kern-alt.exe> <kern-neu.exe> <anfragen.jsonl>... [--schalter betrieb/kern_schalter.txt]
[--prozesse 4] [--max 20000]
Eine Zeile der Anfragedatei ist entweder die Anfrage selbst, ein Spot mit `req` oder eine Schatten-Zeile mit `anfrage`.
Ausgang 1, wenn ein Feld außer `reason` abweicht. Druckt die Zahl der Anfragen, der geänderten Texte und Beispiele.
"""
import argparse
import json
import os
import sys
_HIER = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, os.path.join(_HIER, "..", "..", "werkzeuge"))
import kippliste as kl # noqa: E402
def anfragen(pfade, maximal):
out = []
for p in pfade:
for z in open(p, encoding="utf-8"):
if not z.strip():
continue
d = json.loads(z)
req = d.get("req") or d.get("anfrage") or d
if isinstance(req, dict) and "street" in req:
out.append({"req": req})
if len(out) >= maximal:
return out
return out
def main():
ap = argparse.ArgumentParser()
ap.add_argument("alt")
ap.add_argument("neu")
ap.add_argument("dateien", nargs="+")
ap.add_argument("--schalter", default=os.path.join(_HIER, "..", "..", "betrieb", "kern_schalter.txt"))
ap.add_argument("--prozesse", type=int, default=4)
ap.add_argument("--max", type=int, default=20000)
a = ap.parse_args()
env = kl.lies_schalter(a.schalter)
env.pop("TISCHWAHL", None)
sp = anfragen(a.dateien, a.max)
x = kl.kern_lauf(a.alt, sp, env, a.prozesse)
y = kl.kern_lauf(a.neu, sp, env, a.prozesse)
abw, text = [], []
for s, u, v in zip(sp, x, y):
uu = {k: w for k, w in u.items() if k != "reason"}
vv = {k: w for k, w in v.items() if k != "reason"}
if uu != vv:
abw.append((s, u, v))
elif u.get("reason") != v.get("reason"):
text.append((u.get("reason"), v.get("reason")))
print("%d Anfragen, %d Abweichungen ausser reason, %d neue Begruendungstexte" % (len(sp), len(abw), len(text)))
for _, u, v in abw[:5]:
print("ABWEICHUNG", json.dumps(u)[:300], "\n ->", json.dumps(v)[:300])
for u, v in text[:12]:
print("TEXT", (v or "")[len(u or ""):][:260])
return 1 if abw else 0
if __name__ == "__main__":
sys.exit(main())
+1
View File
@@ -0,0 +1 @@
764d1635f504d44c79101b530e41ef2076cd8a97e39fdb91da1922099de1a1b3
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+105
View File
@@ -0,0 +1,105 @@
#!/usr/bin/env python3
"""POSTERIOR auf echten Spots, Schritt 2: EV je Arm gegen den Live-Stand auf den Spots aus `posterior_spots.py`.
EV wie messung/grosse_calls/population.py (`ev_aktion`, Fold = 0, Raise zählt als Weiterspielen):
`eq` Flop/Turn: Equity gegen die gezeigte Hand des Erhöhers x Topf nach Rake - Call (ohne spätere Einsätze).
`real` was die Population mit dem Weiterspielen wirklich gewann: Ausgang x Endtopf nach Rake - alles, was sie ab
diesem Spot noch einzahlte (spätere Einsätze und Folds der Population inbegriffen; sie spielt weiter, nicht wir).
Gewicht `w`: Muck-IPW aus den Spots (1/g je Rolle). Intervall: 95 %-Bootstrap über die Erhöher (pid_o).
python -I -X utf8 messung/pruefstand/posterior_bewerten.py <spots.jsonl> <live.jsonl> <arm.jsonl>... [--boot 1000] [--json aus.json]
"""
import collections
import json
import os
import sys
import numpy as np
_HIER = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, os.path.join(_HIER, "..", "grosse_calls"))
sys.path.insert(0, os.path.join(_HIER, "..", "..", "lesen"))
import population as P # noqa: E402
import leckfinder as lf # noqa: E402
def ev_real(sp, aktion):
a = str(aktion or "").upper()
if a in ("FOLD", "ABSTAIN", ""):
return 0.0
return sp["ausg"] * lf.nach_rake(sp["topf_end"]) - (sp["inv_end"] - sp["inv_spot"])
def filter_von(sp):
st = "flop" if sp["strasse"] == 1 else "turn"
f = [st, sp["klasse"], "%s_%s" % (st, sp["klasse"])]
f.append("reg_setzer" if sp["reg_o"] else "kein_reg_setzer")
f.append("typ_" + sp["typ"])
f.append("tp" if sp["klasse"] == "top_paar" else "besser_als_tp")
return f
def main(a):
boot = int(a[a.index("--boot") + 1]) if "--boot" in a else 1000
aus = a[a.index("--json") + 1] if "--json" in a else None
pos = [x for i, x in enumerate(a) if not x.startswith("--") and (i == 0 or a[i - 1] not in ("--boot", "--json"))]
spots, dateien = pos[0], pos[1:]
S = {}
for z in open(spots, encoding="utf-8"):
sp = json.loads(z)
sp.pop("req", None)
S[sp["id"]] = sp
A = [{json.loads(z)["id"]: json.loads(z) for z in open(d, encoding="utf-8")} for d in dateien]
namen = [os.path.basename(d).replace(".jsonl", "") for d in dateien]
T = {m: collections.defaultdict(lambda: collections.defaultdict(lambda: np.zeros(len(A) - 1))) for m in ("eq", "real")}
kipp = collections.Counter()
fold_anteil = collections.defaultdict(lambda: np.zeros(len(A)))
n_f = collections.Counter()
ahead = collections.defaultdict(lambda: [0.0, 0.0])
for i, sp in S.items():
if not all(i in x for x in A):
continue
akt = [x[i].get("action") for x in A]
for f in filter_von(sp) + ["alle"]:
fold_anteil[f] += sp["w"] * np.array([1.0 if str(x).upper() in ("FOLD", "ABSTAIN") else 0.0 for x in akt])
n_f[f] += sp["w"]
ahead[f][0] += sp["w"] * (1.0 if sp["eq"] is not None and sp["eq"] >= 0.5 else 0.0)
ahead[f][1] += sp["w"]
for k in range(1, len(A)):
if str(akt[0]).upper() != str(akt[k]).upper():
kipp["%s: %s->%s" % (namen[k], akt[0], akt[k])] += 1
for m, fn in (("eq", lambda x: P.ev_aktion(sp, x[i].get("action"), x[i].get("size"))), ("real", lambda x: ev_real(sp, x[i].get("action")))):
ev = [sp["w"] * fn(x) for x in A]
d = np.array([e - ev[0] for e in ev[1:]])
for f in filter_von(sp) + ["alle"]:
T[m][f][sp["pid_o"]] += d
rng = np.random.default_rng(7)
erg = {"arme": namen, "kipps": dict(kipp), "fold": {}, "vorne": {}, "delta": {}}
for f in sorted(n_f):
erg["fold"][f] = [round(float(x / n_f[f]), 3) for x in fold_anteil[f]]
erg["vorne"][f] = round(ahead[f][0] / max(ahead[f][1], 1e-9), 3)
for m in T:
erg["delta"][m] = {}
for f in sorted(T[m]):
mat = np.array(list(T[m][f].values()))
s = mat.sum(0)
idx = rng.integers(0, len(mat), size=(boot, len(mat)))
b = np.stack([mat[j].sum(0) for j in idx])
lo, hi = np.percentile(b, 2.5, axis=0), np.percentile(b, 97.5, axis=0)
erg["delta"][m][f] = {"setzer": len(mat), **{n: [round(float(s[k]), 1), round(float(lo[k]), 1), round(float(hi[k]), 1)]
for k, n in enumerate(namen[1:])}}
print("Arme:", namen)
print("Kipps:", dict(kipp.most_common(12)))
print("%-24s %8s %s" % ("Filter", "vorne", "Fold-Anteil je Arm"))
for f in sorted(n_f):
print("%-24s %8.3f %s" % (f, erg["vorne"][f], " ".join("%.3f" % x for x in erg["fold"][f])))
for m in T:
print("\nDelta gegen %s (bb, Summe, 95 %%) Mass %s" % (namen[0], m))
for f, d in erg["delta"][m].items():
print("%-24s setzer %5d " % (f, d["setzer"]) + " ".join("%s %+7.0f [%+.0f, %+.0f]" % (n, *d[n]) for n in namen[1:]))
if aus:
json.dump(erg, open(aus, "w", encoding="utf-8", newline="\n"), indent=1, ensure_ascii=False)
if __name__ == "__main__":
main(sys.argv[1:])
+50
View File
@@ -0,0 +1,50 @@
#!/usr/bin/env python3
"""POSTERIOR auf echten Spots, Schritt 1: Flop-/Turn-Spots, in denen der Entscheider auf dieser Strasse gesetzt hat und
erhoeht wurde (Linie `geraist` aus messung/grosse_calls/population.py), Hand des Entscheiders Top-Paar oder besser.
Der Erhoeher bekommt den Read, den der Laeufer live schickt (GEGNER_ZAEHLUNG=raise): `reads.raiseToBet` mit n Faellen,
k Erhoehungen (Vorgabe n=1, k=0 wie im Owner-Fall 180165100008). Mit POOL_STUFE=rtb liegt die Schaetzung dann bei
~0,10 (selten erhoehend) und POSTERIOR S2 greift voll.
python -I -X utf8 messung/pruefstand/posterior_spots.py <spots2.jsonl> <aus.jsonl> [--n 1 --k 0]
Spots enthalten keine Namen (nur Hashes) und bleiben ausserhalb des Repos.
"""
import json
import os
import sys
_hier = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, os.path.join(_hier, "..", "..", "lesen"))
import poolruf_eichung as pe # noqa: E402
AB_KLASSE = 3 # top_paar
def main(a):
ein, aus = a[0], a[1]
n = int(a[a.index("--n") + 1]) if "--n" in a else 1
k = int(a[a.index("--k") + 1]) if "--k" in a else 0
z = 0
with open(aus, "w", encoding="utf-8", newline="\n") as f:
for zeile in open(ein, encoding="utf-8"):
if '"geraist"' not in zeile:
continue
sp = json.loads(zeile)
if sp["strasse"] not in (1, 2) or "geraist" not in sp["linien"]:
continue
kl = pe.klasse(sp["held"], sp["brett"])
if kl < AB_KLASSE:
continue
sp["klasse"] = pe.KLASSEN[kl]
for v in sp["req"]["villains"]:
if not v.get("folded"):
pr = v.setdefault("profile", {"hands": 1})
pr["reads"] = {"raiseToBet": {"n": n, "k": k}}
f.write(json.dumps(sp, separators=(",", ":")) + "\n")
z += 1
print(z, "Spots")
if __name__ == "__main__":
main(sys.argv[1:])
@@ -0,0 +1,32 @@
# Tor echt: `POSTERIOR=bluff,schutz,beleg,fluss`
**Urteil: DURCHGEFALLEN**
- Verlierer: Pflichtfälle: 1 harte Verlierer
## 1 EV auf echten NL2-Spots (Caller-Sicht, bb, 95 %-Bootstrap über die Setzer)
| Teil | Spots | Δ alle | Flop | Turn | River | geänderte Aktionen |
|---|---|---|---|---|---|---|
| dev | 16152 | +0 [+0, +0] | +0 [+0, +0] | +0 [+0, +0] | +0 [+0, +0] | |
| holdout | 18338 | +0 [+0, +0] | +0 [+0, +0] | +0 [+0, +0] | +0 [+0, +0] | |
| post-dev.jsonl | 10737 | +37261 [+30789, +45052] | +36712 [+29818, +43595] | +549 [+58, +1177] | – | flop FOLD->CALL 793, flop CALL->RAISE 190, flop FOLD->RAISE 38, turn FOLD->CALL 8 |
| post-holdout.jsonl | 12340 | +53383 [+45355, +61730] | +53572 [+46084, +61811] | -188 [-489, +30] | – | flop FOLD->CALL 1287, flop CALL->RAISE 421, flop FOLD->RAISE 69, turn FOLD->CALL 8 |
## 2 Pflichtfälle
DURCHGEFALLEN: Soll Live 35/43, Arm 34/43, Ziele behoben 0/6, harte Verlierer 1
- 178543200043 FLOP: live RAISE -> RAISE (trips on dry board: equity 0.82 vs break-even 0.29, EV raise to 1.75 +0.59)
## 3 Eigen-Replay (eigene Kern-Anfragen aus den Schatten-Logs)
11449 Anfragen, 14 anders: FLOP FOLD->CALL 9, FLOP FOLD->RAISE 2, TURN FOLD->CALL 2, RIVER FOLD->CALL 1
Prämie zum Fold: 0; Pflichtregel-Brüche: 0
## 4 Kipp-Liste (Raster: 169 Starthände je Lage, Postflop je Handklasse)
29758 Spots, 37 gekippt, 9 nur Größe, **0 hart**; Richtungen: FOLD->CALL 32, CALL->RAISE 3, CALL->FOLD 1, RAISE->CALL 1
## 5 LBR (S1, gepaart)
{"haende": 40, "bitgleich": true, "delta_bb100": 0.0, "ci_bb100": [0.0, 0.0], "live_bb100": 255.25}
@@ -0,0 +1,40 @@
0 2.5
3 2.5
1 2.5
6 -4.15
5 2.5
2 2.5
7 2.5
4 2.5
9 2.5
11 2.5
12 2.5
13 2.5
15 -2.5
8 2.5
16 -4.15
10 -4.15
18 -4.15
14 2.5
21 2.5
20 4.15
22 -2.5
17 6.25
23 2.5
19 12.5
27 -2.5
24 4.15
28 -6.25
25 12.5
29 2.5
30 2.5
26 4.15
32 2.5
31 2.5
33 2.5
35 2.5
34 18.75
37 2.5
36 6.25
39 2.5
38 6.25
@@ -0,0 +1,40 @@
0 2.5
3 2.5
1 2.5
6 -4.15
5 2.5
2 2.5
7 2.5
4 2.5
9 2.5
11 2.5
12 2.5
13 2.5
15 -2.5
8 2.5
16 -4.15
10 -4.15
18 -4.15
14 2.5
21 2.5
20 4.15
22 -2.5
17 6.25
23 2.5
19 12.5
27 -2.5
24 4.15
28 -6.25
25 12.5
30 2.5
26 4.15
29 2.5
32 2.5
31 2.5
33 2.5
35 2.5
34 18.75
37 2.5
36 6.25
39 2.5
38 6.25
@@ -0,0 +1,342 @@
{
"arm": "POSTERIOR=bluff,schutz,beleg,fluss",
"aenderung": {
"POSTERIOR": "bluff,schutz,beleg,fluss"
},
"ev": {
"dev": {
"spots": 16152,
"anders": {},
"delta": {
"alle": [
0.0,
0.0,
0.0,
3605
],
"river": [
0.0,
0.0,
0.0,
2052
],
"turn": [
0.0,
0.0,
0.0,
2338
],
"flop": [
0.0,
0.0,
0.0,
1655
]
}
},
"holdout": {
"spots": 18338,
"anders": {},
"delta": {
"alle": [
0.0,
0.0,
0.0,
4241
],
"turn": [
0.0,
0.0,
0.0,
2689
],
"river": [
0.0,
0.0,
0.0,
2402
],
"flop": [
0.0,
0.0,
0.0,
1858
]
}
}
},
"ev_extra": {
"post-dev.jsonl": {
"spots": 10737,
"anders": {
"flop FOLD->CALL": 793,
"flop CALL->RAISE": 190,
"flop FOLD->RAISE": 38,
"turn FOLD->CALL": 8,
"flop RAISE->CALL": 4,
"flop CALL->FOLD": 3,
"turn CALL->RAISE": 3,
"turn ABSTAIN->RAISE": 2,
"turn RAISE->CALL": 1
},
"delta": {
"alle": [
37260.7,
30788.9,
45051.9,
2863
],
"flop": [
36711.5,
29817.9,
43594.7,
2059
],
"turn": [
549.2,
58.3,
1177.0,
1930
]
}
},
"post-holdout.jsonl": {
"spots": 12340,
"anders": {
"flop FOLD->CALL": 1287,
"flop CALL->RAISE": 421,
"flop FOLD->RAISE": 69,
"turn FOLD->CALL": 8,
"flop CALL->FOLD": 7,
"flop RAISE->CALL": 7,
"turn CALL->RAISE": 3,
"turn RAISE->CALL": 3,
"flop ABSTAIN->CALL": 1,
"turn FOLD->ABSTAIN": 1,
"flop ABSTAIN->RAISE": 1,
"flop CALL->ABSTAIN": 1
},
"delta": {
"alle": [
53383.3,
45355.4,
61729.8,
3358
],
"turn": [
-188.2,
-488.7,
29.9,
2181
],
"flop": [
53571.6,
46084.4,
61811.2,
2397
]
}
}
},
"pflicht": {
"bestanden": false,
"verlierer": 1,
"n": 43,
"live_soll": 35,
"kandidat_soll": 34,
"ziele_behoben": 0,
"ziele": 6,
"verlierer_faelle": [
{
"hand": "178543200043",
"street": "FLOP",
"live": "RAISE",
"kandidat": "RAISE",
"grund": "trips on dry board: equity 0.82 vs break-even 0.29, EV raise to 1.75 +0.59"
}
]
},
"replay": {
"anfragen": 11449,
"anders": 14,
"richtung": {
"FLOP FOLD->CALL": 9,
"FLOP FOLD->RAISE": 2,
"TURN FOLD->CALL": 2,
"RIVER FOLD->CALL": 1
},
"praemie_zum_fold": [],
"n_praemie_zum_fold": 0,
"pflichtregel_bruch": [],
"n_pflichtregel_bruch": 0,
"beispiele": [
{
"zug": "14R NL 0.01-0.02 EV-INRIT-(A) 1783945|178394500442|FLOP|0.24|0.08|QHSH|()",
"street": "FLOP",
"hand": "Qh6h",
"klasse": "top_paar",
"live": "FOLD",
"arm": "CALL",
"grund_arm": "top pair weak kicker on medium board: equity 0.64 vs break-even 0.26, EV call +0.11"
},
{
"zug": "14R NL 0.01-0.02 EV-INRIT-(A) 1784759|178475900270|FLOP|0.42|0.18|ACTC|()",
"street": "FLOP",
"hand": "Ac3c",
"klasse": "top_paar",
"live": "FOLD",
"arm": "CALL",
"grund_arm": "top pair weak kicker on medium board: equity 0.63 vs break-even 0.32, EV call +0.18"
},
{
"zug": "14R NL 0.01-0.02 EV-INRIT-(A) 1785004|178500400069|FLOP|0.21|0.09|QDTS|()",
"street": "FLOP",
"hand": "QdTs",
"klasse": "paar_schwach",
"live": "FOLD",
"arm": "CALL",
"grund_arm": "middle pair on medium board (2-way): equity 0.39 vs break-even 0.32, EV call +0.02"
},
{
"zug": "14R NL 0.01-0.02 EV-INRIT-(A) 1784931|178493100165|FLOP|0.56|0.28|ESAH|()",
"street": "FLOP",
"hand": "8sAh",
"klasse": "top_paar",
"live": "FOLD",
"arm": "RAISE",
"grund_arm": "top pair good kicker on medium board: equity 0.62 vs break-even 0.35, EV raise to 0.64 +0.26"
},
{
"zug": "14R NL 0.01-0.02 EV-INRIT-(A) 1789081|178908100678|FLOP|0.28|0.12|FDAH|()",
"street": "FLOP",
"hand": "4dAh",
"klasse": "paar_schwach",
"live": "FOLD",
"arm": "CALL",
"grund_arm": "middle pair on dry board: equity 0.51 vs break-even 0.32, EV call +0.07"
},
{
"zug": "14R NL 0.01-0.02 EV-INRIT-(A) 1790035|179003500241|FLOP|0.31|0.08|EHES|()",
"street": "FLOP",
"hand": "8h8s",
"klasse": "paar_schwach",
"live": "FOLD",
"arm": "CALL",
"grund_arm": "middle pair on medium board (2-way): equity 0.34 vs break-even 0.22, EV call +0.04"
},
{
"zug": "14R NL 0.01-0.02 EV-INRIT-(A) 1789081|178908100715|FLOP|0.2|0.06|ACSD|()",
"street": "FLOP",
"hand": "Ac7d",
"klasse": "paar_schwach",
"live": "FOLD",
"arm": "CALL",
"grund_arm": "middle pair on dry board (2-way): equity 0.38 vs break-even 0.24, EV call +0.03"
},
{
"zug": "14R NL 0.01-0.02 EV-INRIT-(A) 1789078|178907801550|TURN|3.78|0.98|AHEH|()",
"street": "TURN",
"hand": "Ah8h",
"klasse": "paar_schwach",
"live": "FOLD",
"arm": "CALL",
"grund_arm": "middle pair with combo draw on medium board: equity 0.45 vs break-even 0.25, EV call +0.77"
},
{
"zug": "14R NL 0.01-0.02 EV-INRIT-(A) 1794220|179422000199|FLOP|0.81|0.35|KCJS|()",
"street": "FLOP",
"hand": "KcJs",
"klasse": "top_paar",
"live": "FOLD",
"arm": "RAISE",
"grund_arm": "top pair good kicker on medium board: equity 0.68 vs break-even 0.32, EV raise to 1.28 +0.59"
},
{
"zug": "14R NL 0.01-0.02 EV-INRIT-(A) 1792602|179260200727|FLOP|1.11|0.65|QDQH|()",
"street": "FLOP",
"hand": "QdQh",
"klasse": "overpair",
"live": "FOLD",
"arm": "CALL",
"grund_arm": "overpair on medium board: equity 0.49 vs break-even 0.39, EV call +0.16"
},
{
"zug": "14R NL 0.01-0.02 EV-INRIT-(A) 1794597|179459700036|FLOP|0.29|0.11|KSSS|()",
"street": "FLOP",
"hand": "Ks6s",
"klasse": "top_paar",
"live": "FOLD",
"arm": "CALL",
"grund_arm": "top pair weak kicker on medium board (2-way): equity 0.43 vs break-even 0.29, EV call +0.05"
},
{
"zug": "14R NL 0.01-0.02 EV-INRIT-(A) 1795600|179560000003|RIVER|0.59|0.15|SCAC|()",
"street": "RIVER",
"hand": "7cAc",
"klasse": "top_paar",
"live": "FOLD",
"arm": "CALL",
"grund_arm": "top pair weak kicker on four-flush board: equity 0.34 vs break-even 0.21, EV call +0.09"
},
{
"zug": "14R NL 0.01-0.02 EV-INRIT-(A) 1793205|179320500839|TURN|0.2|0.05|TCAH|()",
"street": "TURN",
"hand": "TcAh",
"klasse": "nichts",
"live": "FOLD",
"arm": "CALL",
"grund_arm": "air on medium board (2-way): equity 0.29 vs break-even 0.21, EV call +0.02"
},
{
"zug": "14R NL 0.01-0.02 EV-INRIT-(A) 1801651|180165100008|FLOP|0.53|0.22|KSJS|()",
"street": "FLOP",
"hand": "KsJs",
"klasse": "top_paar",
"live": "FOLD",
"arm": "CALL",
"grund_arm": "top pair good kicker on dry board: equity 0.65 vs break-even 0.31, EV call +0.24 | PAAR_RAISE: ein Paar gegen passiv gelesene Gegner -> kein Value-Raise"
}
]
},
"kipp": {
"arm": "POSTERIOR=bluff,schutz,beleg,fluss",
"spots": 29758,
"gekippt": 37,
"groesse": 9,
"hart": 0,
"richtung": {
"FOLD->CALL": 32,
"CALL->RAISE": 3,
"CALL->FOLD": 1,
"RAISE->CALL": 1
},
"klassen": {
"paar_schwach": 9,
"zug": 9,
"zwei_paar": 7,
"top_paar": 6,
"overpair": 3,
"nichts": 2,
"monster": 1
},
"lagen": {
"FLOP srp BTN": 37
},
"harte_beispiele": []
},
"lbr": {
"haende": 40,
"bitgleich": true,
"delta_bb100": 0.0,
"ci_bb100": [
0.0,
0.0
],
"live_bb100": 255.25
},
"urteil": "DURCHGEFALLEN",
"gruende": [
"Pflichtfälle: 1 harte Verlierer"
],
"offen": []
}
+30
View File
@@ -174,3 +174,33 @@ pub fn bluff_catch_blocked(spot: &Spot, read: &HandRead) -> bool {
&& !has_real_draw(read, spot.street)
&& bettor(spot).is_some_and(|(_, c)| read.made < c.min_made && c.bluff_share < MIN_BLUFF_SHARE)
}
/// Vermerk (text only) for a call removed by `bluff_catch_blocked`: the bettor's bluff share, the hand
/// against his value floor, and which switch pushed the share under `MIN_BLUFF_SHARE` - POSTERIOR when
/// the same continuation without it would clear the bar (counterfactual, override restored), else
/// TURN_RAISE_NUR on a turn raise, else the range model.
pub fn bluff_catch_vermerk(spot: &Spot, read: &HandRead) -> String {
let Some((v, c)) = bettor(spot) else { return "Bluff-Fang gesperrt -> fold".into() };
let before = super::glaube::current_override();
let ohne = super::glaube::mode().is_some_and(|m| m.bluff).then(|| {
super::glaube::set_override(Some(None));
let x = bettor(spot).map(|(_, c)| c.bluff_share);
super::glaube::set_override(before);
x
});
let ohne = ohne.flatten();
let raised = spot
.history
.iter()
.filter(|r| r.street == spot.street && r.action.is_aggressive())
.count()
>= 2;
let wer = match ohne {
Some(x) if x >= MIN_BLUFF_SHARE => format!("POSTERIOR: {} selten geblufft (Bluffanteil {:.3}, ohne POSTERIOR {x:.3})", if raised { "Raise" } else { "Einsatz" }, c.bluff_share),
_ if raised && spot.street == crate::game::Street::Turn && crate::exploit::street_continuation::tighten_for(v) => {
format!("TURN_RAISE_NUR: Turn-Raise ohne Bluffs (Bluffanteil {:.3})", c.bluff_share)
}
_ => format!("Range-Modell: Bluffanteil {:.3}", c.bluff_share),
};
format!("{wer} < {MIN_BLUFF_SHARE:.2}, {:?} unter Wertgrenze {:?} -> kein Bluff-Fang -> fold", read.made, c.min_made)
}
+22 -4
View File
@@ -84,7 +84,8 @@ fn postflop(spot: &Spot, thresholds: &Thresholds, raw: &Spot, premium: f64) -> D
crate::exploit::fold_chance::set_ueberbet_hand(super::options::holds_one_pair(spot, &hand_read));
super::check_falle::merke_roh(raw);
let base = choose_postflop_with(spot, &equity, &called_equity(spot), thresholds, &hand_read);
let floored = crate::exploit::mdf_floor::floor(raw, hand_read.made, base).with_equity(equity.share);
let floored = crate::exploit::mdf_floor::floor(raw, hand_read.made, base.clone()).with_equity(equity.share);
let floored = super::vermerk::ersetzt(&base, floored);
// Defensive river veto (the belief+trust gearbox, CASH ONLY): a confident read that the
// villain UNDER-bluffs its river bet turns a heuristic call into a fold. This is the one
// place the gearbox is a proven edge — the heuristic over-calls under-bluffed overbets
@@ -124,7 +125,7 @@ fn postflop(spot: &Spot, thresholds: &Thresholds, raw: &Spot, premium: f64) -> D
// heuristic.
let e3 = if super::turn_game::turn_ueberall() { None } else { super::turn_game::turn_game_decision(raw) };
if let Some(d) = e3 {
return d.with_equity(equity.share);
return super::vermerk::ersetzt(&floored, d.with_equity(equity.share));
}
// Stage B, solver everywhere (off by default, SOLVER_TURN): every heads-up turn.
if let Some(d) = super::turn_game::turn_solver_decision(raw) {
@@ -140,7 +141,8 @@ fn postflop(spot: &Spot, thresholds: &Thresholds, raw: &Spot, premium: f64) -> D
return d.with_equity(equity.share);
}
// Bounded exploitation of the non-station reads (`read_exploit`, switch GEGNER_BREIT, off).
return super::read_exploit::postflop(raw, &hand_read, super::river_subgame::fold_veto(raw, floored));
let vetoed = super::vermerk::ersetzt(&floored, super::river_subgame::fold_veto(raw, floored.clone()));
return super::read_exploit::postflop(raw, &hand_read, vetoed);
}
floored
}
@@ -258,7 +260,17 @@ fn decide_matched(spot: &Spot, lage: Option<&Turnierlage>) -> Decision {
force(Some(1));
let demoted = decide_one(spot, lage);
force(before);
return if aggression_rank(demoted.choice) < aggression_rank(station.choice) { demoted } else { station };
return if aggression_rank(demoted.choice) < aggression_rank(station.choice) {
let note = format!(
"STATION_POSTFLOP schmal: mit Stations-Read {}, blind {} -> {}",
super::vermerk::aktion(&station.choice),
super::vermerk::aktion(&demoted.choice),
super::vermerk::aktion(&demoted.choice)
);
super::vermerk::anhaengen(demoted, &[note])
} else {
station
};
}
decide_one(spot, lage)
}
@@ -273,7 +285,13 @@ fn aggression_rank(c: Choice) -> u8 {
}
}
/// One decision in its own vermerk frame: the notes of overriding rules are appended to the reason.
fn decide_one(spot: &Spot, lage: Option<&Turnierlage>) -> Decision {
super::vermerk::beginne();
super::vermerk::abschliessen(decide_one_inner(spot, lage))
}
fn decide_one_inner(spot: &Spot, lage: Option<&Turnierlage>) -> Decision {
// RAKE_LIVE (`rake::live`, off by default): a cash spot prices every pot net of the room's rake;
// a tournament pays none, also a chip-linear one that plays the cash path below
// (the scope is decided on the original situation). Off: no scope, nothing changes.
+14 -1
View File
@@ -37,11 +37,24 @@ fn commit_begrenzt(spot: &Spot, plan: &PreflopPlan, choice: Option<Choice>) -> O
match choice {
Some(Choice::Raise { to }) if plan.action == ChartAction::Raise => {
let jam = all_in(spot).unwrap_or(to);
match raise_commitment(plan.percentile, to, jam, spot.to_call, spot.pot) {
let out = match raise_commitment(plan.percentile, to, jam, spot.to_call, spot.pot) {
RaiseVerdict::Keep => Some(Choice::Raise { to }),
RaiseVerdict::Downgrade => cheapest_continue(spot).or_else(|| give_up(spot)),
RaiseVerdict::Fold => give_up(spot),
};
match out {
Some(Choice::Raise { .. }) => {
if crate::preflop::vorflop_pop::ziel(spot).is_some() {
super::vermerk::notiere(format!("VORFLOP_POP: Groesse nach NL2-Population, raise to {to:.2}"));
}
}
Some(c) => super::vermerk::notiere(format!(
"Commit-Riegel: raise to {to:.2} bindet den Stack -> {}",
super::vermerk::aktion(&c)
)),
None => {}
}
out
}
other => other,
}
+20 -4
View File
@@ -74,6 +74,10 @@ pub struct Mode {
/// `beleg`: S2 only as far as the read shows few raises (`evidence_weight`); an opponent without a
/// counted `raise_to_bet` keeps the incoming share (micro gate 16.11.: nemesis-2@blind −36 unread).
pub evidence: bool,
/// `fluss`: S2 only on the river; flop and turn keep the incoming bluff share. Pruefstand 18.11.:
/// on 10 737 real NL2 flop/turn raises against top pair or better S2 folded 21 % (without it 7 %)
/// while the caller was ahead 61 % of the time (`messung/pruefstand/POSTERIOR.md`).
pub river_only: bool,
}
thread_local! {
@@ -107,7 +111,7 @@ pub fn mode() -> Option<Mode> {
}
fn parse(s: &str) -> Option<Mode> {
let mut m = Mode { fold: false, board_weight: 1.0, fold_only_branch: false, class_rate: false, bluff: false, river_lines_only: false, guard: false, evidence: false };
let mut m = Mode { fold: false, board_weight: 1.0, fold_only_branch: false, class_rate: false, bluff: false, river_lines_only: false, guard: false, evidence: false, river_only: false };
for t in s.split(',').map(str::trim) {
if t == "fold" {
m.fold = true;
@@ -123,6 +127,8 @@ fn parse(s: &str) -> Option<Mode> {
m.guard = true;
} else if t == "beleg" {
m.evidence = true;
} else if t == "fluss" {
m.river_only = true;
} else if let Some(w) = t.strip_prefix("fold:").and_then(|w| w.parse::<f64>().ok()).filter(|w| w.is_finite()) {
m.fold = true;
m.board_weight = w;
@@ -136,6 +142,11 @@ pub fn set_override(mode: Option<Option<Mode>>) {
OVERRIDE.with(|o| o.set(mode));
}
/// The current override (`set_override`), to restore it after a counterfactual (`bluff::bluff_catch_vermerk`).
pub fn current_override() -> Option<Option<Mode>> {
OVERRIDE.with(|o| o.get())
}
/// Is S1 on?
pub fn fold_on() -> bool {
mode().is_some_and(|m| m.fold)
@@ -298,6 +309,9 @@ fn class_fold(f: f64, m_board: f64, m_ref: f64) -> f64 {
///
/// Off: `prior` unchanged.
pub fn bluff(seat: u8, street: Street, ratio: Option<f64>, line: Option<&Line>, prior: f64) -> f64 {
if street != Street::River && mode().is_some_and(|m| m.river_only) {
return prior;
}
let s2 = line_bluff(seat, street, ratio, line, prior);
let Some(m) = mode().filter(|m| m.bluff && (m.guard || m.evidence)) else { return s2 };
if street == Street::Preflop {
@@ -406,6 +420,8 @@ mod tests {
assert_eq!(guard_weight(&p(Some(0.2), Some(0.56))), 1.0);
assert_eq!(parse("bluff,schutz").map(|m| (m.bluff, m.guard)), Some((true, true)));
assert_eq!(parse("bluff,schutz,beleg").map(|m| m.evidence), Some(true));
assert_eq!(parse("bluff,schutz,beleg,fluss").map(|m| (m.evidence, m.river_only)), Some((true, true)));
assert_eq!(parse("bluff,schutz,beleg").map(|m| m.river_only), Some(false));
assert_eq!(evidence_weight(&Profile::default()), 0.0, "no read: the incoming share");
assert_eq!(evidence_weight(&p(Some(0.30), None)), 0.0);
assert!((evidence_weight(&p(Some(0.275), None)) - 0.5).abs() < 1e-9);
@@ -414,9 +430,9 @@ mod tests {
#[test]
fn parses_the_stages() {
assert_eq!(parse("fold"), Some(Mode { fold: true, board_weight: 1.0, fold_only_branch: false, class_rate: false, bluff: false, river_lines_only: false, guard: false, evidence: false }));
assert_eq!(parse("fold:0.5,bluff"), Some(Mode { fold: true, board_weight: 0.5, fold_only_branch: false, class_rate: false, bluff: true, river_lines_only: false, guard: false, evidence: false }));
assert_eq!(parse("fold:0,nurfold"), Some(Mode { fold: true, board_weight: 0.0, fold_only_branch: true, class_rate: false, bluff: false, river_lines_only: false, guard: false, evidence: false }));
assert_eq!(parse("fold"), Some(Mode { fold: true, board_weight: 1.0, fold_only_branch: false, class_rate: false, bluff: false, river_lines_only: false, guard: false, evidence: false, river_only: false }));
assert_eq!(parse("fold:0.5,bluff"), Some(Mode { fold: true, board_weight: 0.5, fold_only_branch: false, class_rate: false, bluff: true, river_lines_only: false, guard: false, evidence: false, river_only: false }));
assert_eq!(parse("fold:0,nurfold"), Some(Mode { fold: true, board_weight: 0.0, fold_only_branch: true, class_rate: false, bluff: false, river_lines_only: false, guard: false, evidence: false, river_only: false }));
assert_eq!(parse("0"), None);
assert_eq!(parse(""), None);
}
+1
View File
@@ -43,6 +43,7 @@ pub mod turn_subgame;
pub mod ueberschuss;
pub mod ueberwert;
pub mod uncertainty;
pub mod vermerk;
/// One lock for every unit test that flips a process-wide solver switch (`set_river_spieler`,
/// `set_turn_ueberall`, `set_flop_spieler`, `set_river3`, `set_turn3`/`set_flop3`, `set_turn_player`):
+49 -6
View File
@@ -254,16 +254,59 @@ fn reraise_rate(spot: &Spot) -> f64 {
.clamp(0.0, 1.0)
}
/// What kind of raise this hand could make here, if any.
fn raise_kind(spot: &Spot, eff: &Effective, read: &HandRead) -> Option<RaiseKind> {
let nie = never_folds(spot);
let bluffable = eff.raise_ok && !nie;
let pair_blocked = match paar_raise() {
/// `PAAR_RAISE`: the value raise of a one-pair hand facing a bet is blocked here.
fn pair_blocked(spot: &Spot, read: &HandRead) -> bool {
match paar_raise() {
Some(PaarRaise::Nie) => one_pair_facing_bet(spot, read),
Some(PaarRaise::Passiv(bar)) => one_pair_facing_bet(spot, read) && all_passive(spot, bar, false),
Some(PaarRaise::Gelesen(bar)) => one_pair_facing_bet(spot, read) && all_passive(spot, bar, true),
_ => false,
};
}
}
/// Vermerke (text only): which switch-driven option gate shaped this decision. `winner` is the chosen
/// option; notes go to `engine::vermerk`.
pub fn vermerke(spot: &Spot, eff: &Effective, read: &HandRead, winner: Option<&Scored>) {
use super::vermerk::notiere;
let raised = matches!(winner.map(|w| w.choice), Some(Choice::Raise { .. }));
if !raised && is_value_raise(eff) && pair_blocked(spot, read) {
notiere("PAAR_RAISE: ein Paar gegen passiv gelesene Gegner -> kein Value-Raise");
}
// The call was taken out of the options (`scored`): say which gate did it.
if winner.is_some_and(|w| w.choice == Choice::Fold) && spot.is_legal(ActionKind::Call) {
let be = break_even(spot.pot, spot.to_call);
let extra = extra_call_margin(spot, read);
let need = be + eff.call_margin + extra;
if eff.share < need {
notiere(format!(
"Call-Schwelle: Equity {:.2} < Break-even {be:.2} + Marge {:.2} -> fold",
eff.share,
eff.call_margin + extra
));
} else if bluff_catch_blocked(spot, read) {
notiere(super::bluff::bluff_catch_vermerk(spot, read));
}
}
if let Some(w) = winner.filter(|_| raised) {
if w.kind == Some(RaiseKind::Value) && river_monster(spot, eff, read) && !(is_value_raise(eff) && !pair_blocked(spot, read)) {
notiere("FLUSS_WERT: River-Monster bekommt die Wert-Wette");
}
if w.kind == Some(RaiseKind::Bluff) && super::cbet_luft::applies(spot).is_some() {
notiere("CBET_LUFT: Luft-C-Bet gegen seltenen Erhoeher");
}
if let (Choice::Raise { to }, Some(kind)) = (w.choice, w.kind) {
if super::ueberwert::groesse(spot, kind).is_some_and(|g| (g - to).abs() < 1e-9) {
notiere("UEBERWERT: River-Value ab Perzentil 0,90 -> 2x Topf");
}
}
}
}
/// What kind of raise this hand could make here, if any.
fn raise_kind(spot: &Spot, eff: &Effective, read: &HandRead) -> Option<RaiseKind> {
let nie = never_folds(spot);
let bluffable = eff.raise_ok && !nie;
let pair_blocked = pair_blocked(spot, read);
if (is_value_raise(eff) && !pair_blocked) || river_monster(spot, eff, read) {
Some(RaiseKind::Value)
} else if thin_value(eff, read.made, spot.street, spot.is_legal(ActionKind::Check)) {
+26
View File
@@ -150,6 +150,21 @@ fn marginal_raise(
(gap < error).then_some((gap, error))
}
/// `ENTHALTUNG=passiv` (off by default = bit-identical): a semibluff/bluff raise whose EV lead over the
/// best passive line is inside its error no longer ABSTAINs (the runner turns an ABSTAIN facing a bet
/// into FOLD, `betrieb/runner.py::nie_verstreichen`), it plays the best passive option the option gates
/// kept (check, call, else fold). Pruefstand 18.11.: Jc7s on JhTd8c, equity 0.58 vs break-even 0.32,
/// call +0.16, folded because a 0.72 semibluff led by +0.00 (`messung/pruefstand/BERICHT.md`).
fn passiv_statt_enthaltung(options: &[Scored]) -> Option<Scored> {
use std::sync::OnceLock;
static AN: OnceLock<bool> = OnceLock::new();
if !*AN.get_or_init(|| std::env::var("ENTHALTUNG").is_ok_and(|v| v.trim() == "passiv")) {
return None;
}
let passiv: Vec<Scored> = options.iter().copied().filter(|o| !matches!(o.choice, Choice::Raise { .. })).collect();
best(&passiv)
}
/// `choose_postflop_with` when nothing is known about the calling range: the whole
/// range calls, so the called branch uses the overall share.
pub fn choose_postflop(
@@ -207,6 +222,15 @@ pub fn choose_postflop_with(
// that on fold equity (semibluff, bluff) are held back by the error.
let held = kind != Some(RaiseKind::Value);
if let Some((gap, error)) = held.then(|| marginal_raise(spot, &eff, estimate, to, raise_ev)).flatten() {
if let Some(p) = passiv_statt_enthaltung(&options) {
super::options::vermerke(spot, &eff, read, Some(&p));
super::vermerk::notiere(format!("ENTHALTUNG: Raise im Fehler -> {}", super::vermerk::aktion(&p.choice)));
return priced(Decision::new(
p.choice,
abstain_confidence(gap, error),
format!("{head}: raise EV lead {gap:+.2} inside its error {error:.2}, EV {} {:+.2}", label(p.choice, p.kind), p.ev),
));
}
return priced(Decision::new(
Choice::Abstain,
abstain_confidence(gap, error),
@@ -229,6 +253,8 @@ pub fn choose_postflop_with(
// The abstain gate above decided WHETHER to raise on the best size; once committed, mix the
// SIZE among EV-tied raises so the line is not a readable pure argmax (EV-neutral, seeded).
let winner = winner.map(|w| mix_size(spot, estimate, &options, w));
// Vermerke (text only): option gates of switches that shaped this winner (`engine::vermerk`).
super::options::vermerke(spot, &eff, read, winner.as_ref());
priced(match winner {
Some(w) => {
let shown = match w.choice {
+107
View File
@@ -0,0 +1,107 @@
//! Vermerke: every rule that overrides the base calculation names itself in the reason (Auftrag 18.11.,
//! Pruefstand). The owner saw "EV call +0.16" on a FOLD (180165100008, KsJs facing a flop raise): the
//! call had been removed by the bluff-catch block after POSTERIOR pushed the raiser's bluff share
//! under 0.05, and nothing said so.
//!
//! A rule calls `notiere("SCHALTER: was -> aktion")` where it changes the action; `decide_one` opens a
//! frame (`beginne`) and appends the frame's notes to the final reason (`abschliessen`) as
//! `"<reason> | note | note"`. Frames stack, so a nested decision (the station two-way pick, a solver
//! asking the core) keeps its own notes. TEXT ONLY: no note changes a choice, a size or a number.
use crate::game::Decision;
use std::cell::RefCell;
thread_local! {
static RAHMEN: RefCell<Vec<Vec<String>>> = const { RefCell::new(Vec::new()) };
}
/// Opens a frame for one decision.
pub fn beginne() {
RAHMEN.with(|r| r.borrow_mut().push(Vec::new()));
}
/// Notes `text` in the innermost open frame (no frame: dropped). The same text twice is kept once.
pub fn notiere(text: impl Into<String>) {
let text = text.into();
RAHMEN.with(|r| {
if let Some(top) = r.borrow_mut().last_mut() {
if !top.contains(&text) {
top.push(text);
}
}
});
}
/// Closes the innermost frame and appends its notes to `decision.reason`.
pub fn abschliessen(decision: Decision) -> Decision {
let notes = RAHMEN.with(|r| r.borrow_mut().pop()).unwrap_or_default();
anhaengen(decision, &notes)
}
/// `reason | n1 | n2`; no notes: unchanged.
pub fn anhaengen(decision: Decision, notes: &[String]) -> Decision {
if notes.is_empty() {
return decision;
}
let reason = format!("{} | {}", decision.reason, notes.join(" | "));
Decision { reason, ..decision }
}
/// A stage that may replace `before` with `after`: when the action changed and the stage did not say
/// so itself (the reason is still `before`'s), note `name: before -> after`.
pub fn stufe(name: &str, before: &Decision, after: Decision) -> Decision {
if after.choice != before.choice && after.reason == before.reason {
notiere(format!("{name}: {} -> {}", aktion(&before.choice), aktion(&after.choice)));
}
after
}
/// A stage that replaced `before` with its own decision and reason (MDF floor, river veto, turn game):
/// when the action changed, keep the base reason in front, `base | stage`, so the base numbers stay
/// visible. Same action, or the stage already carries the base reason: `after` unchanged.
pub fn ersetzt(before: &Decision, after: Decision) -> Decision {
if after.choice == before.choice {
return after;
}
if after.reason == before.reason {
return stufe("Stufe", before, after);
}
if after.reason.starts_with(&before.reason) {
return after;
}
let reason = format!("{} | {}", before.reason, after.reason);
Decision { reason, ..after }
}
/// Lower-case action word for notes.
pub fn aktion(c: &crate::game::Choice) -> String {
c.name().to_lowercase()
}
#[cfg(test)]
mod tests {
use super::*;
use crate::game::Choice;
#[test]
fn notes_are_appended_once_and_frames_nest() {
beginne();
notiere("A: x -> fold");
beginne();
notiere("B");
let inner = abschliessen(Decision::new(Choice::Call, 0.5, "inner"));
assert_eq!(inner.reason, "inner | B");
notiere("A: x -> fold");
let outer = abschliessen(Decision::new(Choice::Fold, 0.5, "outer"));
assert_eq!(outer.reason, "outer | A: x -> fold");
assert_eq!(outer.choice, Choice::Fold);
}
#[test]
fn no_frame_no_note() {
notiere("lost");
beginne();
let d = abschliessen(Decision::new(Choice::Check, 0.5, "r"));
assert_eq!(d.reason, "r");
}
}
+1 -1
View File
@@ -197,7 +197,7 @@ pub fn note_raw_reads(spot: &Spot) {
ROH.with(|r| r.set(mask));
}
fn tighten_for(villain: &Villain) -> bool {
pub fn tighten_for(villain: &Villain) -> bool {
match nur_modus() {
NurModus::Alle => true,
NurModus::Gelesen => villain.profile.is_some(),
+494
View File
@@ -0,0 +1,494 @@
#!/usr/bin/env python3
"""Kipp-Liste je Schalter: welche Handklassen kippt ein Kern-Schalter, und kippt er eine Prämienhand zum Fold?
Das alte Tor sah nur die paar Replay-Hände, die ein Schalter zufällig änderte (VORFLOP_POP vs3bet: 8 Hände, AJo gegen eine
SB-3-Bet 4,6x fiel erst im Owner-Lauf auf). Hier läuft ein festes Raster durch den Kern:
Vorflop alle 169 Starthände je Lage: Open (5 Positionen), gegen Open (15 Paare), gegen 3-Bet (15), gegen 4-Bet (15),
gegen Limp (4), gegen Open-Jam (2) - 100 bb, 6-max, NL2.
Postflop 16 Flops verschiedener Textur, je Flop/Turn/River; Linien: gegen Einsatz 1/3, 3/4, 1,5 Topf (BB gegen BTN),
angecheckt (BTN), eigener Einsatz erhöht (Flop/Turn), 3-Bet-Topf gegen Einsatz; je Handklasse
(lesen/poolruf_eichung.KLASSEN) bis zu 3 Kombos.
Gegner `ungelesen` (kein Profil) und `gelesen` (Profil wie im Owner-Fall 180165100008: ~25 Hände, Zähl-Read
raiseToBet n=1 k=0, der Live-Zustand der meisten Gegner).
Ein Arm ist der Live-Stand (`betrieb/kern_schalter.txt`) mit Änderungen: `-K` nimmt K heraus, `K=V` setzt K.
Ohne Angabe läuft für JEDEN Live-Schalter der Arm `-K` (was bewirkt dieser Schalter heute?).
Gekippt = andere Aktionsart (Fold/Check/Call/Raise); nur eine andere Raise-Größe zählt als `groesse`.
HARTER BEFUND: eine Prämienhand, die MIT dem Schalter foldet und ohne ihn weiterspielt.
Prämie vorflop: AK, AQ, AJ, KQ (suited und offsuit), Paare ab TT. Prämie postflop: Top-Paar oder besser.
Bei `-K` (Live-Schalter) ist "mit" = Live; bei `K=V` (Kandidat) ist "mit" = der Arm.
python3 werkzeuge/kippliste.py --aus <ordner> [--arm "-POSTERIOR"] [--arm "VORFLOP_POP=dreibet,iso,vs3bet"]
[--kern <rechner.exe>] [--prozesse 6] [--nur vorflop|postflop] [--schalter <datei>]
Ausgabe: <ordner>/kipp-<arm>.json (alle Kipps), <ordner>/KIPPLISTE.md (Übersicht, harte Befunde zuerst).
Der Kern läuft als Kopie `pokerbench-pruefstand-kipp.exe` in Priorität Idle.
"""
import argparse
import collections
import hashlib
import concurrent.futures
import json
import os
import random
import shutil
import subprocess
import sys
_HIER = os.path.dirname(os.path.abspath(__file__))
BAUM = os.path.dirname(_HIER)
sys.path.insert(0, os.path.join(BAUM, "lesen"))
import poolruf_eichung as pe # noqa: E402
BB = 0.02
STACK = 2.00
RAENGE = "AKQJT98765432"
FARBEN = "shdc"
RANG = {"A": "ACE", "K": "KING", "Q": "QUEEN", "J": "JACK", "T": "TEN", "9": "NINE", "8": "EIGHT",
"7": "SEVEN", "6": "SIX", "5": "FIVE", "4": "FOUR", "3": "THREE", "2": "TWO"}
FARBE = {"s": "SPADES", "h": "HEARTS", "d": "DIAMONDS", "c": "CLUBS"}
POS = {1: "SB", 2: "BB", 3: "UTG", 4: "HJ", 5: "CO", 6: "BTN"}
# Live-Schalter, die nur Pfade für andere sind oder nicht im Kern wirken.
NICHT_EINZELN = {"TISCHWAHL", "GRUNDSTRATEGIE"}
PRAEMIE_VORFLOP = {"AKs", "AKo", "AQs", "AQo", "AJs", "AJo", "KQs", "KQo", "AA", "KK", "QQ", "JJ", "TT"}
AB_KLASSE_PRAEMIE = 3 # top_paar
GELESEN = {"vpip": 0.33, "pfr": 0.22, "foldToBet": 0.6, "cbet": 0.7, "foldToCbet": 0.31, "threeBet": 0.09,
"foldToThreeBet": 0.48, "steal": 0.44, "checkRaise": 0.04, "wtsd": 0.32, "wsd": 0.55, "hands": 25,
"aggression": 0.33, "aggressionActions": 3,
"reads": {"raiseToBet": {"n": 1, "k": 0}, "flopBetOpen": {"n": 1, "k": 0}}}
FLOPS = ["Ks7d2c", "Ah8c3d", "Qs9s4h", "JhTd8c", "7c6c5d", "9h9d3s", "Kd Qd 2d", "As Kd 5c", "8s5h2d", "Tc9c2h",
"6h6c6d", "Ad Jh Tc", "4s3s2h", "QhJc4c", "Kh Kc 8d", "Js7s2s"]
def karte(c):
return {"rank": RANG[c[0]], "suit": FARBE[c[1]]}
def flop_karten(f):
f = f.replace(" ", "")
return [f[i:i + 2] for i in range(0, 6, 2)]
# ---------------------------------------------------------------------------------------------
# Vorflop
# ---------------------------------------------------------------------------------------------
def klassen169():
"""[(name, karte1, karte2)] in fester Reihenfolge; suited in Herz, offsuit Herz/Pik, Paare Herz/Karo."""
out = []
for i, a in enumerate(RAENGE):
for j, b in enumerate(RAENGE):
if i == j:
out.append((a + a, a + "h", a + "d"))
elif i < j:
out.append((a + b + "s", a + "h", b + "h"))
out.append((a + b + "o", a + "h", b + "s"))
return out
def _blinds():
return [{"street": "PREFLOP", "seat": 1, "action": "POST_SB", "amount": 0.01},
{"street": "PREFLOP", "seat": 2, "action": "POST_BB", "amount": 0.02}]
def _reihe(von, bis):
"""Sitze in Vorflop-Reihenfolge (3,4,5,6,1,2) strikt zwischen von und bis."""
o = [3, 4, 5, 6, 1, 2]
i, j = o.index(von), o.index(bis)
return o[i + 1:j] if i < j else []
def _vor(seat):
o = [3, 4, 5, 6, 1, 2]
return o[:o.index(seat)]
def vorflop_lagen():
"""[(lage, hero, history, beitrag je Sitz, letzter Einsatz, Spieler im Topf)]."""
lagen = []
o = [3, 4, 5, 6, 1, 2]
# Open
for h in (3, 4, 5, 6, 1):
hist = _blinds() + [{"street": "PREFLOP", "seat": s, "action": "FOLD"} for s in _vor(h)]
lagen.append(("open %s" % POS[h], h, hist, {1: 0.01, 2: 0.02}, 0.02, {h, 1, 2} | set(o[o.index(h):])))
# gegen Open / 3-Bet / 4-Bet
for oi, op in enumerate(o[:-1]):
for he in o[oi + 1:]:
open_to = 0.06 if op == 1 else 0.05
hist = _blinds() + [{"street": "PREFLOP", "seat": s, "action": "FOLD"} for s in _vor(op)]
hist.append({"street": "PREFLOP", "seat": op, "action": "RAISE", "amount": open_to})
zw = [{"street": "PREFLOP", "seat": s, "action": "FOLD"} for s in _reihe(op, he)]
b = {1: 0.01, 2: 0.02, op: open_to}
lagen.append(("vs open %s->%s" % (POS[op], POS[he]), he, hist + zw, dict(b), open_to, {op, he}))
# 3-Bet: he erhöht, op (Held) entscheidet
drei = 0.23 if he in (1, 2) else 0.15
nach = [{"street": "PREFLOP", "seat": s, "action": "FOLD"} for s in o[o.index(he) + 1:] if s != op]
h3 = hist + zw + [{"street": "PREFLOP", "seat": he, "action": "RAISE", "amount": drei}] + nach
b3 = dict(b)
b3[he] = drei
lagen.append(("vs 3bet %s<-%s" % (POS[op], POS[he]), op, h3, b3, drei, {op, he}))
# 4-Bet: op erhöht erneut, he (Held) entscheidet
vier = round(drei * 2.3, 2)
h4 = h3 + [{"street": "PREFLOP", "seat": op, "action": "RAISE", "amount": vier}]
b4 = dict(b3)
b4[op] = vier
lagen.append(("vs 4bet %s<-%s" % (POS[he], POS[op]), he, h4, b4, vier, {op, he}))
# gegen Limp
for he in (5, 6, 1, 2):
hist = _blinds() + [{"street": "PREFLOP", "seat": 3, "action": "CALL", "amount": 0.02}]
hist += [{"street": "PREFLOP", "seat": s, "action": "FOLD"} for s in _reihe(3, he)]
lagen.append(("vs limp UTG->%s" % POS[he], he, hist, {1: 0.01, 2: 0.02, 3: 0.02}, 0.02, {3, he, 1, 2}))
# gegen Open-Jam
for he in (6, 2):
hist = _blinds() + [{"street": "PREFLOP", "seat": s, "action": "FOLD"} for s in (3, 4)]
hist.append({"street": "PREFLOP", "seat": 5, "action": "ALL_IN", "amount": STACK})
hist += [{"street": "PREFLOP", "seat": s, "action": "FOLD"} for s in _reihe(5, he)]
lagen.append(("vs jam CO->%s" % POS[he], he, hist, {1: 0.01, 2: 0.02, 5: STACK}, STACK, {5, he}))
return lagen
def vorflop_spots(profil):
out = []
for lage, he, hist, beitrag, hoch, drin in vorflop_lagen():
gefoldet = {r["seat"] for r in hist if r["action"] == "FOLD"}
tc = round(hoch - beitrag.get(he, 0.0), 4)
pot = round(sum(beitrag.values()), 4)
mein = beitrag.get(he, 0.0)
for name, c1, c2 in klassen169():
vil = []
for s in range(1, 7):
if s == he:
continue
v = {"seat": s, "stack": round(STACK - beitrag.get(s, 0.0), 4), "folded": s in gefoldet}
if profil and not v["folded"]:
v["profile"] = json.loads(json.dumps(GELESEN))
vil.append(v)
allin = hoch >= STACK - 1e-9
legal = (["FOLD"] if tc > 0 else []) + (["CALL"] if tc > 0 else ["CHECK"]) + ([] if allin else ["RAISE"])
req = {"variant": "NLHE", "bigBlind": BB, "seats": 6, "heroSeat": he, "buttonSeat": 6,
"heroCards": [karte(c1), karte(c2)], "street": "PREFLOP", "pot": pot, "toCall": min(tc, STACK - mein),
"heroStack": round(STACK - mein, 4), "legalActions": legal, "villains": vil, "history": hist,
"seed": int(hashlib.blake2b((lage + name).encode(), digest_size=4).hexdigest(), 16)}
if not allin:
req["minRaiseTo"] = round(min(hoch + max(hoch - 0.02, 0.02) if hoch > 0.02 else 0.04, STACK), 4)
req["maxRaiseTo"] = STACK
out.append({"id": "pre|%s|%s|%s" % (lage, name, "g" if profil else "u"), "art": "vorflop", "lage": lage,
"hand": name, "praemie": name in PRAEMIE_VORFLOP, "gegner": "gelesen" if profil else "ungelesen",
"req": req})
return out
# ---------------------------------------------------------------------------------------------
# Postflop
# ---------------------------------------------------------------------------------------------
def _deck():
return [r + f for r in RAENGE for f in FARBEN]
def _laufkarten(flop, rng):
rest = [c for c in _deck() if c not in flop]
rng.shuffle(rest)
return rest[0], rest[1]
def _haende(brett, rng, je=3):
"""Bis zu `je` Kombos je Handklasse auf `brett` (seeded)."""
rest = [c for c in _deck() if c not in brett]
alle = [(a, b) for i, a in enumerate(rest) for b in rest[i + 1:]]
rng.shuffle(alle)
je_kl = collections.defaultdict(list)
for a, b in alle:
k = pe.klasse([a, b], brett)
if len(je_kl[k]) < je:
je_kl[k].append((a, b))
return [(k, h) for k in sorted(je_kl) for h in je_kl[k]]
def _post_req(hero, villain, hist, brett, strasse, pot, tc, hstack, vstack, legal, min_to, seed, profil):
vil = []
for s in range(1, 7):
if s == hero:
continue
v = {"seat": s, "stack": round(vstack if s == villain else STACK, 4), "folded": s != villain}
if profil and s == villain:
v["profile"] = json.loads(json.dumps(GELESEN))
vil.append(v)
board = {"FLOP": [karte(c) for c in brett[:3]]}
if strasse >= 2:
board["TURN"] = [karte(brett[3])]
if strasse >= 3:
board["RIVER"] = [karte(brett[4])]
req = {"variant": "NLHE", "bigBlind": BB, "seats": 6, "heroSeat": hero, "buttonSeat": 6, "heroCards": None,
"board": board, "street": ("FLOP", "TURN", "RIVER")[strasse - 1], "pot": round(pot, 4),
"toCall": round(tc, 4), "heroStack": round(hstack, 4), "legalActions": legal, "villains": vil,
"history": hist, "seed": seed}
if "RAISE" in legal:
req["minRaiseTo"] = round(min(min_to, hstack), 4) # kurzer Stack: All-in ist die einzige Erhöhung
req["maxRaiseTo"] = round(hstack, 4)
return req
def _preflop_srp(op=6, de=2, to=0.05):
hist = _blinds() + [{"street": "PREFLOP", "seat": s, "action": "FOLD"} for s in (3, 4, 5)]
hist.append({"street": "PREFLOP", "seat": op, "action": "RAISE", "amount": to})
hist.append({"street": "PREFLOP", "seat": 1, "action": "FOLD"})
hist.append({"street": "PREFLOP", "seat": de, "action": "CALL", "amount": to})
return hist, 2 * to + 0.01
def _preflop_3bet():
hist = _blinds() + [{"street": "PREFLOP", "seat": s, "action": "FOLD"} for s in (3, 4, 5)]
hist += [{"street": "PREFLOP", "seat": 6, "action": "RAISE", "amount": 0.05},
{"street": "PREFLOP", "seat": 1, "action": "RAISE", "amount": 0.23},
{"street": "PREFLOP", "seat": 2, "action": "FOLD"},
{"street": "PREFLOP", "seat": 6, "action": "CALL", "amount": 0.23}]
return hist, 0.46 + 0.02
STR = {1: "FLOP", 2: "TURN", 3: "RIVER"}
def postflop_linien(brett):
"""[(linie, strasse, hero, villain, history, pot, toCall, hstack, vstack, legal, minRaiseTo)].
Frühere Straßen: BB check, BTN setzt 1/2 Topf, BB callt (SRP) bzw. SB setzt 1/2, BTN callt (3-Bet-Topf)."""
out = []
for strasse in (1, 2, 3):
# SRP BTN (6) gegen BB (2)
hist, pot = _preflop_srp()
drin = 0.05
for s in range(1, strasse):
e = round(pot / 2, 4)
hist = hist + [{"street": STR[s], "seat": 2, "action": "CHECK"},
{"street": STR[s], "seat": 6, "action": "BET", "amount": e},
{"street": STR[s], "seat": 2, "action": "CALL", "amount": e}]
pot += 2 * e
drin += e
st = STACK - drin
# BB gegen Einsatz
for f in (0.33, 0.75, 1.5):
e = round(min(pot * f, st), 4)
h = hist + [{"street": STR[strasse], "seat": 2, "action": "CHECK"},
{"street": STR[strasse], "seat": 6, "action": "BET", "amount": e}]
legal = ["FOLD", "CALL"] + (["RAISE"] if e < st else [])
out.append(("srp BB vs bet %.2f" % f, strasse, 2, 6, h, pot + e, e, st, st - e, legal, 2 * e))
# BTN angecheckt
h = hist + [{"street": STR[strasse], "seat": 2, "action": "CHECK"}]
out.append(("srp BTN checked to", strasse, 6, 2, h, pot, 0.0, st, st, ["CHECK", "RAISE"], BB))
# BTN setzt 1/2, BB erhöht auf 3x
if strasse <= 2:
e = round(pot / 2, 4)
r = round(3 * e, 4)
h = hist + [{"street": STR[strasse], "seat": 2, "action": "CHECK"},
{"street": STR[strasse], "seat": 6, "action": "BET", "amount": e},
{"street": STR[strasse], "seat": 2, "action": "RAISE", "amount": r}]
out.append(("srp BTN bet, BB raise 3x", strasse, 6, 2, h, pot + e + r, r - e, st - e, st - r,
["FOLD", "CALL", "RAISE"], r + (r - e)))
# 3-Bet-Topf: SB (1) gegen BTN (6), Held BTN gegen Einsatz 1/2
hist3, pot3 = _preflop_3bet()
drin3 = 0.23
for s in range(1, strasse):
e = round(pot3 / 2, 4)
hist3 = hist3 + [{"street": STR[s], "seat": 1, "action": "BET", "amount": e},
{"street": STR[s], "seat": 6, "action": "CALL", "amount": e}]
pot3 += 2 * e
drin3 += e
st3 = STACK - drin3
e = round(min(pot3 * 0.5, st3), 4)
h = hist3 + [{"street": STR[strasse], "seat": 1, "action": "BET", "amount": e}]
legal = ["FOLD", "CALL"] + (["RAISE"] if e < st3 else [])
out.append(("3bp BTN vs bet 0.50", strasse, 6, 1, h, pot3 + e, e, st3, st3 - e, legal, 2 * e))
return out
def postflop_spots(profil, je=3):
out = []
for fi, f in enumerate(FLOPS):
rng = random.Random(1000 + fi)
flop = flop_karten(f)
t, r = _laufkarten(flop, rng)
brett5 = flop + [t, r]
for linie, strasse, hero, vil, hist, pot, tc, hst, vst, legal, min_to in postflop_linien(brett5):
brett = brett5[:(0, 3, 4, 5)[strasse]]
for k, (a, b) in _haende(brett, random.Random(int(hashlib.blake2b(("%d|%s|%d" % (fi, linie, strasse)).encode(), digest_size=2).hexdigest(), 16)), je):
seed = int(hashlib.blake2b(("%s|%s|%d|%s%s" % (f, linie, strasse, a, b)).encode(), digest_size=4).hexdigest(), 16)
req = _post_req(hero, vil, hist, brett5, strasse, pot, tc, hst, vst, legal, min_to, seed, profil)
req["heroCards"] = [karte(a), karte(b)]
out.append({"id": "post|%s|%s|%s|%s%s|%s" % (f.replace(" ", ""), STR[strasse], linie, a, b, "g" if profil else "u"),
"art": "postflop", "lage": "%s %s" % (STR[strasse], linie), "brett": "".join(brett),
"hand": a + b, "klasse": pe.KLASSEN[k], "praemie": k >= AB_KLASSE_PRAEMIE,
"gegner": "gelesen" if profil else "ungelesen", "req": req})
return out
# ---------------------------------------------------------------------------------------------
# Kern
# ---------------------------------------------------------------------------------------------
def lies_schalter(pfad):
s = {}
for z in open(pfad, encoding="utf-8"):
z = z.strip()
if not z or z.startswith("#") or "=" not in z:
continue
k, v = z.split("=", 1)
s[k.strip()] = v.strip()
return s
def arm_env(live, arm):
"""`-K` nimmt K heraus (mit -GEGNER_LINIEN auch die Linien), `K=V` setzt K, mehrere mit `;`."""
env = dict(live)
for teil in (arm or "").split(";"):
teil = teil.strip()
if not teil:
continue
if teil.startswith("-"):
env.pop(teil[1:], None)
elif "=" in teil:
k, v = teil.split("=", 1)
env[k] = v
return env
def kern_lauf(kern, spots, env_kern, prozesse=6, block=800):
"""Antworten (Liste von dict) je Spot; Kern-Kopien in Priorität Idle, `prozesse` gleichzeitig."""
env = {k: v for k, v in os.environ.items() if k not in env_kern}
env.update(env_kern)
stuecke = [spots[i:i + block] for i in range(0, len(spots), block)]
flags = 0x40 if sys.platform == "win32" else 0
def eins(stueck):
data = "".join(json.dumps(s["req"], ensure_ascii=True) + "\n" for s in stueck).encode("ascii")
pr = subprocess.Popen([kern], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL,
env=env, creationflags=flags)
out, _ = pr.communicate(data)
return [json.loads(z) if z.strip() else {} for z in out.decode("utf-8").split("\n")[:len(stueck)]]
with concurrent.futures.ThreadPoolExecutor(max_workers=prozesse) as ex:
ergebnisse = list(ex.map(eins, stuecke))
return [a for e in ergebnisse for a in e]
def art(antwort, req=None):
"""Was der Läufer spielt: eine Enthaltung wird CHECK, wenn nichts zu zahlen ist, sonst FOLD
(betrieb/runner.py::nie_verstreichen)."""
a = str(antwort.get("action") or "").upper()
if a in ("ABSTAIN", "") and req is not None and float(req.get("toCall") or 0) <= 0:
return "CHECK"
return "FOLD" if a in ("FOLD", "ABSTAIN", "") else a
def ist_fold(a):
return a == "FOLD"
def vergleich(spots, basis, arm, mit_ist_arm):
"""Kipps zwischen Basis (Live) und Arm. `mit_ist_arm`: der Schalter ist im Arm an (Kandidat), sonst in der Basis."""
kipps = []
for s, a, b in zip(spots, basis, arm):
x, y = art(a, s["req"]), art(b, s["req"])
if x == y:
if x == "RAISE" and abs(float(a.get("size") or 0) - float(b.get("size") or 0)) > 1e-6:
kipps.append({"id": s["id"], "typ": "groesse", "live": x, "arm": y})
continue
mit, ohne = (b, a) if mit_ist_arm else (a, b)
hart = s["praemie"] and ist_fold(art(mit, s["req"])) and not ist_fold(art(ohne, s["req"]))
kipps.append({"id": s["id"], "typ": "art", "live": x, "arm": y, "hart": hart, "art_spot": s["art"],
"lage": s["lage"], "hand": s["hand"], "klasse": s.get("klasse"), "gegner": s["gegner"],
"praemie": s["praemie"], "grund_live": a.get("reason", ""), "grund_arm": b.get("reason", "")})
return kipps
def zusammenfassung(arm, kipps, n_spots):
k = [x for x in kipps if x["typ"] == "art"]
hart = [x for x in k if x.get("hart")]
richt = collections.Counter("%s->%s" % (x["live"], x["arm"]) for x in k)
kl = collections.Counter(x["klasse"] or ("praemie" if x["praemie"] else "rest") for x in k)
lagen = collections.Counter(x["lage"].split(" ")[0] + " " + " ".join(x["lage"].split(" ")[1:3]) for x in k)
return {"arm": arm, "spots": n_spots, "gekippt": len(k), "groesse": len(kipps) - len(k), "hart": len(hart),
"richtung": dict(richt.most_common()), "klassen": dict(kl.most_common()), "lagen": dict(lagen.most_common(12)),
"harte_beispiele": hart[:40]}
def bericht(aus, zus):
z = ["# Kipp-Liste je Schalter", "",
"Erzeugt von `werkzeuge/kippliste.py`. Gekippt = andere Aktionsart als der Live-Stand.",
"Hart = eine Prämienhand (vorflop AK/AQ/AJ/KQ, TT+; postflop Top-Paar+) foldet MIT dem Schalter und spielt ohne ihn weiter.",
"", "| Arm | Spots | gekippt | nur Größe | hart | häufigste Richtungen |", "|---|---|---|---|---|---|"]
for s in sorted(zus, key=lambda s: (-s["hart"], -s["gekippt"])):
r = ", ".join("%s %d" % (k, v) for k, v in list(s["richtung"].items())[:3])
z.append("| `%s` | %d | %d | %d | **%d** | %s |" % (s["arm"], s["spots"], s["gekippt"], s["groesse"], s["hart"], r))
z.append("")
for s in sorted(zus, key=lambda s: -s["hart"]):
if not s["hart"]:
continue
z += ["## Harte Befunde: `%s`" % s["arm"], ""]
for x in s["harte_beispiele"][:15]:
z.append("- %s, %s %s (%s): live %s, Arm %s" % (x["lage"], x["hand"], x.get("klasse") or "", x["gegner"], x["live"], x["arm"]))
z.append(" - live: %s" % x["grund_live"][:220])
z.append(" - Arm: %s" % x["grund_arm"][:220])
z.append("")
open(os.path.join(aus, "KIPPLISTE.md"), "w", encoding="utf-8", newline="\n").write("\n".join(z) + "\n")
def kern_kopie(quelle, aus):
ziel = os.path.join(aus, "pokerbench-pruefstand-kipp.exe")
if not os.path.exists(ziel) or os.path.getmtime(ziel) < os.path.getmtime(quelle):
shutil.copy2(quelle, ziel)
return ziel
def spots_bauen(nur=None):
s = []
if nur in (None, "vorflop"):
s += vorflop_spots(False) + vorflop_spots(True)
if nur in (None, "postflop"):
s += postflop_spots(False) + postflop_spots(True)
return s
def main():
ap = argparse.ArgumentParser()
ap.add_argument("--aus", required=True)
ap.add_argument("--arm", action="append", default=[])
ap.add_argument("--kern", default=os.path.join(BAUM, "target", "release", "rechner.exe"))
ap.add_argument("--schalter", default=os.path.join(BAUM, "betrieb", "kern_schalter.txt"))
ap.add_argument("--prozesse", type=int, default=6)
ap.add_argument("--nur", choices=("vorflop", "postflop"))
a = ap.parse_args()
os.makedirs(a.aus, exist_ok=True)
live = lies_schalter(a.schalter)
live.pop("TISCHWAHL", None)
arme = a.arm or ["-" + k for k in live if k not in NICHT_EINZELN]
kern = kern_kopie(a.kern, a.aus)
spots = spots_bauen(a.nur)
print("%d Spots, %d Arme" % (len(spots), len(arme)), flush=True)
basis_pfad = os.path.join(a.aus, "basis.jsonl")
basis = kern_lauf(kern, spots, live, a.prozesse)
with open(basis_pfad, "w", encoding="utf-8", newline="\n") as f:
for s, b in zip(spots, basis):
f.write(json.dumps({"id": s["id"], "a": b.get("action"), "size": b.get("size"), "reason": b.get("reason")}) + "\n")
alle = []
alt = os.path.join(a.aus, "zusammenfassung.json")
if os.path.exists(alt):
alle = [z for z in json.load(open(alt, encoding="utf-8")) if z["arm"] not in arme]
for arm in arme:
env = arm_env(live, arm)
antw = kern_lauf(kern, spots, env, a.prozesse)
mit_ist_arm = not arm.strip().startswith("-")
kipps = vergleich(spots, basis, antw, mit_ist_arm)
name = arm.replace("=", "_").replace(",", "+").replace(":", "").replace("\\", "").replace("/", "")[:60]
json.dump(kipps, open(os.path.join(a.aus, "kipp-%s.json" % name), "w", encoding="utf-8"), ensure_ascii=False)
z = zusammenfassung(arm, kipps, len(spots))
alle.append(z)
print("%-40s gekippt %5d hart %3d" % (arm, z["gekippt"], z["hart"]), flush=True)
json.dump(alle, open(alt, "w", encoding="utf-8"), ensure_ascii=False, indent=1)
bericht(a.aus, alle)
return 0
if __name__ == "__main__":
sys.exit(main())
+14 -1
View File
@@ -201,10 +201,23 @@ def anhaengen(pfad, neue):
# ---------------------------------------------------------------- Kandidat
def _teile(text):
"""Trennt an ';' und an ',' - ein Komma trennt aber nur, wenn danach ein neues 'K=' folgt; sonst gehört es zum
Wert ('POSTERIOR=bluff,schutz,beleg', 'UEBERWERT=0.9,2' bleiben ganz; bis 18.11. wurden sie hier abgeschnitten)."""
out = []
for stueck in (text or "").split(";"):
for t in stueck.split(","):
if "=" in t or not out:
out.append(t)
else:
out[-1] += "," + t
return out
def arm_lesen(text):
"""'K=V;K=V' -> {K: V}; 'K=' oder 'K=aus' -> {K: None} (Schalter heraus)."""
aus = {}
for teil in (text or "").replace(",", ";").split(";"):
for teil in _teile(text):
if "=" not in teil:
continue
k, v = (t.strip() for t in teil.split("=", 1))
+411
View File
@@ -0,0 +1,411 @@
#!/usr/bin/env python3
"""Tor auf echten NL2-Spots: EIN Urteil je Arm, Pflicht vor jedem Live-Schalten (Auftrag Prüfstand 18.11.).
Ein Arm ist der Live-Stand (`betrieb/kern_schalter.txt`) mit Änderungen, z. B. "POSTERIOR=bluff,schutz,beleg,fluss"
oder "-POSTERIOR" (Schalter heraus) oder mehrere mit ';'. Geprüft wird, Kern-Kopien in Priorität Idle:
1 EV echt hhDealer CoinPoker NL2 (messung/grosse_calls: Caller-Sicht, Muck-IPW, Spieler-Holdout) - Dev und
Holdout je eine feste Stichprobe; Delta gegen Live in bb mit 95 %-Bootstrap über die Setzer.
Zusätzlich jede `--spots`-Datei im selben Format (z. B. die POSTERIOR-Spots dieses Prüfstands).
2 Pflichtfälle werkzeuge/pflichtfaelle.py (harte Verlierer = Rückschritt gegen Live).
3 Eigen-Replay alle eigenen Kern-Anfragen aus den Schatten-Logs des Live-Baums: Entscheidungen anders, davon
Prämienhände zum Fold (vorflop AK/AQ/AJ/KQ, TT+; postflop Top-Paar+), Pflichtregel der Familie A
(keine Klasse >= Zwei Paar foldet gegen < 55 % Topf).
4 Kipp-Liste werkzeuge/kippliste.py auf dem Raster (169 Starthände je Lage, Postflop je Handklasse).
5 LBR gepaartes S1-LBR (engine_lbr, dieselben Hände) auf `--lbr N` Händen je Arm; 0 = nur Status aus
`--lbr-datei` (Ergebnisdatei je Arm, `i wert` je Zeile).
Urteil:
DURCHGEFALLEN EV Dev oder Holdout signifikant negativ; Pflichtfall-Rückschritt; harte Kipps (Prämie zum Fold);
Eigen-Replay bricht die Pflichtregel; LBR signifikant schlechter.
OFFEN kein Verlierer, aber kein Nachweis (EV-Intervall schließt 0 ein und kein Teil zeigt Wirkung)
oder ein Teil fehlt.
BESTANDEN sonst.
python3 werkzeuge/tor_echt.py --arm "POSTERIOR=bluff,schutz,beleg,fluss" --aus messung/pruefstand/tor/<name>
[--kern target/release/rechner.exe] [--live-wurzel <Live-Worktree>] [--daten C:/Users/marcm/pokerfreak-grossecalls]
[--spots extra.jsonl ...] [--stichprobe 5] [--prozesse 6] [--lbr 40] [--ohne kipp,lbr,...]
Rohdaten mit Namen liegen nie im Repo; ins Repo geht nur TOR.md/tor.json (Zähler, Hand-IDs, Karten).
"""
import argparse
import collections
import json
import os
import subprocess
import sys
import numpy as np
_HIER = os.path.dirname(os.path.abspath(__file__))
BAUM = os.path.dirname(_HIER)
for _p in (_HIER, os.path.join(BAUM, "lesen"), os.path.join(BAUM, "messung", "grosse_calls"),
os.path.join(BAUM, "messung", "familie_a")):
sys.path.insert(0, _p)
import kippliste as KL # noqa: E402
LIVE_WURZEL = r"D:\Projects\pokerfreak\.claude\worktrees\engine-lecks-angreifen-de7b88"
DATEN = r"C:\Users\marcm\pokerfreak-grossecalls"
STARK = ("TwoPair", "Trips", "Set", "Straight", "Flush", "FullHouse", "Quads", "StraightFlush")
PRAEMIE_POST = ("top_paar", "overpair", "zwei_paar", "drilling", "monster")
def arm_aenderung(arm):
"""'K=V;-K' -> {K: V, K2: None} (Komma bleibt im Wert)."""
import livefaelle
out = {}
for teil in (arm or "").split(";"):
teil = teil.strip()
if teil.startswith("-"):
out[teil[1:]] = None
elif teil:
out.update(livefaelle.arm_lesen(teil))
return out
def env_mit(live, aend):
env = dict(live)
for k, v in aend.items():
if v is None:
env.pop(k, None)
else:
env[k] = v
return env
def boot(mat, n=1000, seed=7):
mat = np.asarray(mat, dtype=float)
if len(mat) == 0:
return 0.0, 0.0, 0.0
rng = np.random.default_rng(seed)
idx = rng.integers(0, len(mat), size=(n, len(mat)))
b = mat[idx].sum(1)
return float(mat.sum()), float(np.percentile(b, 2.5)), float(np.percentile(b, 97.5))
# --- 1 EV auf echten Spots ----------------------------------------------------------------------
def spots_laden(pfad, jede=1, maximal=None):
out = []
for i, z in enumerate(open(pfad, encoding="utf-8")):
if i % jede:
continue
out.append(json.loads(z))
if maximal and len(out) >= maximal:
break
return out
def ev_teil(kern, spots, env_live, env_arm, prozesse):
import population as P
a = KL.kern_lauf(kern, spots, env_live, prozesse)
b = KL.kern_lauf(kern, spots, env_arm, prozesse)
je = collections.defaultdict(lambda: collections.defaultdict(float))
anders = collections.Counter()
for sp, x, y in zip(spots, a, b):
d = sp["w"] * (P.ev_aktion(sp, y.get("action"), y.get("size")) - P.ev_aktion(sp, x.get("action"), x.get("size")))
st = ("flop", "turn", "river")[sp["strasse"] - 1]
for f in ("alle", st):
je[f][sp["pid_o"]] += d
if str(x.get("action")).upper() != str(y.get("action")).upper():
anders["%s %s->%s" % (st, x.get("action"), y.get("action"))] += 1
erg = {"spots": len(spots), "anders": dict(anders.most_common()), "delta": {}}
for f, m in je.items():
s, lo, hi = boot(list(m.values()))
erg["delta"][f] = [round(s, 1), round(lo, 1), round(hi, 1), len(m)]
return erg
# --- 2 Pflichtfälle -------------------------------------------------------------------------------
def pflicht(kern, arm_text, schalter):
import livefaelle
aend = arm_aenderung(arm_text)
text = ";".join("%s=%s" % (k, "aus" if v is None else v) for k, v in aend.items())
r = subprocess.run([sys.executable, "-I", "-X", "utf8", os.path.join(_HIER, "pflichtfaelle.py"), "--arm", text,
"--kern", kern, "--schalter", schalter, "--json"], capture_output=True, text=True,
encoding="utf-8", creationflags=0x40 if sys.platform == "win32" else 0)
try:
j = json.loads(r.stdout)
except ValueError:
return {"fehler": (r.stderr or r.stdout)[-600:]}
del livefaelle
return {"bestanden": j["bestanden"], "verlierer": j["verlierer"], "n": j["n"], "live_soll": j["live_soll"],
"kandidat_soll": j["kandidat_soll"], "ziele_behoben": j["ziele_behoben"], "ziele": j["ziele"],
"verlierer_faelle": [{"hand": z["hand"], "street": z["street"], "live": z["live"], "kandidat": z["kandidat"],
"grund": (z.get("grund_kandidat") or "")[:200]} for z in j["zeilen"] if z["verlierer"]]}
# --- 3 Eigen-Replay -------------------------------------------------------------------------------
def eigene_anfragen(wurzel):
import roentgen
out, gesehen = [], set()
for e in roentgen.daten(wurzel)["schatten"]:
a = roentgen._als_dict(e.get("anfrage"))
if not isinstance(a, dict) or not a.get("legalActions") or not a.get("heroCards"):
continue
k = json.dumps(a, sort_keys=True)
if k in gesehen:
continue
gesehen.add(k)
out.append({"req": a, "zug": e.get("zug") or e.get("kurz") or ""})
return out
def _karten(req):
r = {"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"}
f = {"SPADES": "s", "HEARTS": "h", "DIAMONDS": "d", "CLUBS": "c"}
hc = [r[c["rank"]] + f[c["suit"]] for c in req.get("heroCards") or []]
b = req.get("board") or {}
if isinstance(b, dict):
brett = [r[c["rank"]] + f[c["suit"]] for s in ("FLOP", "TURN", "RIVER") for c in b.get(s, [])]
else:
brett = [r[c["rank"]] + f[c["suit"]] for c in b]
return hc, brett
def praemie(req):
import poolruf_eichung as pe
hc, brett = _karten(req)
if len(hc) != 2:
return False, ""
if not brett:
a, b = sorted(hc, key=lambda c: "AKQJT98765432".index(c[0]))
name = a[0] + b[0] + ("" if a[0] == b[0] else ("s" if a[1] == b[1] else "o"))
return name in KL.PRAEMIE_VORFLOP, name
k = pe.KLASSEN[pe.klasse(hc, brett)]
return k in PRAEMIE_POST, k
def eigen_replay(kern, wurzel, env_live, env_arm, prozesse):
sp = eigene_anfragen(wurzel)
a = KL.kern_lauf(kern, sp, env_live, prozesse)
b = KL.kern_lauf(kern, sp, env_arm, prozesse)
anders, hart, regel = [], [], []
richt = collections.Counter()
for s, x, y in zip(sp, a, b):
xa, ya = KL.art(x, s["req"]), KL.art(y, s["req"])
if xa == ya:
continue
req = s["req"]
pr, kl = praemie(req)
st = req.get("street")
e = {"zug": s["zug"][:90], "street": st, "hand": "".join(_karten(req)[0]), "klasse": kl, "live": xa, "arm": ya,
"grund_arm": (y.get("reason") or "")[:240]}
anders.append(e)
richt["%s %s->%s" % (st, xa, ya)] += 1
if pr and ya == "FOLD":
hart.append(e)
tc, pot = float(req.get("toCall") or 0), float(req.get("pot") or 0)
if st != "PREFLOP" and ya == "FOLD" and tc > 0 and tc / max(pot - tc, 1e-9) < 0.55 and (y.get("category") or x.get("category")) in STARK:
regel.append(e)
return {"anfragen": len(sp), "anders": len(anders), "richtung": dict(richt.most_common()),
"praemie_zum_fold": hart[:30], "n_praemie_zum_fold": len(hart), "pflichtregel_bruch": regel[:30],
"n_pflichtregel_bruch": len(regel), "beispiele": anders[:40]}
# --- 4 Kipp-Liste ---------------------------------------------------------------------------------
def kipp(kern, live, aend, prozesse, aus):
spots = KL.spots_bauen()
env_arm = env_mit(live, aend)
a = KL.kern_lauf(kern, spots, live, prozesse)
b = KL.kern_lauf(kern, spots, env_arm, prozesse)
# Kandidat (setzt etwas): "mit" = Arm. Reine Herausnahme: "mit" = Live.
mit_ist_arm = any(v is not None for v in aend.values())
kipps = KL.vergleich(spots, a, b, mit_ist_arm)
json.dump(kipps, open(os.path.join(aus, "kipp.json"), "w", encoding="utf-8"), ensure_ascii=False)
z = KL.zusammenfassung(";".join("%s=%s" % (k, v) for k, v in aend.items()), kipps, len(spots))
z["mit_ist_arm"] = mit_ist_arm
return z
# --- 5 LBR ----------------------------------------------------------------------------------------
def lbr_lesen(pfad):
d = {}
if pfad and os.path.exists(pfad):
for z in open(pfad, encoding="utf-8"):
t = z.split()
if len(t) >= 2:
d[int(t[0])] = float(t[1])
return d
def lbr(baum, live, env_arm, haende, aus, threads):
exe = os.path.join(baum, "target", "release", "engine_lbr.exe")
if not os.path.exists(exe):
return {"status": "engine_lbr fehlt (cargo build --release --bin engine_lbr -j 4)"}
import shutil
kopie = os.path.join(aus, "pokerbench-pruefstand-lbr.exe")
shutil.copy2(exe, kopie)
erg = {}
for name, env in (("live", live), ("arm", env_arm)):
datei = os.path.join(aus, "lbr-%s.txt" % name)
e = {k: v for k, v in os.environ.items() if k not in live and k not in env_arm}
e.update(env)
e["POKERBENCH_THREADS"] = str(threads)
subprocess.run([kopie, datei, str(haende)], env=e, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
creationflags=0x40 if sys.platform == "win32" else 0)
erg[name] = lbr_lesen(datei)
gem = sorted(set(erg["live"]) & set(erg["arm"]))
d = [erg["arm"][i] - erg["live"][i] for i in gem]
gleich = all(abs(x) < 1e-9 for x in d)
s, lo, hi = boot([[x] for x in d]) if d else (0.0, 0.0, 0.0)
n = max(len(gem), 1)
return {"haende": len(gem), "bitgleich": gleich, "delta_bb100": round(100 * s / n, 2),
"ci_bb100": [round(100 * lo / n, 2), round(100 * hi / n, 2)],
"live_bb100": round(100 * sum(erg["live"][i] for i in gem) / n, 2)}
# --- Urteil ---------------------------------------------------------------------------------------
def urteil(r):
gruende, offen = [], []
for teil in ("dev", "holdout"):
e = r.get("ev", {}).get(teil)
if not e:
offen.append("EV %s fehlt" % teil)
continue
s, lo, hi, _ = e["delta"].get("alle", [0, 0, 0, 0])
if hi < 0:
gruende.append("EV %s signifikant negativ (%+.0f bb [%+.0f, %+.0f])" % (teil, s, lo, hi))
for name, e in r.get("ev_extra", {}).items():
s, lo, hi, _ = e["delta"].get("alle", [0, 0, 0, 0])
if hi < 0:
gruende.append("EV %s signifikant negativ (%+.0f bb)" % (name, s))
p = r.get("pflicht")
if p is None or "fehler" in (p or {}):
offen.append("Pflichtfälle nicht gelaufen")
elif not p["bestanden"]:
gruende.append("Pflichtfälle: %d harte Verlierer" % p["verlierer"])
e = r.get("replay")
if e is None:
offen.append("Eigen-Replay fehlt")
else:
if e["n_praemie_zum_fold"]:
offen.append("Eigen-Replay: %d Prämienhände zum Fold (einzeln ansehen)" % e["n_praemie_zum_fold"])
if e["n_pflichtregel_bruch"]:
gruende.append("Eigen-Replay bricht die Pflichtregel (%d Folds >= Zwei Paar gegen < 55 %% Topf)" % e["n_pflichtregel_bruch"])
k = r.get("kipp")
if k is None:
offen.append("Kipp-Liste fehlt")
elif k["hart"] and k.get("mit_ist_arm", True):
gruende.append("Kipp-Liste: %d Prämienhände kippen zum Fold" % k["hart"])
elif k["hart"]:
offen.append("Kipp-Liste: der herausgenommene Schalter foldet live %d Prämienhände (Grund für das Herausnehmen, kein Verlierer)" % k["hart"])
lb = r.get("lbr")
if not lb or "haende" not in lb or not lb["haende"]:
offen.append("LBR nicht gemessen")
elif not lb["bitgleich"] and lb["ci_bb100"][0] > 0:
gruende.append("LBR schlechter (%+.1f bb/100 [%+.1f, %+.1f], mehr ausbeutbar)" % (lb["delta_bb100"], *lb["ci_bb100"]))
if gruende:
return "DURCHGEFALLEN", gruende, offen
dev = r.get("ev", {}).get("dev", {}).get("delta", {}).get("alle")
extra_sig = any(e["delta"].get("alle", [0, 0, 0])[1] > 0 for e in r.get("ev_extra", {}).values())
if offen or not ((dev and dev[1] > 0) or extra_sig):
return "OFFEN", gruende, offen + ([] if (dev and dev[1] > 0) or extra_sig else ["kein EV-Nachweis (Intervall schließt 0 ein)"])
return "BESTANDEN", gruende, offen
def bericht(r, aus):
z = ["# Tor echt: `%s`" % r["arm"], "", "**Urteil: %s**" % r["urteil"], ""]
for g in r["gruende"]:
z.append("- Verlierer: " + g)
for g in r["offen"]:
z.append("- offen: " + g)
z += ["", "## 1 EV auf echten NL2-Spots (Caller-Sicht, bb, 95 %-Bootstrap über die Setzer)", "",
"| Teil | Spots | Δ alle | Flop | Turn | River | geänderte Aktionen |", "|---|---|---|---|---|---|---|"]
def zelle(d, f):
x = d["delta"].get(f)
return "%+.0f [%+.0f, %+.0f]" % tuple(x[:3]) if x else "–"
for name, d in list(r.get("ev", {}).items()) + list(r.get("ev_extra", {}).items()):
z.append("| %s | %d | %s | %s | %s | %s | %s |" % (name, d["spots"], zelle(d, "alle"), zelle(d, "flop"), zelle(d, "turn"),
zelle(d, "river"), ", ".join("%s %d" % kv for kv in list(d["anders"].items())[:4])))
p = r.get("pflicht") or {}
z += ["", "## 2 Pflichtfälle", ""]
if "fehler" in p or not p:
z.append("nicht gelaufen: %s" % p.get("fehler", "")[:300])
else:
z.append("%s: Soll Live %d/%d, Arm %d/%d, Ziele behoben %d/%d, harte Verlierer %d" % (
"bestanden" if p["bestanden"] else "DURCHGEFALLEN", p["live_soll"], p["n"], p["kandidat_soll"], p["n"],
p["ziele_behoben"], p["ziele"], p["verlierer"]))
for v in p["verlierer_faelle"]:
z.append("- %s %s: live %s -> %s (%s)" % (v["hand"], v["street"], v["live"], v["kandidat"], v["grund"]))
e = r.get("replay") or {}
z += ["", "## 3 Eigen-Replay (eigene Kern-Anfragen aus den Schatten-Logs)", ""]
if e:
z.append("%d Anfragen, %d anders: %s" % (e["anfragen"], e["anders"], ", ".join("%s %d" % kv for kv in list(e["richtung"].items())[:8])))
z.append("Prämie zum Fold: %d; Pflichtregel-Brüche: %d" % (e["n_praemie_zum_fold"], e["n_pflichtregel_bruch"]))
for x in e["praemie_zum_fold"][:10]:
z.append("- %s %s %s (%s): %s -> %s | %s" % (x["zug"][:40], x["street"], x["hand"], x["klasse"], x["live"], x["arm"], x["grund_arm"][-160:]))
k = r.get("kipp") or {}
z += ["", "## 4 Kipp-Liste (Raster: 169 Starthände je Lage, Postflop je Handklasse)", ""]
if k:
z.append("%d Spots, %d gekippt, %d nur Größe, **%d hart**; Richtungen: %s" % (
k["spots"], k["gekippt"], k["groesse"], k["hart"], ", ".join("%s %d" % kv for kv in list(k["richtung"].items())[:6])))
for x in k["harte_beispiele"][:12]:
z.append("- %s, %s (%s, %s): live %s, Arm %s | %s" % (x["lage"], x["hand"], x.get("klasse") or "", x["gegner"], x["live"], x["arm"],
(x["grund_arm"] if x["arm"] == "FOLD" else x["grund_live"])[-180:]))
lb = r.get("lbr") or {}
z += ["", "## 5 LBR (S1, gepaart)", "", json.dumps(lb, ensure_ascii=False)]
open(os.path.join(aus, "TOR.md"), "w", encoding="utf-8", newline="\n").write("\n".join(z) + "\n")
def main():
ap = argparse.ArgumentParser()
ap.add_argument("--arm", required=True)
ap.add_argument("--aus", required=True)
ap.add_argument("--kern", default=os.path.join(BAUM, "target", "release", "rechner.exe"))
ap.add_argument("--schalter", default=os.path.join(BAUM, "betrieb", "kern_schalter.txt"))
ap.add_argument("--live-wurzel", default=LIVE_WURZEL)
ap.add_argument("--daten", default=DATEN)
ap.add_argument("--spots", action="append", default=[])
ap.add_argument("--stichprobe", type=int, default=5, help="jede n-te Zeile aus spots2(.holdout).jsonl")
ap.add_argument("--prozesse", type=int, default=6)
ap.add_argument("--lbr", type=int, default=40)
ap.add_argument("--lbr-threads", type=int, default=4)
ap.add_argument("--ohne", default="", help="Komma-Liste: ev,pflicht,replay,kipp,lbr")
a = ap.parse_args()
ohne = set(x for x in a.ohne.split(",") if x)
os.makedirs(a.aus, exist_ok=True)
live = KL.lies_schalter(a.schalter)
live.pop("TISCHWAHL", None)
aend = arm_aenderung(a.arm)
env_arm = env_mit(live, aend)
kern = KL.kern_kopie(a.kern, a.aus)
r = {"arm": a.arm, "aenderung": aend}
if "ev" not in ohne:
r["ev"] = {}
for teil, datei in (("dev", "spots2.jsonl"), ("holdout", "spots2.holdout.jsonl")):
p = os.path.join(a.daten, datei)
if os.path.exists(p):
r["ev"][teil] = ev_teil(kern, spots_laden(p, a.stichprobe), live, env_arm, a.prozesse)
print("EV", teil, r["ev"][teil]["delta"].get("alle"), flush=True)
r["ev_extra"] = {}
for p in a.spots:
r["ev_extra"][os.path.basename(p)] = ev_teil(kern, spots_laden(p), live, env_arm, a.prozesse)
print("EV", p, r["ev_extra"][os.path.basename(p)]["delta"].get("alle"), flush=True)
if "pflicht" not in ohne:
r["pflicht"] = pflicht(a.kern, a.arm, a.schalter)
print("Pflicht", {k: v for k, v in r["pflicht"].items() if k != "verlierer_faelle"}, flush=True)
if "replay" not in ohne and os.path.isdir(a.live_wurzel):
r["replay"] = eigen_replay(kern, a.live_wurzel, live, env_arm, a.prozesse)
print("Replay", r["replay"]["anfragen"], r["replay"]["anders"], r["replay"]["n_praemie_zum_fold"], flush=True)
if "kipp" not in ohne:
r["kipp"] = kipp(kern, live, aend, a.prozesse, a.aus)
print("Kipp", r["kipp"]["gekippt"], r["kipp"]["hart"], flush=True)
if "lbr" not in ohne and a.lbr > 0:
r["lbr"] = lbr(BAUM, live, env_arm, a.lbr, a.aus, a.lbr_threads)
print("LBR", r["lbr"], flush=True)
r["urteil"], r["gruende"], r["offen"] = urteil(r)
json.dump(r, open(os.path.join(a.aus, "tor.json"), "w", encoding="utf-8", newline="\n"), ensure_ascii=False, indent=1)
bericht(r, a.aus)
print("URTEIL", r["urteil"], r["gruende"], r["offen"])
return 0 if r["urteil"] == "BESTANDEN" else 1
if __name__ == "__main__":
sys.exit(main())