D1d: Lesen breit (engine::read_exploit, GEGNER_BREIT aus) + Gedaechtnis-Draht profile.reads

- read_exploit: Reads der blind gespielten Stile (Nit/Reg/Maniac) ueber fuenf schmale Kanaele:
  c C-Bet vs Folder, b Bluff-Veto vs Caller, r River fold->call, w River-Duennwert (nur Equity >= 0,5),
  3 Light-3-Bet; jeder Read in KL-Vertrauensregion um den Blind-Wert, Stationen/Multiway/Turnier bitgleich.
- river_br (aus pausiertem WIP 1033e80 uebernommen): node-locked BR, Worst-Case ueber Belief-Box, KL-Budget;
  dient als r/w. river_subgame: ladder_chance, belief_combos.
- decode_villain: profile.reads {n,k,prior} -> Posterior + Vertrauen; neue Felder flop_aggression,
  fold_to_steal, fold_to_raise. Kein reads = bitgleich.
- Replay 1345 echte Zuege: Lesen aendert 0,67 % -> 0,74 % (breit), 1,04 % mit Gedaechtnis-Reads.
- Arme eingereiht (eintraege_breit.txt): Leiter breit-basis/-alle/-c/-b/-rw/-3, LBR typ/nit/maniac.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-14 22:42:05 +01:00
co-authored by Claude Opus 5.5
parent 2b50e8300d
commit faa29b3a1b
20 changed files with 1096 additions and 12 deletions
+1
View File
@@ -100,6 +100,7 @@ Eine Regel für Bankroll und Gesamt-Verlustdeckel über die 30 000 Hände fehlt
| D1 | Zähler je Gegner und Read schreibt live mit (Teil von L0) | Zählungen wachsen, Dedupe stimmt | live |
| D1b | Gezählte Reads an den Kern: Zählung je Kennung mit echter Stichprobe in die Profile (`lesen/profil.py` `mit_zaehlung`), Schalter `GEGNER_ZAEHLUNG=1`; gezeigte River-Einsätze (`riverBluffShown`) zum River-Getriebe, eigener Schalter `GEGNER_SHOWDOWN=1` | Messregel 1a: Leiter mit Gedächtnis-Read im Draht-Format (`LESEN_DRAHT=hud` gegen `gezaehlt`) ohne Verlierer, LBR gepaart dünn gegen gezählt ≤ +5 bb/100; Replay echter Entscheidungen zeigt, was sich ändert | gebaut, beide Schalter aus. Replay 1345 echte Züge: 3 anders (0,2 %), Stil-Read anders in 238 von 516 Nach-Flop-Spots. Leiter + LBR eingereiht (`messung_zaehlung/`). **Wechselpunkt: Owner** |
| D1c | Gedächtnis formt die Ranges des Solvers: `exploit::range_read` (Range-Kippung nach Lockerheit, Bluffanteil je Größe aus Straßen-Aggression und gezeigten River-Einsätzen, Fold je Straße, Vertrauen aus echter Stichprobe) → Kippung der Kombigewichte, festgelegter geglaubter Gegner, KL-Schranke λ aus Vertrauen. Schalter `GEGNER_RANGE=1`, aus. Schnittstelle mit solver-ueberall vereinbart (Orchestrator 14.11.) | LBR gepaart nicht schlechter jenseits des Rauschens; Leiter mit Gedächtnis-Read: Gewinn, kein Profil verliert | gebaut, zuerst im bestehenden River-Veto verdrahtet; Werte auf 634 echten Gegner-Spots plausibel. Leiter `range-an` + LBR `range-lbr-typ` eingereiht. Haken wandert in den Einstieg von solver-ueberall, sobald Stufe A steht |
| D1d | Lesen breit: Ausbeutung auch gegen Nit, Maniac, Folder, passive Fische über begrenzte Kanäle (`engine::read_exploit`, Schalter `GEGNER_BREIT`, aus; C-Bet-Druck, Bluff-Veto, River-Bluff-Catch und Dünnwert über `river_br`, Light-3-Bet), jeder Read in einer KL-Vertrauensregion um den Blind-Wert | Messregel 1a: Gewinn gegen den Lese-Typ > 0, LBR-Anstieg ≤ 5 bb/100, Leiter ohne Verlierer | gebaut; Replay echter Züge: Lesen ändert 0,74 % (vorher 0,67 %), mit Gedächtnis-Draht (`profile.reads`) 1,04 %; limitiert durch die Menge je Read; 6 Leiter- + 5 LBR-Arme eingereiht |
| D2 | Priors aus echten Händen eichen (`lesen/eichung.py`), ab 200 Gegnern mit je ≥ 30 Chancen | κ-Intervalle endlich; ersetzt die gesetzten Anker | Werkzeug steht; 0 von 16 Reads am Tor (39 Gegner); vpip μ̂ 0,70 statt Anker 0,28 |
| D3 | Gezeigte Hände verengen die Range-Annahme je Gegner | Vorhersage auf zurückgehaltenen Händen besser (Log-Loss) | Werkzeug steht; 5 echte gezeigte Hände, zu wenig |
| D4 | Entscheidungs-Audit: jede echte River- und Turn-Entscheidung wird nachgerechnet, EV-Verlust je Entscheidung | Bericht je Woche; zeigt das größte Leck in echten Spots | Werkzeug steht (`bin/audit`); hatte die MDF-Boden-Calls schon markiert. **Wochenbericht läuft noch nicht** |
+4
View File
@@ -286,3 +286,7 @@ das E1-Tor erneut.
| D1c Werte auf echten Gegnern (14.11., 634 Gegner-Spots nach dem Flop) | Live-Profile: 127 ohne Read; Kippung Median +0,05 (p10 −0,40), Bluffanteil Potbet 0,33 fast überall (keine Straßen-Reads), Bluff-Vertrauen ≥ 0,5 auf 0 von 123 River-Spots. **Gezählte Profile: alle mit Read; Kippung p10 −0,91 / Median +0,04 / p90 +0,20, Bluffanteil Potbet 0,18–0,36, Fold Median 0,62, Vertrauen Median 0,73, Bluff-Vertrauen ≥ 0,5 auf 85 von 123 River-Spots.** Gezeigte River-Einsätze im Speicher: noch 0 (Zählung erst ab diesem Stand) | D1c |
| D1c Messungen | eingereiht: Leiter `range-an` (19 Zeilen + micro-passiv, gezählter Gedächtnis-Read, `MDF_UNREAD=0`) gegen `zaehlung-gez`; LBR `range-lbr-typ` (Pool-Regular gezählt, Live-Schalter) gepaart gegen `zaehlung-lbr-typ-gez`. Ergebnis: ausstehend | D1c |
| D1c auf Solver Stufe A | solver-ueberall hat den Haken eingebaut (e7a00cb: Range-Kippung über `solver_lists`, Knotensperre am River als restricted Nash response, w = `trust`). Knotensperre über `believed_row` (3b5cee5). Messstand 9acc58e (Branch `claude/exploit-solver-messung`, nur für Messarme). Eingereiht: Leiter `sr-basis` gegen `sr-range` (`SOLVER_RIVER=1`, gezählter Read, 500/1000 × 2) und LBR `sr-lbr-basis` gegen `sr-lbr-range` (1000 Hände, gezählter Pool-Regular). Ergebnis: ausstehend | D1c |
| D1d Lesen breit gebaut (Schalter `GEGNER_BREIT`, aus) | `engine::read_exploit`: Reads der Stile, die `read_gate` blind spielt (Nit, Reg, Maniac), wirken nur über fünf schmale Kanäle, je eine lokale Änderung der Blind-Entscheidung. `c`: kleine C-Bet gegen Folder (Flop-Check → 1/3 Pot). `b`: kein reiner Bluff in einen Caller (Bet → Check). `r`: River-Bluff-Catch (Fold → Call). `w`: River-Dünnwert, nur gemachte Hand mit Equity ≥ 0,5 (Check → Bet). `3`: Light-3-Bet gegen den Opener. Jeder Read geht durch eine Vertrauensregion: zum Blind-Wert gezogen nach Vertrauen, KL zum Blind-Wert ≤ 0,15·Vertrauen; unter 0,25 Vertrauen ist er der Blind-Wert. `r`/`w` nutzen die node-locked River-Best-Response aus dem pausierten WIP-Branch (`engine::river_br`, schlimmster Fall über eine Belief-Box, Abweichungsgewicht mit KL-Budget). Stationen, Multiway und Turnier unberührt (bitgleich) | Schalter aus = bitgleich (Kanäle leer → Rückgabe unverändert); Spezifikationen `tests/engine_read_exploit.rs` 2 OK, lib-Tests `read_exploit`/`river_br`/`river_subgame` 19 OK |
| D1d Replay echter Züge (14.11., 1345 Züge, 19:25–20:14, gezählte Profile) | Lesen ändert ohne Schalter 9 Züge (0,67 %), mit `GEGNER_BREIT=1` 10 (0,74 %); nur `w` feuert (1 River-Zug). Erster Wurf ohne Dünnwert-Riegel: `w` änderte 23 von 111 River-Zügen, fast alle Luft/Board-only Check → Mini-Bet. Ursache: der Pool zeigt im HUD foldToBet 0,66 (Median), aber foldToCbet nur 0,32 (p90 0,49); die BR las den hohen foldToBet als „foldet alles“ = das Nit-Leck-Muster. Daher `w` nur Wert. `c` feuert nicht, weil der echte Pool kaum C-Bets foldet. `3` feuert nicht, weil foldToThreeBet über 24 HUD-Hände × 0,04 ≈ 1 Spot geschrumpft wird. `b`/`r`: Heuristik blufft selten gegen Caller und foldet River selten gegen Over-Bluffer. Hebel für mehr Wirkung = echte Stichproben je Read (Übergabeformat mit gedaechtnis-voll, `FORMAT-gegner-uebergabe.md`), nicht lockerere Kanäle | `messung_zaehlung/replay_breit.py`, Ergebnis `replay_breit_ergebnis.txt` |
| D1d Gedächtnis-Draht im Kern (`profile.reads`, Übergabe von gedaechtnis-voll) | `wire::decode_villain` liest `reads.<read> = {n, k, prior}`: Posterior (k+α)/(n+α+β), ohne `prior` der Kern-Anker; Vertrauen = n/(n+α+β) (vpip → `confidence`, aggression → `aggression_confidence`). Neue Felder `flop_aggression`, `fold_to_steal`, `fold_to_raise` (Lesen nur, Verbraucher: flop_aggression in `range_read`). Kein `reads` = bitgleich. Replay mit echtem Gedächtnis (1345 Züge, alle mit reads): Lesen ändert 7 (0,52 %) ohne Kanäle, 14 (1,04 %) mit `GEGNER_BREIT=1`; jetzt feuern c (4), b (2), w (1). Grenze bleibt die Menge (D2: vpip ~8400 Hände fehlen) | `tests/wire_decode.rs` memory_reads_become_posteriors OK; 10 Tests in cfr_multi, generated_charts_*, pipeline_bluff, preflop_multi_advice, preflop_plo4 rot, gleich rot auf HEAD 2b50e83 (nicht von hier) |
| D1d Messungen | eingereiht (Warteschlange Live-Worktree): Leiter `breit-basis` (Linien-Reads `READS=cbet,3bet`, Schalter aus) gegen `breit-alle`, `breit-c`, `breit-b`, `breit-rw`, `breit-3`; LBR gepaart `breit-lbr-typ` gegen `zaehlung-lbr-typ-duenn`, `breit-lbr-nit-an`/`-aus`, `breit-lbr-maniac-an`/`-aus` (sicherer Read, 400 Hände = schlimmster Fall) | Tor Messregel 1a: Gewinn gegen den Lese-Typ > 0 im Intervall, LBR-Anstieg ≤ 5 bb/100, Leiter ohne Verlierer. Ein Verlierer-Kanal fällt einzeln |
+1 -1
View File
@@ -33,7 +33,7 @@ SCHALTER_DATEI = os.path.join(BASE, "..", "betrieb", "kern_schalter.txt")
# GEGNER_ZAEHLUNG=1 ist kein Kern-Schalter, sondern einer des Laeufers (betrieb/runner.py): die gezaehlten
# Reads je Gegner gehen in die Profile. Er steht hier, damit er in der Arm-Marke jeder Hand steht.
BEKANNTE_SCHALTER = ("MDF_UNREAD", "RAISE_DRAWS", "RAISE_PRIOR", "TURN_SPIEL", "GRUNDSTRATEGIE",
"GEGNER_ZAEHLUNG", "GEGNER_SHOWDOWN", "GEGNER_RANGE")
"GEGNER_ZAEHLUNG", "GEGNER_SHOWDOWN", "GEGNER_RANGE", "GEGNER_BREIT")
# Pfade gehoeren nicht in die Arm-Marke.
OHNE_MARKE = ("GRUNDSTRATEGIE",)
+13
View File
@@ -0,0 +1,13 @@
# Plan D1d (Lesen breit, GEGNER_BREIT, engine::read_exploit): Leiter, Linien-Reads (READS=cbet,3bet) wie live im HUD; Basis = breit-basis (Schalter aus), je Arm python messung_engine/ab.py messung_zaehlung/arme/breit-basis messung_zaehlung/arme/breit-<x>.
breit-basis|D:\Projects\pokerfreak\.claude\worktrees\exploit-live-ec8091\messung_zaehlung\bin\pokerbench-breit-leiter.exe|D:\Projects\pokerfreak\.claude\worktrees\exploit-live-ec8091\messung_zaehlung\arme\breit-alle 2000 4000 4 wert-sizer,polar,umgekehrt,textur-cbet,position,tanker,balanciert,cbet-folder,3bet-folder,check-raiser,gto,station,fish,reg,nit,maniac,nemesis-1,nemesis-2,nemesis-3,micro-passiv|LESEN_DRAHT=gezaehlt;MDF_UNREAD=0;READS=cbet,3bet|D:\Projects\pokerfreak\.claude\worktrees\exploit-live-ec8091
breit-alle|D:\Projects\pokerfreak\.claude\worktrees\exploit-live-ec8091\messung_zaehlung\bin\pokerbench-breit-leiter.exe|D:\Projects\pokerfreak\.claude\worktrees\exploit-live-ec8091\messung_zaehlung\arme\breit-alle 2000 4000 4 wert-sizer,polar,umgekehrt,textur-cbet,position,tanker,balanciert,cbet-folder,3bet-folder,check-raiser,gto,station,fish,reg,nit,maniac,nemesis-1,nemesis-2,nemesis-3,micro-passiv|LESEN_DRAHT=gezaehlt;MDF_UNREAD=0;READS=cbet,3bet;GEGNER_BREIT=1|D:\Projects\pokerfreak\.claude\worktrees\exploit-live-ec8091
breit-c|D:\Projects\pokerfreak\.claude\worktrees\exploit-live-ec8091\messung_zaehlung\bin\pokerbench-breit-leiter.exe|D:\Projects\pokerfreak\.claude\worktrees\exploit-live-ec8091\messung_zaehlung\arme\breit-c 2000 4000 4 wert-sizer,polar,umgekehrt,textur-cbet,position,tanker,balanciert,cbet-folder,3bet-folder,check-raiser,gto,station,fish,reg,nit,maniac,nemesis-1,nemesis-2,nemesis-3,micro-passiv|LESEN_DRAHT=gezaehlt;MDF_UNREAD=0;READS=cbet,3bet;GEGNER_BREIT=c|D:\Projects\pokerfreak\.claude\worktrees\exploit-live-ec8091
breit-b|D:\Projects\pokerfreak\.claude\worktrees\exploit-live-ec8091\messung_zaehlung\bin\pokerbench-breit-leiter.exe|D:\Projects\pokerfreak\.claude\worktrees\exploit-live-ec8091\messung_zaehlung\arme\breit-b 2000 4000 4 wert-sizer,polar,umgekehrt,textur-cbet,position,tanker,balanciert,cbet-folder,3bet-folder,check-raiser,gto,station,fish,reg,nit,maniac,nemesis-1,nemesis-2,nemesis-3,micro-passiv|LESEN_DRAHT=gezaehlt;MDF_UNREAD=0;READS=cbet,3bet;GEGNER_BREIT=b|D:\Projects\pokerfreak\.claude\worktrees\exploit-live-ec8091
breit-rw|D:\Projects\pokerfreak\.claude\worktrees\exploit-live-ec8091\messung_zaehlung\bin\pokerbench-breit-leiter.exe|D:\Projects\pokerfreak\.claude\worktrees\exploit-live-ec8091\messung_zaehlung\arme\breit-rw 2000 4000 4 wert-sizer,polar,umgekehrt,textur-cbet,position,tanker,balanciert,cbet-folder,3bet-folder,check-raiser,gto,station,fish,reg,nit,maniac,nemesis-1,nemesis-2,nemesis-3,micro-passiv|LESEN_DRAHT=gezaehlt;MDF_UNREAD=0;READS=cbet,3bet;GEGNER_BREIT=rw|D:\Projects\pokerfreak\.claude\worktrees\exploit-live-ec8091
breit-3|D:\Projects\pokerfreak\.claude\worktrees\exploit-live-ec8091\messung_zaehlung\bin\pokerbench-breit-leiter.exe|D:\Projects\pokerfreak\.claude\worktrees\exploit-live-ec8091\messung_zaehlung\arme\breit-3 2000 4000 4 wert-sizer,polar,umgekehrt,textur-cbet,position,tanker,balanciert,cbet-folder,3bet-folder,check-raiser,gto,station,fish,reg,nit,maniac,nemesis-1,nemesis-2,nemesis-3,micro-passiv|LESEN_DRAHT=gezaehlt;MDF_UNREAD=0;READS=cbet,3bet;GEGNER_BREIT=3|D:\Projects\pokerfreak\.claude\worktrees\exploit-live-ec8091
# Plan D1d, Messregel 1a: LBR gepaart, Kern haelt einen SICHEREN (hands 400) Read auf den LBR-Gegner = schlimmster Fall fuer die Ausbeutung; typ gegen zaehlung-lbr-typ-duenn.
breit-lbr-typ|D:\Projects\pokerfreak\.claude\worktrees\exploit-live-ec8091\messung_zaehlung\bin\pokerbench-breit-lbr.exe|D:\Projects\pokerfreak\.claude\worktrees\exploit-live-ec8091\messung_zaehlung\lbr\breit-typ.txt 2000|MDF_UNREAD=0;TURN_SPIEL=grund;GRUNDSTRATEGIE=D:\Projects\pokerfreak\.claude\worktrees\engine-lecks-angreifen-de7b88\daten;GEGNER_BREIT=1;LBR_PROFIL={"vpip":0.23,"pfr":0.16,"foldToBet":0.69,"hands":23,"aggression":0.33,"aggressionActions":2}|D:\Projects\pokerfreak\.claude\worktrees\exploit-live-ec8091
breit-lbr-nit-aus|D:\Projects\pokerfreak\.claude\worktrees\exploit-live-ec8091\messung_zaehlung\bin\pokerbench-breit-lbr.exe|D:\Projects\pokerfreak\.claude\worktrees\exploit-live-ec8091\messung_zaehlung\lbr\breit-nit-aus.txt 2000|MDF_UNREAD=0;TURN_SPIEL=grund;GRUNDSTRATEGIE=D:\Projects\pokerfreak\.claude\worktrees\engine-lecks-angreifen-de7b88\daten;LBR_PROFIL={"vpip":0.14,"pfr":0.11,"foldToBet":0.72,"foldToCbet":0.78,"foldToThreeBet":0.8,"hands":400,"aggression":0.25,"aggressionActions":120}|D:\Projects\pokerfreak\.claude\worktrees\exploit-live-ec8091
breit-lbr-nit-an|D:\Projects\pokerfreak\.claude\worktrees\exploit-live-ec8091\messung_zaehlung\bin\pokerbench-breit-lbr.exe|D:\Projects\pokerfreak\.claude\worktrees\exploit-live-ec8091\messung_zaehlung\lbr\breit-nit-an.txt 2000|MDF_UNREAD=0;TURN_SPIEL=grund;GRUNDSTRATEGIE=D:\Projects\pokerfreak\.claude\worktrees\engine-lecks-angreifen-de7b88\daten;GEGNER_BREIT=1;LBR_PROFIL={"vpip":0.14,"pfr":0.11,"foldToBet":0.72,"foldToCbet":0.78,"foldToThreeBet":0.8,"hands":400,"aggression":0.25,"aggressionActions":120}|D:\Projects\pokerfreak\.claude\worktrees\exploit-live-ec8091
breit-lbr-maniac-aus|D:\Projects\pokerfreak\.claude\worktrees\exploit-live-ec8091\messung_zaehlung\bin\pokerbench-breit-lbr.exe|D:\Projects\pokerfreak\.claude\worktrees\exploit-live-ec8091\messung_zaehlung\lbr\breit-maniac-aus.txt 2000|MDF_UNREAD=0;TURN_SPIEL=grund;GRUNDSTRATEGIE=D:\Projects\pokerfreak\.claude\worktrees\engine-lecks-angreifen-de7b88\daten;LBR_PROFIL={"vpip":0.42,"pfr":0.33,"foldToBet":0.3,"foldToCbet":0.3,"foldToThreeBet":0.35,"hands":400,"aggression":0.62,"aggressionActions":150,"riverAggression":0.6,"riverAggressionActions":40}|D:\Projects\pokerfreak\.claude\worktrees\exploit-live-ec8091
breit-lbr-maniac-an|D:\Projects\pokerfreak\.claude\worktrees\exploit-live-ec8091\messung_zaehlung\bin\pokerbench-breit-lbr.exe|D:\Projects\pokerfreak\.claude\worktrees\exploit-live-ec8091\messung_zaehlung\lbr\breit-maniac-an.txt 2000|MDF_UNREAD=0;TURN_SPIEL=grund;GRUNDSTRATEGIE=D:\Projects\pokerfreak\.claude\worktrees\engine-lecks-angreifen-de7b88\daten;GEGNER_BREIT=1;LBR_PROFIL={"vpip":0.42,"pfr":0.33,"foldToBet":0.3,"foldToCbet":0.3,"foldToThreeBet":0.35,"hands":400,"aggression":0.62,"aggressionActions":150,"riverAggression":0.6,"riverAggressionActions":40}|D:\Projects\pokerfreak\.claude\worktrees\exploit-live-ec8091
+132
View File
@@ -0,0 +1,132 @@
#!/usr/bin/env python3
"""Replay echter Live-Entscheidungen fuer die breite Ausnutzung (Schalter GEGNER_BREIT, engine::read_exploit):
wie viele echte Zuege aendert das Gegner-Lesen insgesamt, und welcher Kanal (c/b/r/w/3) feuert?
Spots und Profile wie replay.py (Shadow-Anfragen des Live-Worktrees, Kennung je Sitz aus den Client-Logs,
gezaehlte Reads aus archiv/lauf/zaehler.json). Arme, alle mit den Live-Schaltern, dasselbe Binary:
leer ohne Profil (blind)
gez gezaehlte Profile, GEGNER_BREIT aus (Stand nach D1b)
breit gezaehlte Profile, GEGNER_BREIT=1
breit+range dazu GEGNER_RANGE=1 (Leseschicht im River-Getriebe)
"Lesen aendert" = Arm != leer.
python messung_zaehlung/replay_breit.py <live-worktree> <log1> [...] --kern <binary> [--aus <datei>]
"""
import argparse
import collections
import json
import os
import re
import sys
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
import replay # noqa: E402
from replay import gleich, kern, mit_profilen, ohne_profile # noqa: E402
KANAL = re.compile(r"breit:(\w)")
def kanal(antwort):
m = KANAL.search(antwort.get("reason") or "")
return m.group(1) if m else None
def main():
ap = argparse.ArgumentParser()
ap.add_argument("live")
ap.add_argument("logs", nargs="+")
ap.add_argument("--kern", required=True)
ap.add_argument("--zaehler", default=None)
ap.add_argument("--aus", default=os.path.join(replay.WURZEL, "messung_zaehlung", "replay_breit.jsonl"))
ap.add_argument("--gedaechtnis", default=None, help="Worktree mit lesen/uebergabe.py (gedaechtnis-voll): Arme ged, ged+breit")
a = ap.parse_args()
sys.path.insert(0, os.path.join(a.live, "entscheiden"))
schalter = {}
with open(os.path.join(a.live, "betrieb", "kern_schalter.txt"), encoding="utf-8") as f:
for z in f:
z = z.split("#", 1)[0].strip()
if "=" in z:
k, v = (t.strip() for t in z.split("=", 1))
schalter[k] = v
basis = {k: v for k, v in {**os.environ, **schalter}.items() if k not in ("GEGNER_BREIT", "GEGNER_RANGE")}
with open(a.zaehler or os.path.join(a.live, "archiv", "lauf", "zaehler.json"), encoding="utf-8") as f:
speicher = json.load(f)
listen = replay.sitzlisten(a.logs)
beginn = min((l[0][0] for l in listen.values() if l), default="9999")
faelle = []
for zeit, raum, anfrage, antwort in replay.zuege(a.live):
if not zeit or zeit < beginn:
continue
sitze = replay.kennung_zur_zeit(listen, raum, zeit)
if sitze is None:
continue
k2c = {int(k): int(v) for k, v in (anfrage.get("_sitze") or {}).items()}
live_profile = {v["seat"]: v.get("profile") for v in anfrage.get("villains", ()) if v.get("profile")}
gez = {}
for v in anfrage.get("villains", ()):
kennung = sitze.get(k2c.get(v["seat"], -1))
z = speicher.get(kennung) if kennung else None
p = replay.profil.mit_zaehlung(live_profile.get(v["seat"]), z, showdown=True) if z else live_profile.get(v["seat"])
if p:
gez[v["seat"]] = p
faelle.append({"zeit": zeit, "raum": raum, "anfrage": anfrage, "gez": gez,
"kennung": {v["seat"]: sitze.get(k2c.get(v["seat"], -1)) for v in anfrage.get("villains", ())}})
print(f"{len(faelle)} Zuege mit Sitzliste ab {beginn}", file=sys.stderr)
gez_anfragen = [mit_profilen(f["anfrage"], f["gez"]) for f in faelle]
arme = {
"leer": kern(a.kern, [ohne_profile(f["anfrage"]) for f in faelle], basis),
"gez": kern(a.kern, gez_anfragen, basis),
"breit": kern(a.kern, gez_anfragen, {**basis, "GEGNER_BREIT": "1"}),
"breit+range": kern(a.kern, gez_anfragen, {**basis, "GEGNER_BREIT": "1", "GEGNER_RANGE": "1"}),
}
namen = ["gez", "breit", "breit+range"]
if a.gedaechtnis:
sys.path.insert(0, os.path.join(a.gedaechtnis, "lesen"))
import uebergabe # noqa: E402
quelle = uebergabe.Quelle(zaehler=a.zaehler or os.path.join(a.live, "archiv", "lauf", "zaehler.json"))
ged = []
reich = 0
for f, q in zip(faelle, gez_anfragen):
q = json.loads(json.dumps(q))
for v in q.get("villains", ()):
if f["kennung"].get(v["seat"]):
v["kennung"] = f["kennung"][v["seat"]]
r = json.loads(uebergabe.anreichern(json.dumps(q), quelle))
reich += any("reads" in (v.get("profile") or {}) for v in r.get("villains", ()))
ged.append(r)
print(f"Gedaechtnis: {reich} von {len(ged)} Anfragen mit reads", file=sys.stderr)
arme["ged"] = kern(a.kern, ged, basis)
arme["ged+breit"] = kern(a.kern, ged, {**basis, "GEGNER_BREIT": "1"})
namen += ["ged", "ged+breit"]
z = collections.Counter()
with open(a.aus, "w", encoding="utf-8") as aus:
for i, f in enumerate(faelle):
s = f["anfrage"].get("street")
z["alle"] += 1
z["alle " + s] += 1
leer = arme["leer"][i]
for name in namen:
x = arme[name][i]
if not gleich(leer, x):
z[f"{name} != leer"] += 1
z[f"{name} != leer {s}"] += 1
for name in [x for x in namen if x != "gez"]:
x = arme[name][i]
if not gleich(arme["gez"][i], x):
k = kanal(x) or "?"
z[f"{name} != gez"] += 1
z[f"{name} != gez kanal {k}"] += 1
z[f"{name} != gez {arme['gez'][i].get('action')}->{x.get('action')}"] += 1
if name == "breit+range":
aus.write(json.dumps({"zeit": f["zeit"], "raum": f["raum"], "strasse": s, "kanal": k,
"gez": [arme["gez"][i].get(t) for t in ("action", "size", "reason")],
"breit": [x.get(t) for t in ("action", "size", "reason")],
"profile": {str(k2): p for k2, p in f["gez"].items()}},
ensure_ascii=False) + "\n")
n = z["alle"] or 1
for k in sorted(z):
print(f"{k:40s} {z[k]:6d} {100.0 * z[k] / n:6.2f} %")
if __name__ == "__main__":
main()
@@ -0,0 +1,49 @@
alle 1345 100.00 %
alle FLOP 237 17.62 %
alle PREFLOP 829 61.64 %
alle RIVER 111 8.25 %
alle TURN 168 12.49 %
breit != gez 1 0.07 %
breit != gez CHECK->RAISE 1 0.07 %
breit != gez kanal w 1 0.07 %
breit != leer 10 0.74 %
breit != leer FLOP 2 0.15 %
breit != leer PREFLOP 3 0.22 %
breit != leer RIVER 3 0.22 %
breit != leer TURN 2 0.15 %
breit+range != gez 1 0.07 %
breit+range != gez CHECK->RAISE 1 0.07 %
breit+range != gez kanal w 1 0.07 %
breit+range != leer 10 0.74 %
breit+range != leer FLOP 2 0.15 %
breit+range != leer PREFLOP 3 0.22 %
breit+range != leer RIVER 3 0.22 %
breit+range != leer TURN 2 0.15 %
ged != gez 4 0.30 %
ged != gez ABSTAIN->RAISE 1 0.07 %
ged != gez RAISE->FOLD 3 0.22 %
ged != gez kanal ? 4 0.30 %
ged != leer 7 0.52 %
ged != leer FLOP 1 0.07 %
ged != leer PREFLOP 2 0.15 %
ged != leer RIVER 2 0.15 %
ged != leer TURN 2 0.15 %
ged+breit != gez 11 0.82 %
ged+breit != gez ABSTAIN->RAISE 1 0.07 %
ged+breit != gez CHECK->RAISE 5 0.37 %
ged+breit != gez RAISE->CHECK 2 0.15 %
ged+breit != gez RAISE->FOLD 3 0.22 %
ged+breit != gez kanal ? 4 0.30 %
ged+breit != gez kanal b 2 0.15 %
ged+breit != gez kanal c 4 0.30 %
ged+breit != gez kanal w 1 0.07 %
ged+breit != leer 14 1.04 %
ged+breit != leer FLOP 5 0.37 %
ged+breit != leer PREFLOP 2 0.15 %
ged+breit != leer RIVER 5 0.37 %
ged+breit != leer TURN 2 0.15 %
gez != leer 9 0.67 %
gez != leer FLOP 2 0.15 %
gez != leer PREFLOP 3 0.22 %
gez != leer RIVER 2 0.15 %
gez != leer TURN 2 0.15 %
+7 -3
View File
@@ -16,7 +16,7 @@ use crate::game::{Decision, Spot, Street};
use crate::guard::enforce::enforce;
use crate::icm::lage::Turnierlage;
use crate::icm::risk::{call_premium, jam_depth_gate, jam_pressure, jam_width_factor, width_factor};
use crate::preflop::advise::advise_widened;
use crate::preflop::advise::advise_widened_read;
use crate::preflop::plan::PreflopPlan;
use crate::read::hand_read::read;
use crate::rng::Rng;
@@ -102,7 +102,8 @@ fn postflop(spot: &Spot, thresholds: &Thresholds, raw: &Spot, premium: f64) -> D
if let Some(d) = super::turn_game::turn_game_decision(raw) {
return d.with_equity(equity.share);
}
return super::river_subgame::fold_veto(raw, floored);
// 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));
}
floored
}
@@ -128,7 +129,10 @@ fn think(spot: &Spot, premium: f64, jam_widen: f64, raw: &Spot) -> Decision {
let thresholds = with_premium(adjust(Thresholds::BASE, &profiles), premium);
match spot.street {
Street::Preflop => {
let plan = advise_widened(spot, &thresholds, jam_widen);
// Bounded light 3-bet vs openers the gate plays blind (`read_exploit`, switch GEGNER_BREIT);
// cash only: with an ICM premium the raw read stays out.
let read = (premium <= 0.0).then_some(raw);
let plan = advise_widened_read(spot, read, &thresholds, jam_widen);
// Eine Grenzhand folgt ihrer Seite der Tabelle (Raise bleibt Raise, Call bleibt Call):
// nahe der Grenze ist jede Linie fast gleich viel wert, Aussetzen ist die schlechteste.
let certainty = plan.certainty.max(MIN_CERTAINTY);
+2
View File
@@ -13,10 +13,12 @@ pub mod omaha_combos;
pub mod options;
pub mod passive;
pub mod postflop;
pub mod read_exploit;
pub mod read_gate;
pub mod range_combos;
pub mod range_filter;
pub mod read_label;
pub mod river_br;
pub mod river_subgame;
pub mod run_twice;
pub mod semibluff;
+298
View File
@@ -0,0 +1,298 @@
//! Bounded exploitation of the opponents `read_gate` plays blind (switch `GEGNER_BREIT`, default off).
//!
//! `read_gate` hands the heuristic a read only for calling stations: acting on a nit's, a reg's or a
//! maniac's read through the single-street bluff EV bled on the ladder (nit −50, maniac −148, reg −176
//! bb/100), because the read flowed into EVERY offensive channel at full strength (BEFUND-nit-read-leck:
//! flop check → bluff-RAISE into a nutted continuing range). This module re-opens the read for the
//! other styles, but only through a few narrow channels, each a single, local change to the blind
//! decision that the read can price completely:
//!
//! | letter | channel | change | read |
//! |---|---|---|---|
//! | `c` | c-bet pressure | flop check → small c-bet (hero preflop aggressor, heads-up) | `fold_to_cbet` |
//! | `b` | bluff veto | a pure-bluff bet → check | street fold-to-bet |
//! | `r` | bluff-catch | river fold → call facing a bet | river gearbox (aggression / shown bluffs) |
//! | `w` | thin value | river check → bet with a made hand | river gearbox |
//! | `3` | light 3-bet | preflop call / top fold → 3-bet vs the lone opener | `fold_to_three_bet` |
//!
//! Every read passes the same trust region before it is used (`bounded`): it is pulled toward the
//! blind default by its confidence, then capped so the Bernoulli KL divergence from the blind default
//! stays within `KL_PER_CONFIDENCE · confidence` nats. A thin read is the blind default; a strong
//! read moves the parameter, never past the KL ball. The river channels'
//! check is the node-locked best response of `river_br` (taken over from the paused WIP branch
//! `worktree-agent-a3f0fb40e48710d66`): worst-case gain over a belief box, KL-capped deviation weight.
//!
//! Untouched: calling stations (already exploited by the heuristic, bit-identical), multiway pots,
//! tournament spots (the caller applies this only with no ICM premium), and every decision the switch
//! does not name. `GEGNER_BREIT=1` turns on all channels; otherwise its value lists the letters.
use super::bluff::is_bluff_hand;
use super::read_gate::exploit_worthy;
use super::river_br;
use crate::exploit::fold_chance::DEFAULT_FOLD_TO_BET;
use crate::exploit::profile::Profile;
use crate::exploit::sample::FOLD_TO_THREE_BET_ANCHOR;
use crate::exploit::style::classify;
use crate::game::{line, ActionKind, Choice, Decision, Spot, Street, Villain};
use crate::read::hand_read::HandRead;
use crate::read::tier::{tier, Tier};
use crate::sizing::candidates::candidates;
/// Below this confidence a read is not used at all (as the river gearbox's `CONFIDENCE_FLOOR`).
pub const CONFIDENCE_FLOOR: f64 = 0.25;
/// Trust-region radius per unit of confidence, in nats of Bernoulli KL from the blind default.
pub const KL_PER_CONFIDENCE: f64 = 0.15;
/// C-bet pressure: bet size as a pot fraction (small: cheap to be wrong, the folder folds anyway).
pub const CBET_FRACTION: f64 = 0.33;
/// C-bet pressure: the bet must beat checking by this share of the pot.
pub const CBET_EDGE: f64 = 0.05;
/// Thin value (`w`): least equity vs the range for the river check -> bet.
pub const THIN_VALUE_EQUITY: f64 = 0.5;
/// C-bet pressure: the trust-bounded fold-to-c-bet must exceed the blind default by this much.
pub const CBET_READ_LIFT: f64 = 0.15;
/// C-bet pressure: only hands up to this equity (strong hands keep the heuristic's own line).
pub const CBET_MAX_EQUITY: f64 = 0.5;
/// Equity a called c-bet keeps relative to the hand's equity against the full range.
pub const CALLED_EQUITY_SHARE: f64 = 0.8;
/// The channels the switch turns on.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub struct Channels {
pub cbet: bool,
pub bluff_veto: bool,
pub bluff_catch: bool,
pub thin_value: bool,
pub light_three_bet: bool,
}
impl Channels {
pub fn parse(value: &str) -> Channels {
let v = value.trim();
if v == "1" || v.eq_ignore_ascii_case("alle") {
return Channels { cbet: true, bluff_veto: true, bluff_catch: true, thin_value: true, light_three_bet: true };
}
Channels {
cbet: v.contains('c'),
bluff_veto: v.contains('b'),
bluff_catch: v.contains('r'),
thin_value: v.contains('w'),
light_three_bet: v.contains('3'),
}
}
}
/// The channels from `GEGNER_BREIT` (read once).
pub fn channels() -> Channels {
static ON: std::sync::OnceLock<Channels> = std::sync::OnceLock::new();
*ON.get_or_init(|| std::env::var("GEGNER_BREIT").map(|v| Channels::parse(&v)).unwrap_or_default())
}
/// Bernoulli KL divergence `KL(p ‖ q)` in nats.
pub fn kl(p: f64, q: f64) -> f64 {
let p = p.clamp(1e-9, 1.0 - 1e-9);
let q = q.clamp(1e-9, 1.0 - 1e-9);
p * (p / q).ln() + (1.0 - p) * ((1.0 - p) / (1.0 - q)).ln()
}
/// The trust region: `read` pulled toward `anchor` by `confidence`, then capped at KL radius
/// `KL_PER_CONFIDENCE · confidence` from `anchor`. Below `CONFIDENCE_FLOOR` (or a non-finite input)
/// the anchor itself.
pub fn bounded(read: f64, anchor: f64, confidence: f64) -> f64 {
if !(read.is_finite() && anchor.is_finite() && confidence.is_finite()) || confidence < CONFIDENCE_FLOOR {
return anchor;
}
let c = confidence.min(1.0);
let target = anchor + c * (read.clamp(0.0, 1.0) - anchor);
let radius = KL_PER_CONFIDENCE * c;
if kl(target, anchor) <= radius {
return target;
}
let (mut lo, mut hi) = (0.0f64, 1.0f64);
for _ in 0..50 {
let mid = 0.5 * (lo + hi);
if kl(anchor + mid * (target - anchor), anchor) <= radius {
lo = mid;
} else {
hi = mid;
}
}
anchor + lo * (target - anchor)
}
/// The lone live villain whose read the gate drops (a non-station with a profile), else `None`.
fn blind_read_villain(spot: &Spot) -> Option<(&Villain, Profile)> {
let mut live = spot.live_villains();
let (Some(v), None) = (live.next(), live.next()) else { return None };
let p = v.profile?;
if exploit_worthy(classify(&p)) {
return None; // the heuristic already exploits it; leave it bit-identical
}
Some((v, p))
}
fn confidence(p: &Profile) -> f64 {
p.confidence.filter(|c| c.is_finite()).unwrap_or(0.0)
}
fn finite(x: Option<f64>) -> Option<f64> {
x.filter(|v| v.is_finite())
}
/// The legal bet nearest `fraction · pot` (a total street amount), if any.
fn bet_near(spot: &Spot, fraction: f64) -> Option<f64> {
let target = fraction * spot.pot;
candidates(spot)
.into_iter()
.filter(|to| *to > 0.0 && *to <= spot.hero_stack)
.min_by(|a, b| (a - target).abs().total_cmp(&(b - target).abs()))
}
fn street_index(street: Street) -> Option<usize> {
match street {
Street::Flop => Some(0),
Street::Turn => Some(1),
Street::River => Some(2),
Street::Preflop => None,
}
}
fn tagged(base: Decision, choice: Choice, tag: &str, why: String) -> Decision {
Decision { choice, reason: format!("breit:{tag}: {why} | {}", base.reason), ..base }
}
/// Postflop: apply the switched-on channels to the heuristic's final decision (`base`, after floor and
/// veto) on the RAW (ungated) spot. Returns `base` unchanged whenever no channel fires.
pub fn postflop(raw: &Spot, hand: &HandRead, base: Decision) -> Decision {
postflop_with(channels(), raw, hand, base)
}
pub fn postflop_with(ch: Channels, raw: &Spot, hand: &HandRead, base: Decision) -> Decision {
if ch == Channels::default() || raw.street == Street::Preflop {
return base;
}
let Some((_, p)) = blind_read_villain(raw) else { return base };
let conf = confidence(&p);
let equity = base.equity.unwrap_or(0.5);
let can_bet = raw.to_call == 0.0 && raw.is_legal(ActionKind::Raise);
// c: c-bet pressure against a folder.
if ch.cbet && base.choice == Choice::Check && can_bet && line::cbet_spot(&raw.history, raw.hero_seat, raw.street) {
if let (Some(read), Some(b)) = (finite(p.fold_to_cbet), bet_near(raw, CBET_FRACTION)) {
let anchor = finite(p.fold_to_bet).unwrap_or(DEFAULT_FOLD_TO_BET).min(DEFAULT_FOLD_TO_BET);
let f = bounded(read, anchor, conf);
let pot = raw.pot;
let called = CALLED_EQUITY_SHARE * equity;
let gain_at = |f: f64| f * pot + (1.0 - f) * (called * (pot + 2.0 * b) - b) - equity * pot;
let gain = gain_at(f);
// The heuristic checked blind for its own (multi-street) reasons, although this one-street
// sum already pays at the blind default; so the read must lift the fold rate clearly
// (`CBET_READ_LIFT` after the trust region) and the bet must gain over that default too.
let lift = gain - gain_at(anchor);
if equity <= CBET_MAX_EQUITY && f >= anchor + CBET_READ_LIFT && gain >= CBET_EDGE * pot && lift > 0.0 {
let why = format!("fold to c-bet {read:.2} -> {f:.2} (conf {conf:.2}), +{:.2} pot", gain / pot);
return tagged(base, Choice::Raise { to: b }, "c", why);
}
}
}
// b: no pure bluff into a caller.
if ch.bluff_veto && raw.to_call == 0.0 && is_bluff_hand(hand, raw) && raw.is_legal(ActionKind::Check) {
if let Choice::Raise { to } = base.choice {
let i = street_index(raw.street);
let read = if line::cbet_spot(&raw.history, raw.hero_seat, raw.street) {
finite(p.fold_to_cbet)
} else {
None
}
.or_else(|| i.and_then(|i| finite(p.street_fold_to_bet[i])))
.or(finite(p.fold_to_bet));
if let Some(read) = read {
let f = bounded(read, DEFAULT_FOLD_TO_BET, conf);
let ev_at = |f: f64| f * raw.pot - (1.0 - f) * to;
let ev = ev_at(f);
// Only where the read flips the blind verdict (the blind fold rate pays the bluff).
if ev < 0.0 && ev_at(DEFAULT_FOLD_TO_BET) >= 0.0 {
let why = format!("fold {read:.2} -> {f:.2} (conf {conf:.2}), bluff EV {:.2} pot", ev / raw.pot);
return tagged(base, Choice::Check, "b", why);
}
}
}
}
// r / w: the node-locked river best response (`engine::river_br`, worst case over a belief box
// around the read, deviation weight capped by a KL budget in the confidence), anchored at the
// heuristic's own decision. Only its promote pieces: fold -> call, check -> bet.
if raw.street == Street::River && (ch.bluff_catch || ch.thin_value) {
let mut mask = 0u8;
if ch.bluff_catch {
mask |= river_br::PIECE_PROMOTE_CALL;
}
// Thin VALUE only: a made hand at least even against the range. Replay 14.11. without this:
// 23 of 111 real river spots, nearly all air/board-only check -> small bet into a high HUD
// fold-to-bet - the nit-leak pattern (a read fold rate turned into bluffs), not value.
let value = tier(hand.made) != Tier::Weak && base.equity.is_some_and(|e| e >= THIN_VALUE_EQUITY);
if ch.thin_value && value {
mask |= river_br::PIECE_VALUE_BET;
}
let before = base.choice;
let refined = river_br::refine_with(raw, base, mask);
if refined.choice != before {
let tag = if refined.choice == Choice::Call { "r" } else { "w" };
let why = refined.reason.clone();
return Decision { reason: format!("breit:{tag}: {why}"), ..refined };
}
return refined;
}
base
}
/// Preflop `3`: the opener's fold-to-3-bet, trust-bounded, for an opener the gate plays blind. `None`
/// when the channel is off, the opener is a station (its gated profile already carries the read) or
/// has no usable read.
pub fn fold_to_three_bet(raw: &Spot, seat: u8) -> Option<f64> {
fold_to_three_bet_with(channels(), raw, seat)
}
pub fn fold_to_three_bet_with(ch: Channels, raw: &Spot, seat: u8) -> Option<f64> {
if !ch.light_three_bet {
return None;
}
let v = raw.villains.iter().find(|v| v.seat == seat && !v.folded)?;
let p = v.profile?;
if exploit_worthy(classify(&p)) {
return None;
}
let read = finite(p.fold_to_three_bet)?;
let conf = confidence(&p);
(conf >= CONFIDENCE_FLOOR).then(|| bounded(read, FOLD_TO_THREE_BET_ANCHOR, conf))
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn the_trust_region_holds_the_kl_ball() {
assert_eq!(bounded(0.9, 0.45, 0.1), 0.45, "below the floor: blind default");
let f = bounded(0.95, 0.45, 0.8);
assert!(f > 0.45 && f < 0.95);
assert!(kl(f, 0.45) <= KL_PER_CONFIDENCE * 0.8 + 1e-9);
// a small move inside the ball is just the confidence pull
let g = bounded(0.50, 0.45, 0.8);
assert!((g - (0.45 + 0.8 * 0.05)).abs() < 1e-12);
// monotone in confidence
assert!(bounded(0.95, 0.45, 0.5) < bounded(0.95, 0.45, 0.9));
assert_eq!(bounded(f64::NAN, 0.45, 0.9), 0.45);
}
#[test]
fn the_switch_names_its_channels() {
assert_eq!(Channels::parse(""), Channels::default());
assert_eq!(Channels::parse("0"), Channels::default());
let all = Channels::parse("1");
assert!(all.cbet && all.bluff_veto && all.bluff_catch && all.thin_value && all.light_three_bet);
let some = Channels::parse("cb");
assert!(some.cbet && some.bluff_veto && !some.bluff_catch && !some.thin_value && !some.light_three_bet);
assert!(Channels::parse("3").light_three_bet);
}
}
+271
View File
@@ -0,0 +1,271 @@
//! Node-locked, trust-region exploitative best response on the heads-up river (Pillar 3).
//!
//! The full "gearbox" (solver plays every action, anchored at GTO) was a measured loser: a KL ball
//! around GTO cannot reach the thin value bets / light calls the heuristic uses to farm stations, so
//! replacing the heuristic bled exactly where it wins. This module therefore anchors at the
//! **heuristic's own decision** and only *deviates* where a node-locked best response proves a gain:
//!
//! 1. **Node-lock.** Villain's two nodes (`v_check`, `v_bet`) are fixed to read-derived strategies
//! (fold-to-bet, aggression). Hero's best response over the card-exact river tree is exact
//! (`value_walk`, `Responder::Best`): no CFR solve, so it is cheap and noise-free.
//! 2. **Uncertainty.** The read is not a point: the best response is evaluated on a box of beliefs
//! around it (fold-to-bet and aggression, radius shrinking with the read's confidence but never
//! below `DELTA_MIN`, since model misfit does not vanish with sample size). The gain used is the
//! WORST case over the box.
//! 3. **Trust region.** Deviate from the heuristic only if the worst-case gain exceeds a margin, and
//! mix the deviation in with weight `w <= 1 - exp(-KL_BUDGET * confidence)` (the KL budget of the
//! deviation from the heuristic grows with confidence). No read / thin read: the heuristic's
//! decision is returned untouched (bit-identical).
//!
//! Pieces are independently switchable (`PIECE_*`) so each can be proven alone on the ladder.
use crate::cfr::strategy::Strategy;
use crate::cfr::tree::Tree;
use crate::cfr::value_walk::{root_values, Responder};
use crate::cfr::river::tree_with_chance;
use crate::exploit::fold_chance::DEFAULT_FOLD_TO_BET;
use crate::exploit::posterior::DEFAULT_AGGRESSION;
use crate::game::{Choice, Decision, SeenAction, Spot, Street};
use crate::hand::showdown::judge;
use crate::rng::Rng;
use crate::sizing::candidates::candidates;
use std::cell::Cell;
/// Facing a bet: heuristic Fold -> Call when the worst-case EV of calling is clearly positive.
pub const PIECE_PROMOTE_CALL: u8 = 1;
/// Facing a bet: heuristic Call -> Fold when even the best case EV of calling is clearly negative.
pub const PIECE_DEMOTE_CALL: u8 = 2;
/// Aggressor: heuristic Check -> Bet (best size) when the worst-case gain is clearly positive.
pub const PIECE_VALUE_BET: u8 = 4;
/// Aggressor: heuristic Bet -> Check when even the best case gain of betting is clearly negative.
pub const PIECE_BET_TO_CHECK: u8 = 8;
/// Shipped set. Only proven pieces are on.
pub const SHIPPED: u8 = 0;
thread_local! {
static OVERRIDE: Cell<Option<u8>> = const { Cell::new(None) };
}
/// Measurement hook: override the active pieces on this thread (`None` = shipped set).
pub fn set_pieces(p: Option<u8>) {
OVERRIDE.with(|c| c.set(p));
}
fn pieces() -> u8 {
OVERRIDE.with(|c| c.get()).unwrap_or(SHIPPED)
}
/// Below this confidence the module stands down entirely.
const CONFIDENCE_FLOOR: f64 = 0.25;
/// Belief box half-width at zero confidence, shrinking as `(1 - c)`.
const DELTA0: f64 = 0.30;
/// Belief box half-width that never shrinks (model misfit).
const DELTA_MIN: f64 = 0.10;
/// Required worst-case gain as a fraction of the pot.
const MARGIN: f64 = 0.04;
/// Gain (fraction of pot) at which the deviation weight saturates.
const GAIN_FULL: f64 = 0.20;
/// KL budget scale: weight cap `1 - exp(-KL_BUDGET * c)`.
const KL_BUDGET: f64 = 3.0;
/// Bet sizes (pot fractions) tried by the value-bet piece.
const SIZES: [f64; 3] = [0.33, 0.66, 1.0];
/// Villain's believed strategy for a given fold-to-bet `f` and aggression `a`; `ip` = hero acts last
/// (villain already checked, so `v_check` is "check").
fn believed(tree: &Tree, n: usize, f: f64, a: f64, pot: f64, bet: f64, ip: bool) -> Strategy {
let rank = |c: usize| if n <= 1 { 1.0 } else { c as f64 / (n - 1) as f64 };
let gto_bluff = if pot + bet > 0.0 { bet / (pot + bet) } else { 0.0 };
let bluff = (gto_bluff * a / DEFAULT_AGGRESSION).clamp(0.0, 1.0);
let base = Strategy::uniform(tree);
let s = base
.with_rows(tree, "v_bet", |c| if rank(c) >= f { vec![0.0, 1.0] } else { vec![1.0, 0.0] })
.unwrap_or(base);
s.with_rows(tree, "v_check", |c| {
let r = rank(c);
let p = if ip {
0.0
} else if r >= 0.60 {
1.0
} else if r <= 0.30 {
bluff
} else {
0.0
};
vec![1.0 - p, p]
})
.unwrap_or(s)
}
/// Hero's conditional action values (chips, relative) at `node` for bucket `hb`, hero best-responding
/// below, villain node-locked to `strat`.
fn cond_values(tree: &Tree, strat: &Strategy, node: usize, hb: usize) -> Option<Vec<f64>> {
let n = tree.classes;
let mut out = None;
root_values(tree, strat, Responder::Best, 0, &mut |v| {
if v.node == node {
let mass: f64 = (0..n).map(|o| tree.chance[hb * n + o] * v.opp[o]).sum();
if mass > 1e-12 {
out = Some(v.action_values.iter().map(|a| a[hb] / mass).collect());
}
}
});
out
}
/// (min, max) over the belief box of `value(action 1) - value(action 0)` at `node`.
#[allow(clippy::too_many_arguments)]
fn gain_range(
ladder_n: usize,
chance: &[f64],
pot: f64,
bet: f64,
node: usize,
hb: usize,
f: f64,
a: f64,
delta: f64,
ip: bool,
) -> Option<(f64, f64)> {
let tree = tree_with_chance(ladder_n, chance.to_vec(), pot, bet);
let (mut lo, mut hi) = (f64::INFINITY, f64::NEG_INFINITY);
let pts = [(0.0, 0.0), (-1.0, -1.0), (-1.0, 1.0), (1.0, -1.0), (1.0, 1.0)];
for (df, da) in pts {
let strat = believed(&tree, ladder_n, (f + df * delta).clamp(0.0, 1.0), (a + da * delta).clamp(0.0, 1.0), pot, bet, ip);
let q = cond_values(&tree, &strat, node, hb)?;
let g = q.get(1)? - q.first()?;
lo = lo.min(g);
hi = hi.max(g);
}
Some((lo, hi))
}
fn weight(gain: f64, pot: f64, conf: f64) -> f64 {
let cap = 1.0 - (-KL_BUDGET * conf).exp();
(gain / (GAIN_FULL * pot)).clamp(0.0, 1.0).min(cap)
}
fn villain_checked_river(spot: &Spot) -> bool {
let Some(v) = spot.live_villains().next() else { return false };
spot.history.iter().any(|r| r.street == Street::River && r.seat == v.seat && r.action == SeenAction::Check)
}
/// Refine the (floored, vetoed) heuristic decision on the river. Identity unless a shipped/active
/// piece fires on a confident read with a worst-case-proven gain.
pub fn refine(raw: &Spot, base: Decision) -> Decision {
refine_with(raw, base, pieces())
}
/// `refine` with an explicit piece mask (`engine::read_exploit` maps its river letters onto pieces).
pub fn refine_with(raw: &Spot, base: Decision, active: u8) -> Decision {
if active == 0 || raw.street != Street::River {
return base;
}
let facing = raw.to_call > 0.0;
let relevant = match (&base.choice, facing) {
(Choice::Fold, true) => active & PIECE_PROMOTE_CALL != 0,
(Choice::Call, true) => active & PIECE_DEMOTE_CALL != 0,
(Choice::Check, false) => active & PIECE_VALUE_BET != 0,
(Choice::Raise { .. }, false) => active & PIECE_BET_TO_CHECK != 0,
_ => false,
};
if !relevant {
return base;
}
let Some((combos, profile)) = super::river_subgame::belief_combos(raw) else { return base };
let Some(profile) = profile else { return base };
let conf = profile.confidence.filter(|c| !c.is_nan()).unwrap_or(0.0);
if conf < CONFIDENCE_FLOOR {
return base;
}
let Ok(hero) = judge(&raw.rules(), &raw.hero_cards, &raw.board) else { return base };
let Some((ladder, chance)) = super::river_subgame::ladder_chance(raw, &combos, &combos) else { return base };
let hb = ladder.partition_point(|d| *d < hero).min(ladder.len() - 1);
let n = ladder.len();
let f = profile.street_fold_to_bet[2].or(profile.fold_to_bet).filter(|x| !x.is_nan()).unwrap_or(DEFAULT_FOLD_TO_BET);
let a = profile.river_aggression.or(profile.aggression).filter(|x| !x.is_nan()).unwrap_or(DEFAULT_AGGRESSION);
let delta = (DELTA0 * (1.0 - conf)).max(DELTA_MIN);
let ip = villain_checked_river(raw);
let deviate = |choice: Choice, gain: f64, pot: f64, what: &str| -> Decision {
let w = weight(gain, pot, conf);
let (u, _) = Rng::seeded(raw.seed ^ 0xB4_5E_ED).unit();
if u < w {
Decision { choice, reason: format!("node-locked BR {what}: worst-case gain {gain:.2} (w {w:.2})"), ..base.clone() }
} else {
base.clone()
}
};
if facing {
let pot = raw.pot - raw.to_call;
if pot <= 0.0 {
return base;
}
let Some((lo, hi)) = gain_range(n, &chance, pot, raw.to_call, 4, hb, f, a, delta, false) else { return base };
match base.choice {
Choice::Fold if lo > MARGIN * pot => deviate(Choice::Call, lo, pot, "fold->call"),
Choice::Call if hi < -MARGIN * pot => deviate(Choice::Fold, -hi, pot, "call->fold"),
_ => base,
}
} else {
let pot = raw.pot;
match base.choice {
Choice::Check => {
let mut best: Option<(f64, f64)> = None; // (lo, size)
for frac in SIZES {
let target = frac * pot;
let Some(size) = candidates(raw)
.into_iter()
.filter(|t| *t > 0.0 && *t <= raw.hero_stack)
.min_by(|x, y| (x - target).abs().total_cmp(&(y - target).abs()))
else {
continue;
};
let Some((lo, _)) = gain_range(n, &chance, pot, size, 0, hb, f, a, delta, ip) else { continue };
if best.is_none_or(|(b, _)| lo > b) {
best = Some((lo, size));
}
}
match best {
Some((lo, size)) if lo > MARGIN * pot => deviate(Choice::Raise { to: size }, lo, pot, "check->bet"),
_ => base,
}
}
Choice::Raise { to } => {
let Some((_, hi)) = gain_range(n, &chance, pot, to.min(raw.hero_stack), 0, hb, f, a, delta, ip) else { return base };
if hi < -MARGIN * pot {
deviate(Choice::Check, -hi, pot, "bet->check")
} else {
base
}
}
_ => base,
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn weight_is_capped_by_confidence_and_zero_without_gain() {
assert_eq!(weight(0.0, 10.0, 0.9), 0.0);
assert!(weight(100.0, 10.0, 0.3) < weight(100.0, 10.0, 0.9));
assert!(weight(100.0, 10.0, 0.9) <= 1.0 - (-KL_BUDGET * 0.9f64).exp() + 1e-12);
assert_eq!(weight(100.0, 10.0, 0.0), 0.0);
}
#[test]
fn belief_box_never_collapses() {
for c in [0.0, 0.5, 0.99] {
assert!((DELTA0 * (1.0 - c)).max(DELTA_MIN) >= DELTA_MIN);
}
}
#[test]
fn shipped_set_is_identity() {
set_pieces(None);
assert_eq!(pieces(), SHIPPED);
}
}
+15 -2
View File
@@ -144,6 +144,13 @@ fn subgame(spot: &Spot, hero_combos: &[Vec<Card>], villain_combos: &[Vec<Card>],
Some(Subgame { tree, solved, ladder })
}
/// The shared strength ladder and the card-exact joint deal table (no solve): what the node-locked
/// best response (`engine::river_br`) evaluates hero on against a fixed villain, without a CFR solve.
pub(crate) fn ladder_chance(spot: &Spot, hero_combos: &[Vec<Card>], villain_combos: &[Vec<Card>]) -> Option<(Vec<Strength>, Vec<f64>)> {
let (tree, ladder) = river_tree(spot, hero_combos, villain_combos, 1.0, 1.0)?;
Some((ladder, tree.chance))
}
/// The card-exact river tree and its strength ladder, unsolved (see `subgame`).
fn river_tree(spot: &Spot, hero_combos: &[Vec<Card>], villain_combos: &[Vec<Card>], pot: f64, bet: f64) -> Option<(Tree, Vec<Strength>)> {
river_tree_weighted(spot, hero_combos, villain_combos, None, pot, bet)
@@ -721,6 +728,12 @@ pub fn river_mix(spot: &Spot) -> Option<RiverPlan> {
/// thin read. `None` outside the v1 slice or below the confidence floor, so the caller keeps the
/// heuristic.
pub fn river_exploit_mix(spot: &Spot) -> Option<RiverPlan> {
let (list, profile) = belief_combos(spot)?;
river_exploit_plan(spot, &list, profile.as_ref())
}
/// The villain's believed river range from the raw (ungated) read, and his profile; heads-up river only.
pub(crate) fn belief_combos(spot: &Spot) -> Option<(Vec<Vec<Card>>, Option<Profile>)> {
if spot.street != Street::River {
return None;
}
@@ -728,7 +741,7 @@ pub fn river_exploit_mix(spot: &Spot) -> Option<RiverPlan> {
return None;
}
let villain = spot.live_villains().next()?;
let profile = villain.profile.as_ref();
let profile = villain.profile;
let rules = spot.rules();
let filter = crate::engine::range_filter::range_filter(
&crate::exploit::range_model::range_spec(spot, villain),
@@ -738,7 +751,7 @@ pub fn river_exploit_mix(spot: &Spot) -> Option<RiverPlan> {
);
let dead: Vec<Card> = spot.hero_cards.iter().chain(&spot.board).copied().collect();
let list = crate::engine::range_combos::combos(&rules, &filter, &dead)?;
river_exploit_plan(spot, &list, profile)
Some((list, profile))
}
// --- The full river game (A.1): position, several sizes, raises, hero's own range. ---
+6
View File
@@ -28,6 +28,9 @@ const WEAK_PLAYER: Profile = Profile {
aggression_confidence: None,
river_bluff_share: None,
river_bluff_shown: None,
flop_aggression: None,
fold_to_steal: None,
fold_to_raise: None,
};
fn prior(mark: &str) -> Option<Profile> {
@@ -60,5 +63,8 @@ pub fn with_mark(measured: Option<Profile>, mark: &str) -> Option<Profile> {
aggression_confidence: known.aggression_confidence,
river_bluff_share: known.river_bluff_share,
river_bluff_shown: known.river_bluff_shown,
flop_aggression: known.flop_aggression,
fold_to_steal: known.fold_to_steal,
fold_to_raise: known.fold_to_raise,
})
}
+6
View File
@@ -68,6 +68,12 @@ pub struct Profile {
pub river_bluff_share: Option<f64>,
/// How many river bets/raises `river_bluff_share` rests on.
pub river_bluff_shown: Option<f64>,
/// Aggression frequency on the FLOP only (memory handover `reads.flopAggression`). `None` without it.
pub flop_aggression: Option<f64>,
/// How often the player, in a blind, folds to a steal raise (`reads.foldToSteal`).
pub fold_to_steal: Option<f64>,
/// How often the player folds after betting/raising a postflop street and being raised (`reads.foldToRaise`).
pub fold_to_raise: Option<f64>,
}
/// Equity vs a random hand on the river below which a shown river bet counts as air (a bluff): the
+1 -1
View File
@@ -92,7 +92,7 @@ impl RangeRead {
let fold_pooled = ok(p.fold_to_bet);
Some(RangeRead {
tilt,
aggression_ratio: [ratio(None), ratio(p.turn_aggression), ratio(p.river_aggression)],
aggression_ratio: [ratio(p.flop_aggression), ratio(p.turn_aggression), ratio(p.river_aggression)],
shown,
fold: [0, 1, 2].map(|i| ok(p.street_fold_to_bet[i]).or(fold_pooled).map(|f| f.clamp(0.0, 1.0))),
confidence,
+6
View File
@@ -39,6 +39,9 @@ pub const PRIOR: Profile = Profile {
aggression_confidence: None,
river_bluff_share: None,
river_bluff_shown: None,
flop_aggression: None,
fold_to_steal: None,
fold_to_raise: None,
};
/// Postflop moves at which an aggression read and the population weigh the same — the session
@@ -87,6 +90,9 @@ pub fn shrink(profile: &Profile, hands: f64) -> Profile {
aggression_confidence: profile.aggression_confidence,
river_bluff_share: profile.river_bluff_share,
river_bluff_shown: profile.river_bluff_shown,
flop_aggression: profile.flop_aggression,
fold_to_steal: profile.fold_to_steal,
fold_to_raise: profile.fold_to_raise,
}
}
+13 -4
View File
@@ -159,8 +159,15 @@ pub fn advise(spot: &Spot, thresholds: &Thresholds) -> PreflopPlan {
/// `advise` with an ICM open-jam widening factor (`>= 1`, `1.0` = neutral). The tournament entry
/// (`engine::decide`) passes the bubble factor (`icm::risk::jam_width_factor`); cash passes `1.0`.
pub fn advise_widened(spot: &Spot, thresholds: &Thresholds, jam_widen: f64) -> PreflopPlan {
advise_widened_read(spot, None, thresholds, jam_widen)
}
/// `advise_widened` with the RAW (ungated) spot: an opener the read gate plays blind may still be
/// light-3-bet on its trust-bounded fold-to-3-bet read (`engine::read_exploit`, switch GEGNER_BREIT).
/// `raw = None` (or the switch off) is exactly `advise_widened`.
pub fn advise_widened_read(spot: &Spot, raw: Option<&Spot>, thresholds: &Thresholds, jam_widen: f64) -> PreflopPlan {
let situation = situation_of(spot);
light_three_bet(spot, situation, advise_chart(spot, thresholds, jam_widen))
light_three_bet(spot, raw, situation, advise_chart(spot, thresholds, jam_widen))
}
/// A light 3-bet re-raises to this multiple of the open.
@@ -177,7 +184,7 @@ const LIGHT_THREE_BET_BAND: f64 = 0.85;
/// (+ `LIGHT_THREE_BET_EDGE`) for a 3-bet to `LIGHT_THREE_BET_MULT`× the open, and a called 3-bet
/// still has the hand's equity — against a folder that beats flatting. Only heads-up against the
/// lone opener with a fold-to-3-bet read, full-shape games. Everything else stays as the chart says.
fn light_three_bet(spot: &Spot, situation: Situation, plan: PreflopPlan) -> PreflopPlan {
fn light_three_bet(spot: &Spot, raw: Option<&Spot>, situation: Situation, plan: PreflopPlan) -> PreflopPlan {
let candidate = match plan.action {
ChartAction::Call => true,
ChartAction::Fold => plan.percentile <= LIGHT_THREE_BET_BAND,
@@ -191,7 +198,9 @@ fn light_three_bet(spot: &Spot, situation: Situation, plan: PreflopPlan) -> Pref
if line::opener(&spot.history) != Some(v.seat) {
return plan;
}
let Some(f3) = v.profile.and_then(|p| p.fold_to_three_bet).filter(|f| !f.is_nan()) else { return plan };
let gated = v.profile.and_then(|p| p.fold_to_three_bet).filter(|f| !f.is_nan());
let bounded = || raw.and_then(|r| crate::engine::read_exploit::fold_to_three_bet(r, v.seat));
let Some(f3) = gated.or_else(bounded) else { return plan };
let hero_in = spot
.history
.iter()
@@ -209,7 +218,7 @@ fn light_three_bet(spot: &Spot, situation: Situation, plan: PreflopPlan) -> Pref
}
PreflopPlan {
action: ChartAction::Raise,
reason: format!("{} | light 3-bet: fold to 3-bet {f3:.2} > {need:.2} needed", plan.reason),
reason: format!("{} | {}light 3-bet: fold to 3-bet {f3:.2} > {need:.2} needed", plan.reason, if gated.is_some() { "" } else { "breit:3: " }),
..plan
}
}
+3
View File
@@ -348,6 +348,9 @@ impl SessionMemory {
check_raise,
river_bluff_share: river_bluff.map(|(s, _)| s),
river_bluff_shown: river_bluff.map(|(_, n)| n as f64),
flop_aggression: None,
fold_to_steal: None,
fold_to_raise: None,
vpip: ratio(self.c.vpip, self.c.hands),
pfr: ratio(self.c.pfr, self.c.hands),
fold_to_bet: ratio(self.c.folded_to_bet, facing_bet),
+140 -1
View File
@@ -39,6 +39,10 @@ fn profile(villain: &Value, path: &str) -> Result<Option<Profile>, Fault> {
// own count (`engine::river_subgame::river_bluff_aggression`).
river_bluff_share: opt_number_member(object, &at_profile, "riverBluffShare")?,
river_bluff_shown: opt_number_member(object, &at_profile, "riverBluffShown")?,
// Only from the memory handover (`reads`, below).
flop_aggression: None,
fold_to_steal: None,
fold_to_raise: None,
};
// `hands` (extension, exploit::sample): with it, few hands count little
let shrunk = match opt_number_member(object, &at_profile, "hands")? {
@@ -51,7 +55,142 @@ fn profile(villain: &Value, path: &str) -> Result<Option<Profile>, Fault> {
Some(actions) => shrink_aggression(shrunk, raw.aggression, actions),
None => shrunk,
};
streets(object, &at_profile, pooled).map(Some)
let lined = streets(object, &at_profile, pooled)?;
with_reads(object, &at_profile, lined).map(Some)
}
/// One counted read of the memory handover (`profile.reads.<name>`, FORMAT-gegner-uebergabe):
/// `n` chances, `k` hits, optional hierarchical `prior` `[α, β]`.
struct CountedRead {
n: f64,
k: f64,
prior: Option<(f64, f64)>,
}
impl CountedRead {
/// Posterior mean `(k + α) / (n + α + β)`; without a `prior` the core's anchor at `strength`
/// pseudo-chances. `None` without a chance or a usable anchor.
fn posterior(&self, anchor: Option<f64>, strength: f64) -> Option<f64> {
if !(self.n > 0.0) {
return None;
}
let (a, b) = match self.prior {
Some(ab) => ab,
None => {
let m = anchor.filter(|m| m.is_finite())?.clamp(0.0, 1.0);
(m * strength, (1.0 - m) * strength)
}
};
let total = self.n + a + b;
(total > 0.0).then(|| ((self.k + a) / total).clamp(0.0, 1.0))
}
/// The read's own confidence `n / (n + α + β)` (prior strength or `strength`).
fn confidence(&self, strength: f64) -> f64 {
let s = self.prior.map_or(strength, |(a, b)| a + b);
if self.n > 0.0 { self.n / (self.n + s) } else { 0.0 }
}
}
fn counted(reads: &Value, path: &str, name: &str) -> Result<Option<CountedRead>, Fault> {
let Some(r) = optional(reads, path, name)? else { return Ok(None) };
let at_read = join(path, name);
let (Some(n), Some(k)) = (opt_number_member(r, &at_read, "n")?, opt_number_member(r, &at_read, "k")?) else {
return Ok(None);
};
if !(n.is_finite() && k.is_finite()) || n <= 0.0 || k < 0.0 || k > n {
return Ok(None);
}
let prior = match opt_items_member(r, &at_read, "prior")? {
Some([Value::Number(a), Value::Number(b)]) if *a > 0.0 && *b > 0.0 => Some((*a, *b)),
_ => None,
};
Ok(Some(CountedRead { n, k, prior }))
}
/// Pseudo-chances of the core's own anchor for a line read without a delivered prior.
const LINE_PRIOR: f64 = 15.0;
/// Population anchors of reads that have none in `sample::PRIOR`.
const CBET_ANCHOR: f64 = 0.60;
const THREE_BET_ANCHOR: f64 = 0.07;
const STEAL_ANCHOR: f64 = 0.35;
const FOLD_TO_STEAL_ANCHOR: f64 = 0.65;
const FOLD_TO_RAISE_ANCHOR: f64 = 0.45;
/// `reads` (extension, the memory handover `lesen/uebergabe.py`, switch GEGNER_GEDAECHTNIS): counted
/// reads with their true sample replace the HUD/shrunk rates, one posterior per read; the confidences
/// rise to the counted samples. Absent or empty: the profile unchanged (bit-identical).
fn with_reads(object: &Value, path: &str, p: Profile) -> Result<Profile, Fault> {
let Some(reads) = optional(object, path, "reads")? else { return Ok(p) };
let path = &join(path, "reads");
let get = |name: &str| counted(reads, path, name);
let mut out = p;
let pr = crate::exploit::sample::PRIOR;
if let Some(r) = get("vpip")? {
out.vpip = r.posterior(pr.vpip, crate::exploit::sample::PRIOR_HANDS).or(out.vpip);
let c = r.confidence(crate::exploit::sample::PRIOR_HANDS);
out.confidence = Some(out.confidence.unwrap_or(0.0).max(c));
}
if let Some(r) = get("pfr")? {
out.pfr = r.posterior(pr.pfr, crate::exploit::sample::PRIOR_HANDS).or(out.pfr);
}
if let Some(r) = get("foldToBet")? {
out.fold_to_bet = r.posterior(pr.fold_to_bet, crate::exploit::sample::PRIOR_HANDS).or(out.fold_to_bet);
}
if let Some(r) = get("aggression")? {
out.aggression = r.posterior(pr.aggression, crate::exploit::sample::AGGRESSION_HALF).or(out.aggression);
out.aggression_confidence = Some(r.confidence(crate::exploit::sample::AGGRESSION_HALF));
}
let pooled_aggr = out.aggression;
if let Some(r) = get("flopAggression")? {
out.flop_aggression = r.posterior(pooled_aggr, crate::exploit::sample::STREET_PRIOR);
}
if let Some(r) = get("turnAggression")? {
out.turn_aggression = r.posterior(pooled_aggr, crate::exploit::sample::STREET_PRIOR).or(out.turn_aggression);
}
if let Some(r) = get("riverAggression")? {
out.river_aggression = r.posterior(pooled_aggr, crate::exploit::sample::STREET_PRIOR).or(out.river_aggression);
}
let pooled_fold = out.fold_to_bet;
for (i, name) in ["flopFoldToBet", "turnFoldToBet", "riverFoldToBet"].iter().enumerate() {
if let Some(r) = get(name)? {
out.street_fold_to_bet[i] = r.posterior(pooled_fold, crate::exploit::sample::STREET_PRIOR).or(out.street_fold_to_bet[i]);
}
}
let fold_anchor = pooled_fold.or(Some(crate::exploit::fold_chance::DEFAULT_FOLD_TO_BET));
if let Some(r) = get("foldToCbet")? {
out.fold_to_cbet = r.posterior(fold_anchor, LINE_PRIOR).or(out.fold_to_cbet);
}
if let Some(r) = get("foldToThreeBet")? {
out.fold_to_three_bet = r.posterior(Some(FOLD_TO_THREE_BET_ANCHOR), LINE_PRIOR).or(out.fold_to_three_bet);
}
if let Some(r) = get("checkRaise")? {
out.check_raise = r.posterior(Some(CHECK_RAISE_ANCHOR), crate::exploit::sample::CHECK_RAISE_KAPPA).or(out.check_raise);
}
if let Some(r) = get("cbet")? {
out.cbet = r.posterior(Some(CBET_ANCHOR), LINE_PRIOR).or(out.cbet);
}
if let Some(r) = get("threeBet")? {
out.three_bet = r.posterior(Some(THREE_BET_ANCHOR), LINE_PRIOR).or(out.three_bet);
}
if let Some(r) = get("steal")? {
out.steal = r.posterior(Some(STEAL_ANCHOR), LINE_PRIOR).or(out.steal);
}
// The three reads counted since 14.11. (gedaechtnis-voll 9b37738), anchors as eichung.MOTOR.
if let Some(r) = get("foldToSteal")? {
out.fold_to_steal = r.posterior(Some(FOLD_TO_STEAL_ANCHOR), crate::exploit::sample::PRIOR_HANDS);
}
if let Some(r) = get("foldToRaise")? {
out.fold_to_raise = r.posterior(Some(FOLD_TO_RAISE_ANCHOR), LINE_PRIOR);
}
// Shown river bets: raw share and count (the river gearbox blends them by their own count).
if let Some(r) = get("riverBluffShown")? {
if out.river_bluff_shown.is_none() {
out.river_bluff_share = Some(r.k / r.n);
out.river_bluff_shown = Some(r.n);
}
}
Ok(out)
}
/// Share of a HUD's hands in which the player faces a c-bet / a 3-bet after opening / a bet after
+104
View File
@@ -0,0 +1,104 @@
//! Breite Ausnutzung (`engine::read_exploit`, Schalter GEGNER_BREIT): ein Read, den der Riegel blind
//! spielt (Nit, Reg, Maniac), darf nur ueber wenige, begrenzte Kanaele wirken. Hier: der C-Bet-Druck
//! gegen einen Folder und das Bluff-Veto gegen einen Caller, je am konkreten Spot; Station und Schalter
//! aus lassen die Entscheidung unberuehrt.
use rechner::card::Card;
use rechner::engine::read_exploit::{postflop_with, Channels};
use rechner::exploit::profile::Profile;
use rechner::game::{ActionKind, ActionRecord, Choice, Decision, SeenAction, Spot, Street, Villain};
use rechner::read::hand_read::read;
use rechner::variant::Variant;
fn rec(street: Street, seat: u8, action: SeenAction, amount: Option<f64>) -> ActionRecord {
ActionRecord { street, seat, action, amount }
}
/// Heads-up flop, hero (seat 0) raised preflop, villain (seat 1) called and checked the flop.
fn flop(hero: &str, profile: Option<Profile>) -> Spot {
Spot {
variant: Variant::Nlhe,
big_blind: 1.0,
seats: 2,
hero_seat: 0,
button_seat: Some(0),
hero_cards: Card::parse_list(hero).unwrap(),
board: Card::parse_list("Kc 8d 3s").unwrap(),
street: Street::Flop,
pot: 6.0,
to_call: 0.0,
hero_stack: 97.0,
min_raise_to: Some(1.0),
max_raise_to: Some(97.0),
legal: vec![ActionKind::Check, ActionKind::Raise],
allowed_sizes: None,
villains: vec![Villain { seat: 1, stack: 97.0, folded: false, profile }],
seed: 7,
history: vec![
rec(Street::Preflop, 0, SeenAction::Raise, Some(3.0)),
rec(Street::Preflop, 1, SeenAction::Call, Some(3.0)),
rec(Street::Flop, 1, SeenAction::Check, None),
],
}
}
fn nit(fold_to_cbet: f64, confidence: f64) -> Option<Profile> {
Some(Profile {
vpip: Some(0.14),
pfr: Some(0.11),
fold_to_bet: Some(0.70),
aggression: Some(0.25),
fold_to_cbet: Some(fold_to_cbet),
confidence: Some(confidence),
..Profile::default()
})
}
fn decision(choice: Choice, equity: f64) -> Decision {
Decision::new(choice, 0.6, "heuristic").with_equity(equity)
}
#[test]
fn ein_sicherer_cbet_folder_bekommt_die_kleine_cbet() {
let spot = flop("7h 6h", nit(0.85, 0.8));
let hand = read(&spot.rules(), &spot.hero_cards, &spot.board).unwrap();
let ch = Channels::parse("c");
let d = postflop_with(ch, &spot, &hand, decision(Choice::Check, 0.2));
match d.choice {
Choice::Raise { to } => assert!(to > 0.0 && to <= 0.5 * spot.pot, "small c-bet, got {to}"),
other => panic!("expected a c-bet, got {other:?}"),
}
assert!(d.reason.starts_with("breit:c"));
// Schalter aus, duenner Read, Station: unberuehrt.
let base = decision(Choice::Check, 0.2);
assert_eq!(postflop_with(Channels::default(), &spot, &hand, base.clone()), base);
let thin = flop("7h 6h", nit(0.85, 0.1));
assert_eq!(postflop_with(ch, &thin, &hand, base.clone()), base);
let station = flop(
"7h 6h",
Some(Profile { vpip: Some(0.6), pfr: Some(0.05), fold_to_bet: Some(0.2), fold_to_cbet: Some(0.85), confidence: Some(0.9), ..Profile::default() }),
);
assert_eq!(postflop_with(ch, &station, &hand, base.clone()), base);
}
#[test]
fn gegen_einen_sicheren_caller_kein_reiner_bluff() {
let caller = Some(Profile {
vpip: Some(0.26),
pfr: Some(0.2),
fold_to_bet: Some(0.15),
aggression: Some(0.5),
fold_to_cbet: Some(0.15),
confidence: Some(0.9),
..Profile::default()
});
let spot = flop("5h 4d", caller);
let hand = read(&spot.rules(), &spot.hero_cards, &spot.board).unwrap();
let bet = decision(Choice::Raise { to: 4.0 }, 0.15);
let d = postflop_with(Channels::parse("b"), &spot, &hand, bet.clone());
assert_eq!(d.choice, Choice::Check, "{}", d.reason);
assert!(d.reason.starts_with("breit:b"));
// Gegen einen Folder bleibt der Bluff.
let folder = flop("5h 4d", nit(0.85, 0.9));
assert_eq!(postflop_with(Channels::parse("b"), &folder, &hand, bet.clone()), bet);
}
+24
View File
@@ -343,3 +343,27 @@ fn hud_line_stats_rest_on_their_spots_not_on_all_hands() {
assert!((q.fold_to_three_bet.unwrap() - (0.9 * n3 + 15.0 * 0.55) / (n3 + 15.0)).abs() < 1e-12);
assert!(q.check_raise.unwrap() < 0.2, "10 chances barely move it off 0.08");
}
/// The memory handover (`profile.reads`, FORMAT-gegner-uebergabe): counted reads with their true sample
/// replace the HUD rates as posteriors; a delivered `prior` wins over the core's anchor; confidence
/// rises to the counted sample; extra fields (`post`, `prior_d2`, ...) are ignored; no `reads` = as before.
#[test]
fn memory_reads_become_posteriors() {
let hud = r#""villains":[{"seat":1,"stack":50,"folded":false,"profile":{"vpip":0.3,"foldToBet":0.6,"hands":24}}]"#;
let base = run(&plus(hud)).unwrap().villains[0].profile.unwrap();
let empty = r#""villains":[{"seat":1,"stack":50,"folded":false,"profile":{"vpip":0.3,"foldToBet":0.6,"hands":24,"reads":{}}}]"#;
assert_eq!(run(&plus(empty)).unwrap().villains[0].profile.unwrap(), base);
let counted = r#""villains":[{"seat":1,"stack":50,"folded":false,"profile":{"vpip":0.3,"foldToBet":0.6,"hands":24,
"reads":{"vpip":{"n":443,"k":85,"prior_d2":[3.25,6.79],"post":0.195},
"foldToThreeBet":{"n":20,"k":16,"prior":[5.5,4.5]},
"foldToCbet":{"n":30,"k":3},
"aggression":{"n":60,"k":30}}}}]"#;
let p = run(&plus(counted)).unwrap().villains[0].profile.unwrap();
assert!((p.vpip.unwrap() - (85.0 + 0.28 * 30.0) / 473.0).abs() < 1e-12, "core anchor, prior_d2 ignored");
assert!((p.fold_to_three_bet.unwrap() - 21.5 / 30.0).abs() < 1e-12, "delivered prior wins");
assert!(p.fold_to_cbet.unwrap() < 0.3, "a counted non-folder overrides the HUD");
assert!((p.aggression.unwrap() - (30.0 + 0.35 * 30.0) / 90.0).abs() < 1e-12);
assert!((p.aggression_confidence.unwrap() - 60.0 / 90.0).abs() < 1e-12);
assert!((p.confidence.unwrap() - 443.0 / 473.0).abs() < 1e-12);
}