Files
pokerfreak/messung/aof/hu_schaetzung.py
T
mmintelandClaude Opus 5.5 be9472e2c6 Sammler watches All-In-or-Fold tables: measure AoF rake and pool without money
A model of the 8 BB blind battle (messung/aof/SCHAETZUNG.md) says AoF only pays against a
pool that plays clearly too tight: the micro rake takes 0.8 BB from every called shove, so
Nash against Nash loses about 0.2 BB per duel. Before risking money we need the real rake,
the pool's shove and call widths and the traffic.

The sammler already watches tables without sitting. It now has a second format:
--format aof opens only real-money AoF hold'em tables; stages are named AOF25 etc., kept
apart from NL25 (same big blind exists in both). The lobby count always lists AoF stages,
and hands from AoF tables are filed under AOF25 so they never mix into the cash analyses.

Spec: tests/sammler_aof_spec.py. Not run live yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 10:44:37 +01:00

193 lines
7.6 KiB
Python

#!/usr/bin/env python3
"""Schaetzung: was AoF im Blindduell (SB gegen BB, 8 BB) einbringen kann - Modell, keine Messung.
Zweck (plans/2026-11-25_aof.md, Schritt 2): die Groessenordnung des Gewinns, bevor ein Korpus da
ist. Gerechnet wird nur das Heads-up-Teilspiel, das an einem 4er-Tisch entsteht, wenn CO und BTN
folden. Equity aus dem Kern (`src/cfr/generated_equity.rs`, 169x169, 60 000 Boards je Paar).
Vereinfachungen (offen benannt):
* Klassenebene: Kartenentfernung zwischen den zwei Haenden wird ignoriert (Gewicht 6/4/12 je
Klasse, unabhaengig gezogen). Fehler im Nash-EV typisch < 0,01 BB.
* Rake: Mikro-Regel des Cash-Tisches (messung/rake/BERICHT.md: 5 % auf den Cent, Deckel 10 BB,
Toepfe ab 0,11 $ zahlen, kein "no flop no drop"). Ob AoF dieselbe Regel hat, misst Schritt 2.
Variante "ohne Fold-Rake": ein nicht gecallter Push zahlt nichts.
* Gegner-Profile sind Annahmen (Schwellen in Prozent der Haende), nicht gemessen.
python3 messung/aof/hu_schaetzung.py > messung/aof/SCHAETZUNG.md
"""
import os
import re
WURZEL = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
N = 169
STAPEL_BB = 8.0
SB_BB, BB_BB = 0.5, 1.0
BB_DOLLAR = 0.25 # 17th-TX AOF 0.10-0.25 (betrieb/scratch/zustand.json)
RAKE_ANTEIL = 0.05
RAKE_DECKEL_BB = 10.0
RAKE_AB_DOLLAR = 0.11
ITERATIONEN = 4000
def equity_tabelle():
text = open(os.path.join(WURZEL, "src", "cfr", "generated_equity.rs")).read()
roh = text.split("TRIANGLE", 1)[1]
werte = [int(x) for x in re.findall(r"\d+", roh.split("[", 2)[2].split("]")[0])]
assert len(werte) == N * (N + 1) // 2, len(werte)
e = [[0.5] * N for _ in range(N)]
k = 0
for i in range(N):
for j in range(i, N):
e[i][j] = werte[k] / 10000.0
e[j][i] = 1.0 - e[i][j]
k += 1
return e
def gewichte():
w = []
for c in range(N):
zeile, spalte = divmod(c, 13)
w.append(6.0 if zeile == spalte else (4.0 if zeile > spalte else 12.0))
s = sum(w)
return [x / s for x in w]
def name(c):
r = "23456789TJQKA"
zeile, spalte = divmod(c, 13)
if zeile == spalte:
return r[zeile] * 2
hoch, tief, s = (zeile, spalte, "s") if zeile > spalte else (spalte, zeile, "o")
return r[hoch] + r[tief] + s
def rake(topf_bb, fold_rake=True, fold=False):
if fold and not fold_rake:
return 0.0
if topf_bb * BB_DOLLAR < RAKE_AB_DOLLAR:
return 0.0
cent = round(topf_bb * BB_DOLLAR * RAKE_ANTEIL, 2)
return min(cent / BB_DOLLAR, RAKE_DECKEL_BB)
class Spiel:
def __init__(self, fold_rake=True):
self.e, self.w = equity_tabelle(), gewichte()
topf = 2 * STAPEL_BB
self.r_call = rake(topf)
self.r_fold = rake(SB_BB + BB_BB, fold_rake, fold=True)
self.topf = topf
# Auszahlungen als Chip-Aenderung gegenueber dem Handbeginn (BB)
def sb_push_ev(self, i, call):
"""EV eines SB-Push mit Klasse i gegen die Call-Wahrscheinlichkeiten `call[j]` des BB."""
ev = 0.0
for j in range(N):
gecallt = self.e[i][j] * (self.topf - self.r_call) - STAPEL_BB
gefoldet = BB_BB - self.r_fold
ev += self.w[j] * (call[j] * gecallt + (1 - call[j]) * gefoldet)
return ev
def bb_call_ev(self, j, push):
"""EV eines BB-Calls mit Klasse j (gegen die Push-Range), relativ zum Fold (-1 BB)."""
masse = sum(self.w[i] * push[i] for i in range(N))
if masse == 0:
return 0.0
ev = sum(self.w[i] * push[i] * (self.e[j][i] * (self.topf - self.r_call) - STAPEL_BB)
for i in range(N)) / masse
return ev - (-BB_BB)
def beste_push(self, call):
return [1.0 if self.sb_push_ev(i, call) > -SB_BB else 0.0 for i in range(N)]
def beste_call(self, push):
return [1.0 if self.bb_call_ev(j, push) > 0 else 0.0 for j in range(N)]
def nash(self):
"""Fiktives Spiel: Mittel der besten Antworten (konvergiert im Zwei-Spieler-Nullsummen-Fall
bis auf den Rake, der beide gleich trifft)."""
push, call = [0.5] * N, [0.5] * N
for t in range(1, ITERATIONEN + 1):
bp, bc = self.beste_push(call), self.beste_call(push)
a = 1.0 / (t + 1)
push = [p + a * (b - p) for p, b in zip(push, bp)]
call = [c + a * (b - c) for c, b in zip(call, bc)]
return push, call
def ev_sb(self, push, call):
return sum(self.w[i] * (push[i] * self.sb_push_ev(i, call) + (1 - push[i]) * -SB_BB)
for i in range(N))
def ev_bb(self, push, call):
"""EV des BB (Chip-Aenderung) gegen die Push-Range."""
ev = 0.0
for i in range(N):
for j in range(N):
p = self.w[i] * self.w[j]
if not push[i]:
ev += p * SB_BB
continue
gecallt = self.e[j][i] * (self.topf - self.r_call) - STAPEL_BB
ev += p * push[i] * (call[j] * gecallt + (1 - call[j]) * -BB_BB)
ev += p * (1 - push[i]) * SB_BB
return ev
def schwelle(anteil, e, w):
"""Range der besten `anteil` Haende (nach Equity gegen eine Zufallshand)."""
staerke = sorted(range(N), key=lambda c: -sum(w[j] * e[c][j] for j in range(N)))
out, masse = [0.0] * N, 0.0
for c in staerke:
if masse >= anteil:
break
out[c], masse = 1.0, masse + w[c]
return out
def anteil(r, w):
return sum(x * y for x, y in zip(r, w))
def main():
for fold_rake in (True, False):
s = Spiel(fold_rake)
push, call = s.nash()
e, w = s.e, s.w
print(f"\n## Rake {'auch auf nicht gecallte Pushes' if fold_rake else 'nur auf gecallte Toepfe'}"
f" (Push-Topf {s.r_call:.2f} BB, Fold-Topf {s.r_fold:.2f} BB)\n")
print(f"Nash: SB pusht {anteil(push, w):.0%}, BB callt {anteil(call, w):.0%}.")
sb, bb = s.ev_sb(push, call), s.ev_bb(push, call)
print(f"Nash gegen Nash: SB {sb:+.3f} BB, BB {bb:+.3f} BB je Duell; Rake je Duell "
f"{-(sb + bb):.3f} BB.\n")
profile = {
"SB pusht eng (30 %)": ("sb", schwelle(0.30, e, w)),
"SB pusht weit (80 %)": ("sb", schwelle(0.80, e, w)),
"SB pusht alles (100 %)": ("sb", [1.0] * N),
"BB callt eng (20 %)": ("bb", schwelle(0.20, e, w)),
"BB callt weit (50 %)": ("bb", schwelle(0.50, e, w)),
"BB callt sehr weit (70 %)": ("bb", schwelle(0.70, e, w)),
}
print("| Gegner (Annahme) | wir in | wir Nash | wir beste Antwort | Nash-Wert dieses Sitzes |")
print("|---|---|---|---|---|")
nash_sb, nash_bb = sb, bb
for titel, (rolle, r) in profile.items():
if rolle == "sb": # Gegner ist SB, wir sind BB
wir_nash = s.ev_bb(r, call)
wir_ba = s.ev_bb(r, s.beste_call(r))
print(f"| {titel} | BB | {wir_nash:+.3f} | {wir_ba:+.3f} | {nash_bb:+.3f} |")
else: # Gegner ist BB, wir sind SB
wir_nash = s.ev_sb(push, r)
wir_ba = s.ev_sb(s.beste_push(r), r)
print(f"| {titel} | SB | {wir_nash:+.3f} | {wir_ba:+.3f} | {nash_sb:+.3f} |")
if fold_rake:
print("\nNash-Push-Range SB (rein, > 50 %): "
+ " ".join(name(c) for c in range(N) if push[c] > 0.5 and name(c)[-1] != "o")[:400])
if __name__ == "__main__":
print("# AoF-Schaetzung: Blindduell SB gegen BB, 8 BB (Modell, keine Messung)")
print("\nWerte in BB je Duell (Chip-Aenderung gegenueber Handbeginn, nach Rake). Erzeugt von "
"`messung/aof/hu_schaetzung.py`.")
main()