Merge claude/budget-baum (1bddcac6) in Go-live-Buendel

Konflikte: decide.py (BEKANNTE_SCHALTER: ALLIN_KURVE + BUDGET), river3_spieler.rs/solver_kern.rs (zeit_stopp der Stuetzungs-Diagnose bleibt, BUDGET=baum-Schleife).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-21 02:45:12 +01:00
co-authored by Claude Opus 5.5
31 changed files with 835 additions and 16 deletions
+1 -1
View File
@@ -45,7 +45,7 @@ BEKANNTE_SCHALTER = ("FAUSTREGEL", "MDF_UNREAD", "RAISE_DRAWS", "RAISE_PRIOR", "
"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", "ALLIN_KURVE", "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", "ENTHALTUNG", "TURN_SPIEL_FOLD", "BETTOR_GROSS", "BETTOR_GROSS_TURN", "RANGES_ECHT", "KERN_RUECKFALL")
"TISCHWAHL", "TISCHWAHL_AB", "SITZWAHL", "GEGNER_GEDAECHTNIS", "ZEIGT_KIPP", "STATION_ZUG", "RAISE_FOLD_DECKEL", "STEAL_BREITE", "INFO_KONSISTENT", "EINSATZ_BLUFF", "WETT_KURVE", "UEBERWERT", "ENTHALTUNG", "TURN_SPIEL_FOLD", "BETTOR_GROSS", "BETTOR_GROSS_TURN", "RANGES_ECHT", "KERN_RUECKFALL", "BUDGET")
# 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
+93
View File
@@ -0,0 +1,93 @@
# BUDGET=baum: Rechenmenge aus der Baumgroesse statt aus der Uhr
Schalter `BUDGET=baum` (aus/unset = bitgleich zu heute; in `BEKANNTE_SCHALTER`). Code: `src/engine/baum.rs`, Einhaengepunkte in
`solver_kern.rs` (HU River/Turn/Flop), `multi3_spieler.rs` (MW Flop/Turn, Stufe), `river3_spieler.rs` (MW River), `frist.rs`
(Notbremse bleibt, zaehlt ihre Ausloesungen), `rueckfall.rs` (Zeit-Rueckfall), `turn_river_game.rs` (feste Kartenwahl).
## Was gilt
* Iterationen, River/Turn-Karten und MW-Stufe stehen VOR dem Solve fest, aus Baumgroesse und einem Kostenmodell (CPU-ms je Iteration,
gefittet auf fester Iterationszahl, nicht auf Uhrzeit). Die Kappen sind die heutigen Live-Kappen (HU River 1300 ms, Turn 900,
Flop 1000, MW `SOLVER3_MS`=300 bzw. Strassen-Rest), aber gegen das Modell statt gegen die Thread-CPU-Uhr.
* Kein Abbruch mitten im Solve nach Zeit. Keine Neuberechnung nach Zeitmessung. Notbremse (`KERN_NOTBREMSE_MS`) bleibt Sicherheitsnetz,
`frist::NOTBREMSE_ZAEHLER` zaehlt je Entscheidung; `kern_grund` meldet ihn auf stderr (`NOTBREMSE n`). Fixture: 0.
* "Uhr" innerhalb einer Entscheidung ist ein Konto vorhergesagter ms (`baum::konto`), z. B. fuer MW-Budget je Strasse, den
Notfall-Schwellwert, `tgstark=breit` (zweite Rechnung ab 900 ms) und den Zeit-Rueckfall.
## Kostenmodell (CPU-ms je Iteration; neu geeicht 21.11. auf `live_allein.txt`, Uhr-Lauf allein auf der Maschine)
| Art | ms/Iteration | Eichung |
|---|---|---|
| hu_river | 7.0e-6 x Knoten x (c0+c1) | Fit auf 35 Live-Loesungen, rel. Fehler 13 % |
| hu_turn (k River-Karten) | k x (3.8e-7 x c0 x c1 + 6.4e-6 x Knoten x (c0+c1)) | 57 Loesungen, 20 % |
| hu_flop (k Turn-Karten) | k x 7.5e-6 x Knoten x (c0+c1) | 99 Loesungen, 19 % |
| mw_flop / mw_turn / mw_river | {4.2e-5, 4.8e-5, 1.75e-5} x Spieler x Summe(Kombos) | Median-Verhaeltnis zur Live-Iterationszahl (die erste, auf ueberbuchter Maschine gefittete Fassung war 1.5-2.7x zu pessimistisch) |
Setup: HU 15 ms, MW 1.6e-3 ms je Knoten. Iterationen = floor((Kappe - Setup) / ms je Iteration), auf Vielfache 5 (HU) / 50 (MW) / 200 (MW River) abgerundet, mindestens Live-Minimum.
HU-Turn/Flop: Karten wie die Live-`eng`-Regel (zuerst min(16, 5.6e6/(c0 x c1)), dann bis zu dreimal verkleinern, wenn
20 Iterationen x 1.3 nicht in die Kappe passen), aber aus dem Modell, vor dem Aufbau (kein verlorener Aufbau).
MW: Stufe 1 (200 Kombos, volle Slots) wird uebersprungen, wenn 1000 Iterationen nicht passen; dann (100, Slots/2), dann (50, 2).
## Kartenwahl (Befund Jd8h)
Bisher: gleichmaessiger Schritt ueber das nach Farbe sortierte Deck -> bei kleinem k Farben/Raenge zufaellig ungleich, das Ergebnis
springt mit k (Jd8h: +0.19 / +0.23 / -0.14 bei 11 / 6 / 12 Karten). Neu unter baum (`karten_gleichmaessig`): Deck nach Rang
sortiert, Farbreihenfolge je Rang rotiert, dann gleichmaessiger Schritt; reine Funktion von Brett und k, gleiche Karten in gleicher
Reihenfolge; Zufallszahl pro Spot ist nicht noetig (keine Zufallswahl). Jd8h gegen 1.5 Topf (Call minus Fold in Toepfen, 38 Iterationen):
6 Karten -0.347, 11 -0.340, 16 -0.182, 24 +0.032, 44 (alle) +0.028: monoton, kein Springen; der Wert braucht aber ~24 Karten,
um beim Vollwert anzukommen (bei 16 bleibt es Fold).
Abstand gewaehlt/Vollwert (44 Karten, je 38 Iterationen), `messung/solver_kern/budget_baum/karten_ausw.txt`:
* 16 Kipp-Turn-Spots der Angriffs-Kippliste (aus dem Raster von `werkzeuge/kippliste.py`, ungelesen/gelesen):
gewaehlte Karten (11-16): gleiche Aktion 12/16, |Delta(Call-Fold)| Median 0.053, p90 0.380, max 0.451 Topf;
fest 6: 9/16 (Median 0.197), 11: 11/16, 16: 12/16 (Median 0.095), 24: 12/16 (0.062).
* 57 HU-Turn-Spots der Fixture: gewaehlte Karten (44x16, 5x7, 3x8, je 1x 4/5/9/10/12): gleiche Aktion 54/57,
|Delta(Call-Fold)| Median 0.057, p90 0.254, max 0.937; EV-Verlust der gewaehlten Aktion nach Vollwerten im Mittel 0.034 Topf,
p90 0.000, max 1.834 (ein 7-Karten-Fall); bei 16 Karten (44 Spots) EV-Verlust 0.000.
=> Kipp-Spots sind knappe Entscheidungen; 16 Karten reichen fuer typische Spots, nicht fuer Knappe. Hebel, falls gewuenscht: 24 Karten
(1.5x Rechnung dieser Baeume) oder Karten nach Knappheit nachfuellen; nicht eingebaut.
## Gates
* (a) gleicher Build, `BUDGET=baum`, Fixture 2x: 238/238 gleich (ms normiert), der zweite Lauf lief neben einem weiteren
kern_grund-Prozess (Kartenreihe): Lastunabhaengigkeit ok. Notbremse 0.
* (b) unset gegen `pokerbench-solverkern-grund-mess.exe`, beide mit `SOLVER_ZEIT=fest` (Uhr-Laeufe sind selbst nicht bitgleich): 238/238.
* (c) Tabelle unten. Der saubere Live-Uhr-Lauf steht aus (siehe unten).
## Ergebnis nach Neueichung (Fixture, `BUDGET=baum`)
* Gate (a): zwei Laeufe gleichzeitig (also unter Last, dazu andere Messungen auf der Maschine) 238/238 gleich, Notbremse 0.
* Gate (b): unset gegen mess-stand, beide `SOLVER_ZEIT=fest`: 238/238.
* Iterationen baum gegen Referenz (Median, Viertelgrenzen): HU River, Turn, Flop gegen `live_allein.txt` UND `it_neu1.txt`
(hu_*:100/40/40, mw 4050/4100/7200): exakt 1.00 (alle 191 HU-Loesungen gleich, Karten 16, bei breiten Baeumen die Live-eng-Karten).
MW Flop 0.98 (0.80-1.11) bzw. 1.00 (0.86-1.19), MW Turn 0.85 bzw. 0.76, MW River 0.89 bzw. 0.86.
MW Turn/River liegen etwas niedrig (Modellkonstanten dort auf 10 bzw. 5 Loesungen gefittet, Setup der grossen 4-Spieler-Baeume
ist nur grob modelliert); nicht weiter nachgezogen.
* Zeiten: die Neueichungs-Laeufe liefen auf einer wieder voll belegten Maschine (zwei eigene Laeufe parallel plus fremde Messungen,
Gesamt 309 s statt 86 s live solo). Die ms-Spalten von `vs_live.md` sind darum nicht vergleichbar; gueltig sind Iterationen und Karten.
Eine saubere Zeit-Spalte braucht einen Lauf allein (ca. 2 min, ein Prozess): `python lauf.py pokerbench-solverkern-budget-baum.exe x.txt BUDGET=baum`
danach `tab.py live_allein.txt x.txt live baum`. Gebaut ist die Obergrenze: HU Turn <= 900 ms, Flop <= 1000, River <= 1300, MW <= 300 ms Modell-CPU.
* Entscheidungen verschieden (von 238):
* baum (balancierte Karten) gegen live solo: 14 Aktionsart, 14 nur Groesse; gegen `it_neu1`: 15 / 13.
* baum mit `BAUM_WAHL=schritt` (alte Schritt-Kartenwahl, Messknopf): gegen `it_neu1` 3 (alle MW, Fold/Call/Raise, ohne EV-Ausgabe),
gegen live solo 3 (2 Art, 1 Groesse). => Die HU-Unterschiede stammen vollstaendig von der balancierten Kartenwahl, nicht vom Budget.
* Die Aktionsart-Kipps mit EV (HU, balanciert gegen live solo): Zeile 38 Call->Fold, EV Topf (fold/call) 2.43/2.47 -> 3.06/2.71;
62: 1.90/1.98 -> 3.20/2.43; 133: 1.96/1.99 -> 2.31/2.29; 231 Fold->Call 0.01/0.00 -> 0.00/0.07; dazu Flop/Turn-Raise gegen Check mit
Checkwert 0.2-3.2 (siehe `vs_live.md`/`vs_iter.md`, Zeilenliste). Das sind knappe Faelle, wie die Kartenauswertung oben zeigt.
* Entscheidung offen fuer den Orchestrator: balanciert (hier, bewiesen monoton, aber andere Schaetzung als live) oder `BAUM_WAHL`-Schritt
als Standard (fast live-identisch, hat aber das Jd8h-Springen).
## Kartenwahl entschieden: balanciert bleibt Standard (Kriterium: Naehe zum Vollwert)
Test (fest: `SOLVER_ITER=hu_turn:38,hu_flop:40`, beide Arme auf den von baum gewaehlten Karten, Referenz = alle Karten (44 Turn / 49 Flop),
EV-Verlust = bester Vollwert minus Vollwert der gespielten Aktion, nur Spots mit Wertliste; `wahl_ausw.txt`, `wahl_ausw.py`):
| Menge | balanciert: mittl. EV-Verlust / schlimmster / gleiche Aktion | Schritt: dito |
|---|---|---|
| Fixture HU Turn (57; 13/14 mit Wertliste; Karten 6/9/13/16) | 0.0000 / 0.000 / 13 von 13 | 0.0176 / 0.238 / 12 von 14 |
| Kipp Turn (16; 16 Karten) | 0.0369 / 0.353 / 12 von 16 | 0.0590 / 0.353 / 8 von 16 |
| Fixture HU Flop (99; 31 mit Wertliste; 16 Karten) | 0.0008 / 0.024 / 30 von 31 | 0.0171 / 0.507 / 29 von 31 |
Balanciert ist in allen drei Mengen niedriger oder gleich (schlimmster Fall der Kipp-Spots gleich). Es bleibt Standard; die
Schritt-Wahl bleibt als Messschalter `BAUM_WAHL=schritt`.
## Fenster fuer Gate (b) (12 Tische) und die Zeit-Solo-Messung (Schaetzung)
`latenz12_gruende.py <arm>` startet 12 Prozesse `kern_grund`, jeder die ganze 238-Zeilen-Fixture (2856 Entscheidungen, davon ~2400
postflop gezaehlt), alle gleichzeitig = 12 Tische parallel auf 12 von 32 Kernen. Dauer je Prozess ~ Solo-Dauer: live solo 86 s;
baum etwa gleich viel Rechenzeit, bei 12 parallelen mit Cache/Speicher-Konkurrenz 1.2-1.5x: ca. 2-2.5 min je Arm.
Es gibt keine fruehere Zeitmessung (`latenz12_ab.txt` ist leer). Gesamtfenster: Solo-Zeitlauf baum ca. 1.5-2 min + 12-Tische baum
ca. 2.5 min (+ 12-Tische live zum Vergleich ca. 2.5 min) = 4-5 min ohne, 7 min mit Live-Vergleich, allein auf der Maschine.
Das Skript ruft fest die Mess-exe `grund-mess` auf: fuer baum eine Kopie mit dem baum-exe und `BUDGET=baum` im Arm noetig (kleine Aenderung, nicht gemacht).
+3
View File
@@ -0,0 +1,3 @@
for k in - 6 11 16 24 44; do python vergl.py kipp_turn.jsonl kipp_k$k.txt $k; done
for k in - 44; do python vergl.py fixture_turn_hu.jsonl fix_k$k.txt $k; done
echo fertig > kipp_fertig.txt
+52
View File
@@ -0,0 +1,52 @@
import re,sys,statistics as st
def lies(f):
r=[]
for l in open(f,encoding='utf-8'):
p=l.rstrip('\n').split('\t')
m=re.search(r'(\d+) river cards, (\d+) iters',p[2]);
vals=re.search(r'\(pots\): (.*?)\] ->',p[2])
v={}
if vals:
for a,x in re.findall(r'(fold|call|check|raise to [\d.]+) ([+-][\d.]+)',vals.group(1)): v[a]=float(x)
act=re.search(r'-> (\w+)',p[2])
r.append(dict(k=int(m.group(1)) if m else None,it=int(m.group(2)) if m else None,v=v,act=act.group(1) if act else p[-1],ms=float(p[3])))
return r
def gap(x):
v=x['v']
if 'call' in v and 'fold' in v: return v['call']-v['fold']
return None
def best2(x):
s=sorted(x['v'].values(),reverse=True); return s[0]-s[1] if len(s)>1 else None
def vgl(a,b,name):
# a = gewaehlt, b = voll
n=len(a); same=sum(x['act']==y['act'] for x,y in zip(a,b))
dg=[abs(gap(x)-gap(y)) for x,y in zip(a,b) if gap(x) is not None and gap(y) is not None]
db=[abs(x['v'].get('call',0)-y['v'].get('call',0)) for x,y in zip(a,b)]
# EV loss: value (in b's values) of a's action vs best in b
loss=[]
for x,y in zip(a,b):
if y['v']:
best=max(y['v'].values())
ka=[k for k in y['v'] if k.startswith(x['act'].lower().split()[0])]
loss.append(best-(y['v'][ka[0]] if ka else min(y['v'].values())))
q=lambda v,p: sorted(v)[min(int(len(v)*p),len(v)-1)] if v else float('nan')
if not dg: dg=[0.0]
print(f"{name}: n={n} same action {same}/{n}; |dcall-fold| median {st.median(dg):.3f} p90 {q(dg,.9):.3f} max {max(dg):.3f}; EV loss of chosen action vs full-card values: mean {st.mean(loss):.3f} p90 {q(loss,.9):.3f} max {max(loss):.3f} (pots)")
if __name__=='__main__':
full=lies('kipp/kipp_k44.txt')
ks=[('-',None)]+[(k,k) for k in ('6','11','16','24')]
for k,_ in ks:
a=lies(f'kipp/kipp_k{k}.txt')
print('k',k,'cards',sorted(set(x['k'] for x in a)),end=' '); vgl(a,full,'Kipp turn')
ff=lies('kipp/fix_k44.txt'); fa=lies('kipp/fix_k-.txt')
from collections import Counter
print('fixture cards chosen',sorted(Counter(x['k'] for x in fa).items()), 'iters',sorted(Counter(x['it'] for x in fa).items()))
vgl(fa,ff,'Fixture HU turn')
# per k breakdown on fixture
for k in sorted(set(x['k'] for x in fa)):
idx=[i for i,x in enumerate(fa) if x['k']==k]
vgl([fa[i] for i in idx],[ff[i] for i in idx],f' fixture k={k}')
# Jd8h
print('Jd8h (id 3rd) call-fold by k:')
for k in ['-','6','11','16','24','44']:
a=lies(f'kipp/kipp_k{k}.txt'); print(' ',k,a[2]['k'],round(gap(a[2]),3),a[2]['act'],'| g-version',a[11]['k'],round(gap(a[11]),3),a[11]['act'])
+5
View File
@@ -0,0 +1,5 @@
import re,sys
def norm(f): return [re.sub(r"\d+(\.\d+)? ?ms","ms",re.sub(r"\t[0-9.]+\t","\t#\t",l.rstrip('\n'))) for l in open(f,encoding='utf-8')]
a,b=norm(sys.argv[1]),norm(sys.argv[2])
d=[i for i,(x,y) in enumerate(zip(a,b)) if x!=y]
print(len(a),len(b),'gleich',sum(x==y for x,y in zip(a,b)),'abw',d[:10])
@@ -0,0 +1,80 @@
#!/bin/bash
# Messfenster BUDGET=baum (allein auf der Maschine): 1) baum solo, 2) 12 Tische baum, 3) 12 Tische live (Uhr).
# Aufruf: bash fenster.sh (voll, ca. 7-8 min)
# FENSTER_TISCHE=2 FENSTER_KORPUS=<kleine.jsonl> FENSTER_AUS=<ordner> bash fenster.sh (Trockenlauf)
# Je Schritt Start und Ende in $AUS/fenster.log; am Ende eine Tabelle in $AUS/fenster_tabelle.txt (und auf stdout).
# Ein Aufruf = alles; Prozesse BelowNormal, nie mehr als TISCHE gleichzeitig.
export FENSTER_AUS="${FENSTER_AUS:-C:/Users/marcm/pokerfreak-solverkern/budget/fenster}"
export FENSTER_TISCHE="${FENSTER_TISCHE:-12}"
export FENSTER_KORPUS="${FENSTER_KORPUS:-D:/Projects/pokerfreak/.claude/worktrees/mess-stand/tests/live_fixture/abdeckung/echtgeld-2026-11-19.jsonl}"
export FENSTER_BAUM="${FENSTER_BAUM:-C:/Users/marcm/pokerfreak-solverkern/bin/pokerbench-solverkern-budget-baum.exe}"
export FENSTER_LIVE="${FENSTER_LIVE:-C:/Users/marcm/pokerfreak-solverkern/bin/pokerbench-solverkern-grund-mess.exe}"
export FENSTER_SCHALTER="${FENSTER_SCHALTER:-D:/Projects/pokerfreak/.claude/worktrees/mess-stand/betrieb/kern_schalter.txt}"
export FENSTER_LIVESOLO="${FENSTER_LIVESOLO:-C:/Users/marcm/pokerfreak-solverkern/budget/live_allein.txt}"
mkdir -p "$FENSTER_AUS"
python -I -X utf8 - <<'PY'
import os, re, statistics, subprocess, sys, time, datetime
AUS = os.environ["FENSTER_AUS"]; N = int(os.environ["FENSTER_TISCHE"]); KORPUS = os.environ["FENSTER_KORPUS"]
BAUM, LIVE, KS = os.environ["FENSTER_BAUM"], os.environ["FENSTER_LIVE"], os.environ["FENSTER_SCHALTER"]
LIVESOLO = os.environ["FENSTER_LIVESOLO"]
log = open(os.path.join(AUS, "fenster.log"), "a", encoding="utf-8")
def L(s):
z = "%s %s" % (datetime.datetime.now().strftime("%H:%M:%S"), s); print(z, flush=True); log.write(z + "\n"); log.flush()
def basis():
env = dict(os.environ)
for z in open(KS, encoding="utf-8"):
z = z.strip()
if z and not z.startswith("#") and "=" in z:
k, v = z.split("=", 1); env[k.strip()] = v.strip()
for k in ("SOLVER_ITER", "SOLVER_ZEIT", "BUDGET", "BAUM_KARTEN", "BAUM_WAHL"): env.pop(k, None)
env["KERN_GRUND_ZEIT"] = "1"; env["KERN_NOTBREMSE_MS"] = "8000" # wie die Live-Bruecke (decide.py)
return env
def lauf(name, exe, env, n):
L("START %s (%d Prozess(e))" % (name, n))
t = time.time(); ps = []
for i in range(n):
o = os.path.join(AUS, "%s_%02d.txt" % (name, i))
ps.append((o, subprocess.Popen([exe, KORPUS], env=env, stdout=open(o, "w", encoding="utf-8"), stderr=open(o + ".err", "w"), creationflags=0x4000)))
for o, p in ps: p.wait()
L("ENDE %s nach %.0f s" % (name, time.time() - t))
return [o for o, _ in ps]
norm = lambda f: [re.sub(r"\d+(\.\d+)? ?ms", "ms", re.sub(r"\t[0-9.]+\t", "\t#\t", l.rstrip("\n"))) for l in open(f, encoding="utf-8")]
def gleich(a, b):
x, y = norm(a), norm(b); return sum(p == q for p, q in zip(x, y)), max(len(x), len(y))
def zeiten(dateien):
d = {}
for f in dateien:
for l in open(f, encoding="utf-8"):
p = l.rstrip("\n").split("\t")
if len(p) >= 4 and not p[0].startswith("Preflop"):
try: d.setdefault("/".join(p[0].split("/")[:2]), []).append(float(p[3]))
except ValueError: pass
return d
eb = basis(); eb["BUDGET"] = "baum"
solo = lauf("baum_solo", BAUM, eb, 1)
t12b = lauf("baum_12", BAUM, eb, N)
t12l = lauf("live_12", LIVE, basis(), N)
def kopf(t): return "%-12s %5s %7s %7s %7s" % (t, "n", "mean", "p99", "max")
def stat(v):
v = sorted(v); return "%5d %7.0f %7.0f %7.0f" % (len(v), statistics.mean(v), v[max(int(len(v) * .99) - 1, 0)], v[-1])
out = []
for titel, dat in (("baum 12 Tische (ms je Entscheidung, Wand)", t12b), ("live 12 Tische (Uhr)", t12l)):
out.append(titel); z = zeiten(dat)
for k in sorted(z): out.append(" %-12s %s" % (k, stat(z[k])))
allv = [x for v in z.values() for x in v]; out.append(" %-12s %s" % ("alle", stat(allv)))
zs = zeiten(solo); out.append("baum solo");
for k in sorted(zs): out.append(" %-12s %s" % (k, stat(zs[k])))
nb = 0
for f in t12b + solo:
for l in open(f + ".err", encoding="utf-8", errors="replace"):
if l.startswith("NOTBREMSE"): nb += int(l.split("\t")[1])
out.append("Notbremse (baum, alle Laeufe zusammen): %d" % nb)
g = [gleich(f, solo[0]) for f in t12b]
out.append("baum-12 gegen baum-solo: Tische vollstaendig gleich %d/%d; Zeilen gleich je Tisch %s" % (sum(a == b for a, b in g), len(g), [a for a, _ in g]))
if os.path.exists(LIVESOLO):
g = [gleich(f, LIVESOLO) for f in t12l]
out.append("live-12 gegen live-solo (%s): Tische vollstaendig gleich %d/%d; Zeilen gleich je Tisch %s (Uhr-Lauf, kein Soll 238)" % (os.path.basename(LIVESOLO), sum(a == b for a, b in g), len(g), [a for a, _ in g]))
g = [gleich(f, t12b[0]) for f in t12b[1:]]
out.append("baum-12 Tisch 1 gegen die anderen: Zeilen gleich %s" % [a for a, _ in g])
txt = "\n".join(out); print(txt); open(os.path.join(AUS, "fenster_tabelle.txt"), "w", encoding="utf-8").write(txt + "\n"); L("FERTIG")
PY
+27
View File
@@ -0,0 +1,27 @@
import sys, re, json, os
W = r"D:\Projects\pokerfreak\.claude\worktrees\budget-baum"
sys.path.insert(0, os.path.join(W, "lesen"))
import importlib.util
spec = importlib.util.spec_from_file_location("kippliste", os.path.join(os.path.dirname(os.path.abspath(__file__)), "kippliste.py"))
kl = importlib.util.module_from_spec(spec)
kl.__file__ = os.path.join(W, "werkzeuge", "kippliste.py")
sys.modules["kippliste"] = kl
spec.loader.exec_module(kl)
md = open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "KIPPLISTE-allin-kurve.md"), encoding="utf-8").read()
# Turn-Eintraege: "TURN <linie>, <hand> <klasse> (<gegner>)"
ein = set()
for m in re.finditer(r"^- TURN (.+?), ([2-9TJQKA][shdc][2-9TJQKA][shdc]) \w+ \((\w+)\)", md, re.M):
ein.add((m.group(1), m.group(2), m.group(3)))
print(len(ein), "Kipp-Turn-Eintraege", file=sys.stderr)
out = []
for profil in (False, True):
for s in kl.postflop_spots(profil):
if not s["lage"].startswith("TURN "): continue
lin = s["lage"][5:]
g = "gelesen" if profil else "ungelesen"
if (lin, s["hand"], g) in ein:
out.append(s)
print(len(out), "Spots in der Raster", file=sys.stderr)
with open("kipp_turn.jsonl", "w", encoding="utf-8", newline="\n") as f:
for s in out: f.write(json.dumps({"id": s["id"], "req": s["req"]}) + "\n")
for s in out: print(s["id"])
@@ -0,0 +1,7 @@
Traceback (most recent call last):
File "C:\Users\marcm\pokerfreak-solverkern\budget\kipp\ausw.py", line 36, in <module>
full=lies('kipp/kipp_k44.txt')
File "C:\Users\marcm\pokerfreak-solverkern\budget\kipp\ausw.py", line 4, in lies
for l in open(f,encoding='utf-8'):
~~~~^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'kipp/kipp_k44.txt'
+6
View File
@@ -0,0 +1,6 @@
cd /c/Users/marcm/pokerfreak-solverkern/budget/kipp
python vergl.py fixture_turn_hu.jsonl w_fixt_bal.txt -
python vergl.py fixture_turn_hu.jsonl w_fixt_str.txt - schritt
python vergl.py kipp_turn.jsonl w_kipp_bal.txt -
python vergl.py kipp_turn.jsonl w_kipp_str.txt - schritt
echo done > kw1.done
+5
View File
@@ -0,0 +1,5 @@
cd /c/Users/marcm/pokerfreak-solverkern/budget/kipp
python vergl.py fixture_flop_hu.jsonl w_flop_bal.txt -
python vergl.py fixture_flop_hu.jsonl w_flop_str.txt - schritt
python vergl.py fixture_flop_hu.jsonl w_flop_full.txt 47
echo done > kw2.done
+18
View File
@@ -0,0 +1,18 @@
import os, re, subprocess, sys, time
# lauf.py <exe> <out> [KEY=VAL ...] : fixture run with kern_schalter env + KERN_GRUND_ZEIT=1, BelowNormal
exe, out = os.path.abspath(sys.argv[1]), os.path.abspath(sys.argv[2])
ks = r"D:\Projects\pokerfreak\.claude\worktrees\mess-stand\betrieb\kern_schalter.txt"
env = dict(os.environ)
for z in open(ks, encoding="utf-8"):
z = z.strip()
if z and not z.startswith("#") and "=" in z:
k, v = z.split("=", 1); env[k.strip()] = v.strip()
env["KERN_GRUND_ZEIT"] = "1"
env.pop("SOLVER_ITER", None); env.pop("BUDGET", None)
for a in sys.argv[3:]:
k, v = a.split("=", 1); env[k] = v
korpus = r"D:\Projects\pokerfreak\.claude\worktrees\mess-stand\tests\live_fixture\abdeckung\echtgeld-2026-11-19.jsonl"
t = time.time()
p = subprocess.Popen([exe, korpus], env=env, stdout=open(out, "w", encoding="utf-8"), stderr=open(out + ".err", "w"), creationflags=0x4000)
p.wait()
print("fertig", round(time.time() - t, 1), "s", out)
@@ -0,0 +1,4 @@
# Clean live baseline, run ALONE (other measurements paused): ~5 min single process.
cd /c/Users/marcm/pokerfreak-solverkern/budget
python lauf.py pokerbench-solverkern-budget-live.exe live_allein.txt SOLVER_ITER_LOG=1
python tab.py live_allein.txt baum2.txt live baum > live_vs_baum.md
+15
View File
@@ -0,0 +1,15 @@
import sys,collections
def lies(f):
r=[]
for l in open(f,encoding='utf-8'):
p=l.rstrip('\n').split('\t')
if len(p)>=4: r.append((p[0],float(p[3]),p[2],p[4] if len(p)>4 else ''))
return r
if __name__=='__main__':
for f in sys.argv[1:]:
d=collections.defaultdict(list)
for k,ms,_,_ in lies(f): d['/'.join(k.split('/')[:2])].append(ms)
print(f); tot=0
for k,v in sorted(d.items()):
v.sort(); tot+=sum(v); print(' ',k,len(v),'mean %.0f p99 %.0f max %.0f'%(sum(v)/len(v),v[max(int(len(v)*.99)-1,0)],v[-1]))
print(' total s %.0f'%(tot/1e3))
+45
View File
@@ -0,0 +1,45 @@
import re,sys,collections,statistics as st
def rd(f):
r=[]
for l in open(f,encoding='utf-8'):
p=l.rstrip('\n').split('\t'); r.append(p)
return r
def kind(p):
lg=p[0].split('/'); s=lg[0]+'/'+lg[1]
return s
def info(p):
m=re.search(r'(\d+) river cards, (\d+) iters',p[2]) or re.search(r'(\d+) turn cards, (\d+) iters',p[2])
if m: return int(m.group(1)),int(m.group(2))
m=re.search(r'(\d+) iters',p[2]);
return (None,int(m.group(1))) if m else (None,None)
def ch(p):
c=p[4] if len(p)>4 else ''
k=re.match(r'[A-Za-z]+',c); return (k.group(0) if k else c), c
def ev(p):
v=re.search(r'\(pots\): (.*?)\]',p[2]);
d={}
if v:
for a,x in re.findall(r'(fold|call|check|raise to [\d.]+) ([+-][\d.]+)',v.group(1)): d[a]=float(x)
return d
A=rd(sys.argv[1]); B=rd(sys.argv[2]); na,nb=sys.argv[3],sys.argv[4]
q=lambda v,p: sorted(v)[max(int(len(v)*p)-1,0)]
by=collections.defaultdict(list)
for i,(a,b) in enumerate(zip(A,B)): by[kind(a)].append(i)
print(f"| kind | n | {na} mean/p99/max ms | {nb} mean/p99/max ms | {na} cards/iters (median) | {nb} cards/iters (median) |")
print("|---|---|---|---|---|---|")
for k,ix in sorted(by.items()):
fa=[float(A[i][3]) for i in ix]; fb=[float(B[i][3]) for i in ix]
ia=[info(A[i]) for i in ix]; ib=[info(B[i]) for i in ix]
med=lambda L,j: st.median([x[j] for x in L if x[j] is not None]) if any(x[j] is not None for x in L) else '-'
print(f"| {k} | {len(ix)} | {st.mean(fa):.0f}/{q(fa,.99):.0f}/{max(fa):.0f} | {st.mean(fb):.0f}/{q(fb,.99):.0f}/{max(fb):.0f} | {med(ia,0)}/{med(ia,1)} | {med(ib,0)}/{med(ib,1)} |")
ta=sum(float(a[3]) for a in A)/1e3; tb=sum(float(b[3]) for b in B)/1e3
print(f"total {na} {ta:.0f} s, {nb} {tb:.0f} s")
act=sz=0; rows=[]
for i,(a,b) in enumerate(zip(A,B)):
(ka,ca),(kb,cb)=ch(a),ch(b)
if ka!=kb: act+=1; rows.append((i,kind(a),ca,cb))
elif ca!=cb: sz+=1; rows.append((i,kind(a),ca,cb))
print(f"differ {na} vs {nb}: action {act}, size only {sz}, of {len(A)}")
for r in rows:
i=r[0]; ea,eb=ev(A[i]),ev(B[i])
print(' line',i+1,r[1],r[2],'vs',r[3],'| EV(pots) ',{k:round(v,2) for k,v in ea.items()},'vs',{k:round(v,2) for k,v in eb.items()})
@@ -0,0 +1,39 @@
| kind | n | SOLVER_ITER mean/p99/max ms | baum mean/p99/max ms | SOLVER_ITER cards/iters (median) | baum cards/iters (median) |
|---|---|---|---|---|---|
| Flop/hu | 99 | 899/1622/2147 | 776/2046/2077 | 16/40 | 16/40 |
| Flop/mw | 32 | 942/2102/2516 | 513/1458/1527 | -/2000.0 | -/1675.0 |
| River/hu | 35 | 256/544/587 | 190/379/457 | -/100 | -/100 |
| River/mw | 5 | 873/1359/1495 | 611/817/933 | -/5600 | -/3600 |
| Turn/hu | 57 | 1632/3986/4296 | 815/1272/2284 | 16/38 | 16/35 |
| Turn/mw | 10 | 1197/2145/2934 | 595/964/1022 | -/2700.0 | -/1425.0 |
total SOLVER_ITER 238 s, baum 155 s
differ SOLVER_ITER vs baum: action 15, size only 14, of 238
line 38 Turn/hu Call vs Fold | EV(pots) {'fold': 2.43, 'call': 2.47, 'raise to 1.50': 2.21, 'raise to 9.13': 0.0} vs {'fold': 3.06, 'call': 2.71, 'raise to 1.50': 2.55, 'raise to 9.13': 0.0}
line 54 Flop/hu Check vs Raise { to: 0.03666666666666667 } | EV(pots) {'check': 1.01} vs {'check': 1.13}
line 56 Flop/hu Raise { to: 0.06666666666666667 } vs Raise { to: 0.03333333333333333 } | EV(pots) {'check': 1.71} vs {'check': 2.24}
line 62 Flop/hu Call vs Fold | EV(pots) {'fold': 1.9, 'call': 1.98, 'raise to 3.00': 1.96, 'raise to 12.93': 0.0} vs {'fold': 3.2, 'call': 2.43, 'raise to 3.00': 2.05, 'raise to 12.93': 0.0}
line 63 Turn/hu Raise { to: 0.42 } vs Raise { to: 0.13999999999999999 } | EV(pots) {'check': 0.27} vs {'check': 0.39}
line 68 Flop/hu Check vs Raise { to: 0.03 } | EV(pots) {'check': 1.26} vs {'check': 0.94}
line 73 Flop/hu Raise { to: 0.12333333333333332 } vs Raise { to: 0.24666666666666665 } | EV(pots) {'check': 0.0} vs {'check': 0.0}
line 84 Flop/hu Raise { to: 0.33 } vs Raise { to: 0.22 } | EV(pots) {'check': 0.31} vs {'check': 0.28}
line 96 Flop/hu Raise { to: 0.05 } vs Raise { to: 0.02 } | EV(pots) {'check': 3.23} vs {'check': 3.16}
line 97 Turn/hu Raise { to: 0.05 } vs Raise { to: 0.02 } | EV(pots) {'check': 2.64} vs {'check': 3.12}
line 123 Flop/hu Raise { to: 0.11 } vs Raise { to: 0.07333333333333333 } | EV(pots) {'check': 1.34} vs {'check': 1.6}
line 133 Turn/hu Call vs Fold | EV(pots) {'fold': 1.96, 'call': 1.99, 'raise to 1.50': 2.11, 'raise to 9.63': 0.0} vs {'fold': 2.31, 'call': 2.29, 'raise to 1.50': 2.34, 'raise to 9.63': 0.0}
line 136 Flop/mw Raise { to: 0.15666666666666665 } vs Check | EV(pots) {} vs {}
line 145 Flop/hu Raise { to: 0.039999999999999994 } vs Raise { to: 0.12 } | EV(pots) {'check': 2.06} vs {'check': 1.76}
line 155 Flop/hu Raise { to: 0.03 } vs Check | EV(pots) {'check': 2.34} vs {'check': 2.21}
line 159 Turn/hu Raise { to: 0.27999999999999997 } vs Raise { to: 0.5599999999999999 } | EV(pots) {'check': 0.0} vs {'check': 0.0}
line 180 Turn/hu Raise { to: 0.02 } vs Check | EV(pots) {'check': 3.15} vs {'check': 2.82}
line 183 Flop/hu Check vs Raise { to: 0.1 } | EV(pots) {'check': 0.12} vs {'check': 0.26}
line 184 Turn/hu Check vs Raise { to: 0.05333333333333333 } | EV(pots) {'check': 0.94} vs {'check': 0.83}
line 185 Turn/hu Raise { to: 0.1 } vs Raise { to: 3.17 } | EV(pots) {'check': 0.0} vs {'check': 0.0}
line 190 Flop/hu Raise { to: 0.07333333333333333 } vs Raise { to: 0.03666666666666667 } | EV(pots) {'check': 0.48} vs {'check': 0.85}
line 199 Flop/mw Raise { to: 0.04666666666666667 } vs Raise { to: 0.023333333333333334 } | EV(pots) {} vs {}
line 200 Turn/hu Raise { to: 0.039999999999999994 } vs Raise { to: 0.07999999999999999 } | EV(pots) {'check': 0.22} vs {'check': 0.64}
line 205 Turn/hu Raise { to: 0.11 } vs Raise { to: 0.03666666666666667 } | EV(pots) {'check': 3.12} vs {'check': 2.64}
line 214 Turn/mw Raise { to: 0.1433333333333333 } vs Call | EV(pots) {} vs {}
line 218 Turn/hu Raise { to: 0.06333333333333332 } vs Check | EV(pots) {'check': 1.17} vs {'check': 1.28}
line 224 Turn/hu Check vs Raise { to: 0.07333333333333333 } | EV(pots) {'check': 0.14} vs {'check': 0.0}
line 228 Flop/hu Check vs Raise { to: 0.03666666666666667 } | EV(pots) {'check': 0.69} vs {'check': 0.69}
line 231 Turn/hu Fold vs Call | EV(pots) {'fold': 0.01, 'call': 0.0} vs {'fold': 0.0, 'call': 0.07}
+16
View File
@@ -0,0 +1,16 @@
import os, re, subprocess, sys
# vergl.py <jsonl> <out> <KARTEN|-> : kern_grund unter BUDGET=baum, SOLVER_ITER=hu_turn:38, optional BAUM_KARTEN
exe = r"C:\Users\marcm\pokerfreak-solverkern\budget\pokerbench-solverkern-budget-baum.exe"
ks = r"D:\Projects\pokerfreak\.claude\worktrees\mess-stand\betrieb\kern_schalter.txt"
env = dict(os.environ)
for z in open(ks, encoding="utf-8"):
z = z.strip()
if z and not z.startswith("#") and "=" in z:
k, v = z.split("=", 1); env[k.strip()] = v.strip()
env.pop("SOLVER_ITER", None)
env.update(BUDGET="baum", KERN_GRUND_ZEIT="1", SOLVER_ITER="hu_turn:38,hu_flop:40")
if len(sys.argv) > 4: env["BAUM_WAHL"] = sys.argv[4]
if sys.argv[3] != "-": env["BAUM_KARTEN"] = sys.argv[3]
src, out = os.path.abspath(sys.argv[1]), os.path.abspath(sys.argv[2])
p = subprocess.Popen([exe, src], env=env, stdout=open(out, "w", encoding="utf-8"), stderr=subprocess.DEVNULL, creationflags=0x4000)
p.wait()
@@ -0,0 +1,38 @@
| kind | n | iter_neu mean/p99/max ms | baum mean/p99/max ms | iter_neu cards/iters (median) | baum cards/iters (median) |
|---|---|---|---|---|---|
| Flop/hu | 99 | 854/1959/3890 | 1129/3539/5060 | 16/40 | 16/40 |
| Flop/mw | 32 | 1489/3500/4121 | 1475/4582/4822 | -/4050.0 | -/4050.0 |
| River/hu | 35 | 231/458/822 | 295/765/998 | -/100 | -/100 |
| River/mw | 5 | 1187/1901/2268 | 2036/2981/3477 | -/7200 | -/6200 |
| Turn/hu | 57 | 1310/3053/3618 | 1994/5582/6072 | 16/40 | 16/40 |
| Turn/mw | 10 | 1221/1848/2316 | 1583/2423/3175 | -/4100.0 | -/3125.0 |
total iter_neu 233 s, baum 309 s
differ iter_neu vs baum: action 15, size only 13, of 238
line 29 Flop/mw Raise { to: 0.026666666666666665 } vs Check | EV(pots) {} vs {}
line 38 Turn/hu Call vs Fold | EV(pots) {'fold': 2.43, 'call': 2.47, 'raise to 1.50': 2.21, 'raise to 9.13': 0.0} vs {'fold': 2.53, 'call': 2.47, 'raise to 1.50': 2.31, 'raise to 9.13': 0.0}
line 54 Flop/hu Check vs Raise { to: 0.03666666666666667 } | EV(pots) {'check': 1.01} vs {'check': 1.13}
line 56 Flop/hu Raise { to: 0.06666666666666667 } vs Raise { to: 0.03333333333333333 } | EV(pots) {'check': 1.71} vs {'check': 2.24}
line 62 Flop/hu Call vs Fold | EV(pots) {'fold': 1.9, 'call': 1.98, 'raise to 3.00': 1.96, 'raise to 12.93': 0.0} vs {'fold': 3.2, 'call': 2.43, 'raise to 3.00': 2.05, 'raise to 12.93': 0.0}
line 63 Turn/hu Raise { to: 0.42 } vs Raise { to: 0.13999999999999999 } | EV(pots) {'check': 0.27} vs {'check': 0.39}
line 68 Flop/hu Check vs Raise { to: 0.03 } | EV(pots) {'check': 1.26} vs {'check': 0.94}
line 73 Flop/hu Raise { to: 0.12333333333333332 } vs Raise { to: 0.24666666666666665 } | EV(pots) {'check': 0.0} vs {'check': 0.0}
line 81 Turn/hu Check vs Raise { to: 0.03666666666666667 } | EV(pots) {'check': 2.49} vs {'check': 3.33}
line 84 Flop/hu Raise { to: 0.33 } vs Raise { to: 0.22 } | EV(pots) {'check': 0.31} vs {'check': 0.28}
line 96 Flop/hu Raise { to: 0.05 } vs Raise { to: 0.02 } | EV(pots) {'check': 3.23} vs {'check': 3.16}
line 97 Turn/hu Raise { to: 0.05 } vs Raise { to: 0.02 } | EV(pots) {'check': 2.64} vs {'check': 3.11}
line 123 Flop/hu Raise { to: 0.11 } vs Raise { to: 0.07333333333333333 } | EV(pots) {'check': 1.34} vs {'check': 1.6}
line 145 Flop/hu Raise { to: 0.039999999999999994 } vs Raise { to: 0.12 } | EV(pots) {'check': 2.06} vs {'check': 1.76}
line 149 Flop/mw Fold vs Call | EV(pots) {} vs {}
line 155 Flop/hu Raise { to: 0.03 } vs Check | EV(pots) {'check': 2.34} vs {'check': 2.21}
line 159 Turn/hu Raise { to: 0.27999999999999997 } vs Raise { to: 0.5599999999999999 } | EV(pots) {'check': 0.0} vs {'check': 0.0}
line 183 Flop/hu Check vs Raise { to: 0.1 } | EV(pots) {'check': 0.12} vs {'check': 0.26}
line 184 Turn/hu Check vs Raise { to: 0.05333333333333333 } | EV(pots) {'check': 0.94} vs {'check': 0.83}
line 185 Turn/hu Raise { to: 0.1 } vs Raise { to: 3.17 } | EV(pots) {'check': 0.0} vs {'check': 0.0}
line 190 Flop/hu Raise { to: 0.07333333333333333 } vs Raise { to: 0.03666666666666667 } | EV(pots) {'check': 0.48} vs {'check': 0.85}
line 200 Turn/hu Raise { to: 0.039999999999999994 } vs Raise { to: 0.07999999999999999 } | EV(pots) {'check': 0.23} vs {'check': 0.65}
line 205 Turn/hu Raise { to: 0.11 } vs Raise { to: 0.03666666666666667 } | EV(pots) {'check': 3.12} vs {'check': 2.67}
line 218 Turn/hu Raise { to: 0.06333333333333332 } vs Check | EV(pots) {'check': 1.17} vs {'check': 1.28}
line 221 Flop/mw Fold vs Call | EV(pots) {} vs {}
line 224 Turn/hu Check vs Raise { to: 0.07333333333333333 } | EV(pots) {'check': 0.14} vs {'check': 0.0}
line 228 Flop/hu Check vs Raise { to: 0.03666666666666667 } | EV(pots) {'check': 0.69} vs {'check': 0.69}
line 231 Turn/hu Fold vs Call | EV(pots) {'fold': 0.01, 'call': 0.0} vs {'fold': 0.0, 'call': 0.07}
@@ -0,0 +1,13 @@
| kind | n | iter_neu mean/p99/max ms | baum_schritt mean/p99/max ms | iter_neu cards/iters (median) | baum_schritt cards/iters (median) |
|---|---|---|---|---|---|
| Flop/hu | 99 | 854/1959/3890 | 1180/2988/4561 | 16/40 | 16/40 |
| Flop/mw | 32 | 1489/3500/4121 | 1568/3732/3736 | -/4050.0 | -/4050.0 |
| River/hu | 35 | 231/458/822 | 315/848/852 | -/100 | -/100 |
| River/mw | 5 | 1187/1901/2268 | 1611/2320/2855 | -/7200 | -/6200 |
| Turn/hu | 57 | 1310/3053/3618 | 1728/4199/4252 | 16/40 | 16/40 |
| Turn/mw | 10 | 1221/1848/2316 | 2028/3482/4418 | -/4100.0 | -/3125.0 |
total iter_neu 233 s, baum_schritt 305 s
differ iter_neu vs baum_schritt: action 3, size only 0, of 238
line 29 Flop/mw Raise { to: 0.026666666666666665 } vs Check | EV(pots) {} vs {}
line 149 Flop/mw Fold vs Call | EV(pots) {} vs {}
line 221 Flop/mw Fold vs Call | EV(pots) {} vs {}
@@ -0,0 +1,38 @@
| kind | n | live mean/p99/max ms | baum mean/p99/max ms | live cards/iters (median) | baum cards/iters (median) |
|---|---|---|---|---|---|
| Flop/hu | 99 | 286/669/918 | 1129/3539/5060 | 16/40 | 16/40 |
| Flop/mw | 32 | 489/1010/1611 | 1475/4582/4822 | -/4100.0 | -/4050.0 |
| River/hu | 35 | 84/160/167 | 295/765/998 | -/100 | -/100 |
| River/mw | 5 | 715/694/1577 | 2036/2981/3477 | -/7400 | -/6200 |
| Turn/hu | 57 | 542/1539/1555 | 1994/5582/6072 | 16/40 | 16/40 |
| Turn/mw | 10 | 458/658/756 | 1583/2423/3175 | -/4100.0 | -/3125.0 |
total live 86 s, baum 309 s
differ live vs baum: action 14, size only 14, of 238
line 28 Turn/mw Raise { to: 0.023333333333333334 } vs Check | EV(pots) {} vs {}
line 38 Turn/hu Call vs Fold | EV(pots) {'fold': 2.43, 'call': 2.47, 'raise to 1.50': 2.2, 'raise to 9.13': 0.0} vs {'fold': 2.53, 'call': 2.47, 'raise to 1.50': 2.31, 'raise to 9.13': 0.0}
line 54 Flop/hu Check vs Raise { to: 0.03666666666666667 } | EV(pots) {'check': 1.01} vs {'check': 1.13}
line 56 Flop/hu Raise { to: 0.06666666666666667 } vs Raise { to: 0.03333333333333333 } | EV(pots) {'check': 1.71} vs {'check': 2.24}
line 62 Flop/hu Call vs Fold | EV(pots) {'fold': 1.9, 'call': 1.98, 'raise to 3.00': 1.96, 'raise to 12.93': 0.0} vs {'fold': 3.2, 'call': 2.43, 'raise to 3.00': 2.05, 'raise to 12.93': 0.0}
line 63 Turn/hu Raise { to: 0.42 } vs Raise { to: 0.13999999999999999 } | EV(pots) {'check': 0.27} vs {'check': 0.39}
line 68 Flop/hu Check vs Raise { to: 0.03 } | EV(pots) {'check': 1.26} vs {'check': 0.94}
line 73 Flop/hu Raise { to: 0.12333333333333332 } vs Raise { to: 0.24666666666666665 } | EV(pots) {'check': 0.0} vs {'check': 0.0}
line 81 Turn/hu Check vs Raise { to: 0.03666666666666667 } | EV(pots) {'check': 2.49} vs {'check': 3.33}
line 84 Flop/hu Raise { to: 0.33 } vs Raise { to: 0.22 } | EV(pots) {'check': 0.31} vs {'check': 0.28}
line 96 Flop/hu Raise { to: 0.05 } vs Raise { to: 0.02 } | EV(pots) {'check': 3.23} vs {'check': 3.16}
line 97 Turn/hu Raise { to: 0.05 } vs Raise { to: 0.02 } | EV(pots) {'check': 2.64} vs {'check': 3.11}
line 123 Flop/hu Raise { to: 0.11 } vs Raise { to: 0.07333333333333333 } | EV(pots) {'check': 1.34} vs {'check': 1.6}
line 145 Flop/hu Raise { to: 0.039999999999999994 } vs Raise { to: 0.12 } | EV(pots) {'check': 2.06} vs {'check': 1.76}
line 155 Flop/hu Raise { to: 0.03 } vs Check | EV(pots) {'check': 2.34} vs {'check': 2.21}
line 159 Turn/hu Raise { to: 0.27999999999999997 } vs Raise { to: 0.5599999999999999 } | EV(pots) {'check': 0.0} vs {'check': 0.0}
line 183 Flop/hu Check vs Raise { to: 0.1 } | EV(pots) {'check': 0.12} vs {'check': 0.26}
line 184 Turn/hu Check vs Raise { to: 0.05333333333333333 } | EV(pots) {'check': 0.94} vs {'check': 0.83}
line 185 Turn/hu Raise { to: 0.1 } vs Raise { to: 3.17 } | EV(pots) {'check': 0.0} vs {'check': 0.0}
line 190 Flop/hu Raise { to: 0.07333333333333333 } vs Raise { to: 0.03666666666666667 } | EV(pots) {'check': 0.48} vs {'check': 0.85}
line 200 Turn/hu Raise { to: 0.039999999999999994 } vs Raise { to: 0.07999999999999999 } | EV(pots) {'check': 0.23} vs {'check': 0.65}
line 201 Turn/mw Raise { to: 0.04666666666666667 } vs Raise { to: 0.023333333333333334 } | EV(pots) {} vs {}
line 205 Turn/hu Raise { to: 0.11 } vs Raise { to: 0.03666666666666667 } | EV(pots) {'check': 3.12} vs {'check': 2.67}
line 218 Turn/hu Raise { to: 0.06333333333333332 } vs Check | EV(pots) {'check': 1.17} vs {'check': 1.28}
line 221 Flop/mw Fold vs Call | EV(pots) {} vs {}
line 224 Turn/hu Check vs Raise { to: 0.07333333333333333 } | EV(pots) {'check': 0.14} vs {'check': 0.0}
line 228 Flop/hu Check vs Raise { to: 0.03666666666666667 } | EV(pots) {'check': 0.69} vs {'check': 0.69}
line 231 Turn/hu Fold vs Call | EV(pots) {'fold': 0.01, 'call': 0.0} vs {'fold': 0.0, 'call': 0.07}
@@ -0,0 +1,13 @@
| kind | n | live mean/p99/max ms | baum_schritt mean/p99/max ms | live cards/iters (median) | baum_schritt cards/iters (median) |
|---|---|---|---|---|---|
| Flop/hu | 99 | 286/669/918 | 1180/2988/4561 | 16/40 | 16/40 |
| Flop/mw | 32 | 489/1010/1611 | 1568/3732/3736 | -/4100.0 | -/4050.0 |
| River/hu | 35 | 84/160/167 | 315/848/852 | -/100 | -/100 |
| River/mw | 5 | 715/694/1577 | 1611/2320/2855 | -/7400 | -/6200 |
| Turn/hu | 57 | 542/1539/1555 | 1728/4199/4252 | 16/40 | 16/40 |
| Turn/mw | 10 | 458/658/756 | 2028/3482/4418 | -/4100.0 | -/3125.0 |
total live 86 s, baum_schritt 305 s
differ live vs baum_schritt: action 2, size only 1, of 238
line 28 Turn/mw Raise { to: 0.023333333333333334 } vs Check | EV(pots) {} vs {}
line 201 Turn/mw Raise { to: 0.04666666666666667 } vs Raise { to: 0.023333333333333334 } | EV(pots) {} vs {}
line 221 Flop/mw Fold vs Call | EV(pots) {} vs {}
@@ -0,0 +1,34 @@
import re,statistics as st,sys
def lies(f):
r=[]
for l in open(f,encoding='utf-8'):
p=l.rstrip('\n').split('\t')
m=re.search(r'(\d+) (?:river|turn) cards, (\d+) iters',p[2])
v={}
vals=re.search(r'\(pots\): (.*?)\] ->',p[2])
if vals:
for a,x in re.findall(r'(fold|call|check|raise to [\d.]+) ([+-][\d.]+)',vals.group(1)): v[a]=float(x)
a=re.search(r'-> (fold|call|check|raise to [\d.]+)',p[2])
r.append(dict(k=int(m.group(1)) if m else None,v=v,act=a.group(1) if a else None))
return r
def bewerte(arm,full,name):
loss=[];same=0;n=0;worst=(0,None)
for i,(x,y) in enumerate(zip(arm,full)):
if not y['v'] or x['act'] is None or y['act'] is None: continue
n+=1
best=max(y['v'].values())
val=y['v'].get(x['act'])
if val is None: val=min(y['v'].values())
L=best-val; loss.append(L)
if L>worst[0]: worst=(L,i+1)
same+= x['act'].split()[0]==y['act'].split()[0]
cut=sum(1 for x in arm if x['k'] is not None and x['k']<16)
return f"{name}: n={n} mean EV loss {st.mean(loss):.4f} pots, worst {worst[0]:.3f} (line {worst[1]}), action agreement {same}/{n}"
rows=[('fixture HU turn (57)','w_fixt_%s.txt','fix_k44.txt'),('Kipp turn (16)','w_kipp_%s.txt','kipp_k44.txt'),('fixture HU flop (99)','w_flop_%s.txt','w_flop_full.txt')]
for name,pat,full in rows:
F=lies(full)
for arm,lab in (('bal','balanced'),('str','stride')):
A=lies(pat%arm)
cards=sorted(set(x['k'] for x in A if x['k']))
n_cut=sum(1 for x in A if x['k'] and x['k']<(16))
print(bewerte(A,F,f"{name} {lab}"),f"| cards used {cards[:8]}")
@@ -0,0 +1,6 @@
fixture HU turn (57) balanced: n=13 mean EV loss 0.0000 pots, worst 0.000 (line None), action agreement 13/13 | cards used [6, 9, 13, 16]
fixture HU turn (57) stride: n=14 mean EV loss 0.0176 pots, worst 0.238 (line 5), action agreement 12/14 | cards used [6, 9, 13, 16]
Kipp turn (16) balanced: n=16 mean EV loss 0.0369 pots, worst 0.353 (line 16), action agreement 12/16 | cards used [16]
Kipp turn (16) stride: n=16 mean EV loss 0.0590 pots, worst 0.353 (line 16), action agreement 8/16 | cards used [16]
fixture HU flop (99) balanced: n=31 mean EV loss 0.0008 pots, worst 0.024 (line 75), action agreement 30/31 | cards used [16]
fixture HU flop (99) stride: n=31 mean EV loss 0.0171 pots, worst 0.507 (line 29), action agreement 29/31 | cards used [16]
+3
View File
@@ -64,4 +64,7 @@ fn main() {
};
println!("{lage}\t{grund}\t{}{ms}", d.reason.replace('\t', " "));
}
if rechner::engine::baum::aktiv() {
eprintln!("NOTBREMSE {}", rechner::engine::frist::NOTBREMSE_ZAEHLER.load(std::sync::atomic::Ordering::Relaxed));
}
}
+23
View File
@@ -377,6 +377,20 @@ fn matched_any(regret: &[f64], a: usize, out: &mut [f64]) {
}
}
/// `k` of the undealt cards as single-bit masks, balanced over ranks and suits: the deck sorted by rank (the suit order rotating
/// with the rank, so no suit leads), then evenly strided. Same board and `k` give the same cards in the same order.
pub fn karten_gleichmaessig(board: u64, k: usize) -> Vec<u64> {
let mut all: Vec<u64> = (0..4u32).flat_map(|s| (0..13u32).map(move |r| 1u64 << (16 * s + r))).filter(|b| b & board == 0).collect();
all.sort_by_key(|b| {
let t = b.trailing_zeros();
let (s, r) = (t / 16, t % 16);
(r, (s + r) % 4)
});
let n = all.len();
let k = k.clamp(1, n);
(0..k).map(|i| all[(((i as f64 + 0.5) * n as f64 / k as f64) as usize).min(n - 1)]).collect()
}
impl TrSolver {
/// `board`: the four turn cards as a mask; `river`: the river cards to enumerate (`None` = all 48 not
/// on the board, `Some(k)` = `k` of them, evenly strided). Combos must not touch the board.
@@ -395,6 +409,15 @@ impl TrSolver {
TrSolver::with_cards(game, hands, board, all, wr)
}
/// As `new` with `Some(k)`, but the `k` cards are chosen by `karten_gleichmaessig` (rank- and suit-balanced, a fixed function of
/// the board and `k`): `BUDGET=baum` uses it so a smaller card count is a coarser but unbiased sample of the same deck.
pub fn new_gleichmaessig(game: TrGame, hands: [Hands; 2], board: u64, k: usize) -> TrSolver {
let candidates = (0..52u32).filter(|i| board & (1u64 << (16 * (i / 13) + i % 13)) == 0).count();
let all = karten_gleichmaessig(board, k);
let wr = candidates as f64 / (all.len() as f64 * (candidates as f64 - 4.0));
TrSolver::with_cards(game, hands, board, all, wr)
}
/// As `new`, with explicit river cards (single-bit masks) and the deal weight of each.
pub fn with_cards(game: TrGame, hands: [Hands; 2], board: u64, all: Vec<u64>, wr: f64) -> TrSolver {
let n = [hands[0].masks.len(), hands[1].masks.len()];
+122
View File
@@ -0,0 +1,122 @@
//! `BUDGET=baum`: the work of every postflop solve is a deterministic function of its tree size, not of the clock.
//! (Calibration helpers: `BAUM_LOG=1` prints one stderr line per finished solve loop.)
/// `BUDGET=baum` is set (read once). Off: nothing in this module is consulted and every path is the clock's.
pub fn aktiv() -> bool {
static AN: std::sync::OnceLock<bool> = std::sync::OnceLock::new();
*AN.get_or_init(|| std::env::var("BUDGET").as_deref() == Ok("baum"))
}
/// Calibration log `BAUM_LOG=1`: `BAUM_LOG <kind> <size features> setup_ms loop_ms iters` on stderr.
pub fn log(art: &str, feats: &str, setup_ms: f64, loop_ms: f64, done: u64) {
static LOG: std::sync::OnceLock<bool> = std::sync::OnceLock::new();
if *LOG.get_or_init(|| std::env::var("BAUM_LOG").is_ok_and(|v| !v.is_empty() && v != "0")) {
eprintln!("BAUM_LOG\t{art}\t{feats}\t{setup_ms:.1}\t{loop_ms:.1}\t{done}");
}
}
// ---------------------------------------------------------------------------------------------------------------------
// The work of a solve as a function of its tree size. Constants: least-squares fits of CPU ms per iteration over the 238
// fixture decisions, measured with fixed iterations (`SOLVER_ITER`, `BAUM_LOG=1`; messung/solver_kern/BUDGET_BAUM.md), relative
// error 12 to 16 % (HU) and 4 to 12 % (MW). A solve gets what the live clock would give it on an idle core
// (`TURN_BUDGET_MS` etc.), but the iterations, the river/turn cards and the multiway stage are computed from these predictions
// BEFORE the solve, so the same spot gets the same work whatever the machine load.
// ---------------------------------------------------------------------------------------------------------------------
use crate::engine::frist::Art;
use std::cell::Cell;
thread_local! {
/// Predicted CPU ms the solves of this decision have used so far (the deterministic stand-in of `frist::elapsed_ms`).
static KONTO: Cell<f64> = const { Cell::new(0.0) };
}
/// New decision (called by `frist::begin`).
pub fn neu() {
KONTO.with(|k| k.set(0.0));
}
/// Predicted CPU ms spent on solves in this decision so far.
pub fn konto() -> f64 {
KONTO.with(Cell::get)
}
/// Book predicted CPU ms.
pub fn buche(ms: f64) {
KONTO.with(|k| k.set(k.get() + ms));
}
/// Setup (ranges, tree, equity tables) of a heads-up flop/turn/river solve, CPU ms (the measured ticks are 0 to 60).
pub const HU_SETUP_MS: f64 = 15.0;
/// CPU ms of one heads-up river iteration.
pub fn hu_river_iter_ms(c0: usize, c1: usize, nodes: usize) -> f64 {
7.0e-6 * nodes as f64 * (c0 + c1) as f64
}
/// CPU ms of one heads-up turn iteration with `k` river cards.
pub fn hu_turn_iter_ms(c0: usize, c1: usize, nodes: usize, k: usize) -> f64 {
k as f64 * (3.8e-7 * (c0 * c1) as f64 + 6.4e-6 * nodes as f64 * (c0 + c1) as f64)
}
/// CPU ms of one heads-up flop iteration with `k` turn cards.
pub fn hu_flop_iter_ms(c0: usize, c1: usize, nodes: usize, k: usize) -> f64 {
k as f64 * 7.5e-6 * nodes as f64 * (c0 + c1) as f64
}
/// CPU ms of one multiway iteration (MCCFR samples one path: the cost follows players x combos, not the node count;
/// fit `ms = k x players x sum(combos)`, relative error ~20 %, the small solves are limited by the 15.6 ms clock tick).
pub fn mw_iter_ms(art: Art, players: usize, combos: &[usize]) -> f64 {
let k = match art {
Art::MwFlop => 4.2e-5,
Art::MwTurn => 4.8e-5,
_ => 1.75e-5,
};
k * players as f64 * combos.iter().sum::<usize>() as f64
}
/// CPU ms to set up a multiway solve of `nodes` tree nodes (locks and rows).
pub fn mw_setup_ms(nodes: usize) -> f64 {
1.6e-3 * nodes as f64
}
/// `x` rounded down to a multiple of `step`, between `lo` and `hi` (the live clock checks every `step` iterations too).
pub fn iters_aus(x: f64, step: u32, lo: u32, hi: u32) -> u32 {
let n = if x.is_finite() && x > 0.0 { (x as u32) / step * step } else { 0 };
n.clamp(lo, hi.max(lo))
}
/// Iterations of a solve that must fit `kappe` CPU ms with `setup` ms already gone and `p` ms per iteration.
pub fn iters_fuer(kappe: f64, setup: f64, p: f64, step: u32, lo: u32, hi: u32) -> u32 {
iters_aus((kappe - setup) / p.max(1e-9), step, lo, hi)
}
/// Cards of a heads-up turn/flop solve so that `min_iters` iterations (x 1.3 slack, as the live check) fit `kappe`:
/// the live `eng` rule (scale by `(kappe - setup) / (p x min_iters x 1.5)`, at most three times), with the predicted cost in
/// place of two measured iterations. `iter_ms(k)` = predicted ms per iteration with `k` cards.
pub fn karten_fuer(k0: usize, kmin: usize, kappe: f64, min_iters: u32, iter_ms: &dyn Fn(usize) -> f64) -> usize {
let mut k = k0;
for _ in 0..3 {
let p = iter_ms(k);
if p * min_iters as f64 * 1.3 <= kappe - HU_SETUP_MS || k <= kmin {
break;
}
let skala = ((kappe - HU_SETUP_MS) / (p * min_iters as f64 * 1.5)).clamp(0.05, 0.9);
k = ((k as f64 * skala) as usize).max(kmin);
}
k
}
/// Measurement only (`BAUM_KARTEN=<n>`, under `BUDGET=baum`): force the river/turn card count of every heads-up turn/flop solve
/// (48 = all), to compare the chosen count with the full one.
pub fn karten_vorgabe() -> Option<usize> {
static K: std::sync::OnceLock<Option<usize>> = std::sync::OnceLock::new();
*K.get_or_init(|| std::env::var("BAUM_KARTEN").ok().and_then(|v| v.trim().parse().ok()).filter(|n: &usize| *n > 0))
}
/// Measurement only (`BAUM_WAHL=schritt`, under `BUDGET=baum`): the old suit-sorted stride card selection instead of the balanced one,
/// to tell what a difference to the clock/`SOLVER_ITER` runs owes to the card choice.
pub fn wahl_schritt() -> bool {
static W: std::sync::OnceLock<bool> = std::sync::OnceLock::new();
*W.get_or_init(|| std::env::var("BAUM_WAHL").as_deref() == Ok("schritt"))
}
+17 -1
View File
@@ -15,8 +15,13 @@ thread_local! {
static WAND: Cell<Option<Instant>> = const { Cell::new(None) };
/// `fest_hier`: this thread ignores wall time like `SOLVER_ZEIT=fest` (tests, tools).
static FEST_HIER: Cell<bool> = const { Cell::new(false) };
/// `BUDGET=baum`: the emergency brake already fired in this decision (counted once per decision).
static GEFEUERT: Cell<bool> = const { Cell::new(false) };
}
/// How many decisions the emergency brake cut under `BUDGET=baum` (a safety net there: should stay 0).
pub static NOTBREMSE_ZAEHLER: std::sync::atomic::AtomicU32 = std::sync::atomic::AtomicU32::new(0);
/// Total wall time of one decision per street, in ms.
pub const RIVER_MS: f64 = 2000.0;
pub const TURN_MS: f64 = 1250.0;
@@ -28,6 +33,8 @@ pub const MARGIN_MS: f64 = 150.0;
pub fn begin() {
START.with(|s| s.set(Some(thread_cpu_ms())));
WAND.with(|s| s.set(Some(Instant::now())));
GEFEUERT.with(|g| g.set(false));
super::baum::neu();
}
/// Live emergency brake in wall time (`KERN_NOTBREMSE_MS`, set only by the live bridge
@@ -39,7 +46,11 @@ pub fn notbremse() -> bool {
let Some(ms) = *MS.get_or_init(|| std::env::var("KERN_NOTBREMSE_MS").ok().and_then(|v| v.trim().parse().ok()).filter(|x: &f64| *x > 0.0)) else {
return false;
};
!fixed() && wand_ueber(ms)
let an = !fest_streng() && wand_ueber(ms);
if an && super::baum::aktiv() && !GEFEUERT.with(|g| g.replace(true)) {
NOTBREMSE_ZAEHLER.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
}
an
}
/// Wall time since `begin` exceeds `ms`.
@@ -64,6 +75,11 @@ pub fn left_ms(total_ms: f64) -> f64 {
/// Measurement switch `SOLVER_ZEIT=fest`: solvers ignore wall time and always run their full iteration
/// count, so ladder and LBR results do not depend on machine load (read once).
pub fn fixed() -> bool {
fest_streng() || super::baum::aktiv()
}
/// `fixed` without `BUDGET=baum`: the modes that also switch the emergency brake off.
fn fest_streng() -> bool {
static FIXED: std::sync::OnceLock<bool> = std::sync::OnceLock::new();
FEST_HIER.with(Cell::get) || *FIXED.get_or_init(|| std::env::var("SOLVER_ZEIT").as_deref() == Ok("fest")) || iter_aktiv()
}
+1
View File
@@ -14,6 +14,7 @@ pub mod double_board;
pub mod effective;
pub mod flop_spieler;
pub mod fortsetzung;
pub mod baum;
pub mod frist;
pub mod glaube;
pub mod glaube_linie;
+33 -6
View File
@@ -629,7 +629,12 @@ pub fn solve_multi3(spot: &Spot) -> Option<SolvedM> {
if spot.board.len() != cards || spot.hero_cards.len() != 2 || villains < 2 {
return weg("mw lage");
}
let budget = crate::engine::frist::budget_ms(self::cap_ms(cap_ms), total);
let baum = crate::engine::baum::aktiv();
let budget = if baum {
self::cap_ms(cap_ms).min(total - crate::engine::frist::MARGIN_MS - crate::engine::baum::konto())
} else {
crate::engine::frist::budget_ms(self::cap_ms(cap_ms), total)
};
if budget <= 0.0 {
return weg("mw keine zeit");
}
@@ -660,6 +665,8 @@ pub fn solve_multi3(spot: &Spot) -> Option<SolvedM> {
// Under SOLVER3_ALLE a game too big for the budget (fewer than MIN_ITERS iterations projected) is solved again
// smaller: fewer combos per player, fewer slots (a coarser abstraction beats the heuristic).
let stufen: Vec<(usize, usize)> = if alle() { vec![(MAX_COMBOS, slots), (100, (slots / 2).max(2)), (50, 2)] } else { vec![(MAX_COMBOS, slots)] };
// `BUDGET=baum`: predicted CPU ms already used by earlier stages of this solve (the stand-in of `jetzt - cpu0`).
let mut baum_vorher = 0.0;
for (lvl, (maxc, sl)) in stufen.iter().copied().enumerate() {
let letzte = lvl + 1 == stufen.len();
let erzwungen: Option<usize> = std::env::var("KERN_STUFE").ok().and_then(|v| v.trim().parse().ok());
@@ -687,6 +694,20 @@ pub fn solve_multi3(spot: &Spot) -> Option<SolvedM> {
let nodes = game.nodes.len();
let combos: Vec<usize> = hands.iter().map(|h| h.masks.len()).collect();
let hero_index = hands[me].masks.iter().position(|m| *m == hero_mask)?;
// `BUDGET=baum`: the stage and its iterations come from the tree size, before anything is built on it.
let art = if spot.street == Street::Turn { crate::engine::frist::Art::MwTurn } else { crate::engine::frist::Art::MwFlop };
let min_iter = crate::engine::frist::iter_min(art, if alle() && letzte { MIN_ITERS_KLEIN } else { MIN_ITERS });
let p_baum = crate::engine::baum::mw_iter_ms(art, order.len(), &combos);
let setup_baum = crate::engine::baum::mw_setup_ms(nodes);
let mut iters_eff = ITERS;
if baum {
let frei = budget - baum_vorher - setup_baum;
if !letzte && erzwungen.is_none() && p_baum * MIN_ITERS as f64 > frei - 30.0 * p_baum && !crate::engine::frist::iter_aktiv() {
baum_vorher += setup_baum + 30.0 * p_baum;
continue;
}
iters_eff = crate::engine::baum::iters_fuer(frei, 0.0, p_baum, 50, min_iter, ITERS);
}
let mut solver = SolverM::new(game, hands, board, spot.seed ^ 0x9e37_79b9_7f4a_7c15);
solver.werte_beobachten(at, hero_index);
if pool_w() > 0.0 || offen_w() > 0.0 {
@@ -727,19 +748,21 @@ pub fn solve_multi3(spot: &Spot) -> Option<SolvedM> {
return weg("stuetzung-locks");
}
let cpu_stufe = crate::engine::frist::thread_cpu_ms();
let cpu_s0 = cpu_stufe;
let mut done = 0u32;
let mut zu_gross = false;
let art = if spot.street == Street::Turn { crate::engine::frist::Art::MwTurn } else { crate::engine::frist::Art::MwFlop };
let min_iter = crate::engine::frist::iter_min(art, if alle() && letzte { MIN_ITERS_KLEIN } else { MIN_ITERS });
while done < crate::engine::frist::iter_cap(art, ITERS) {
while done < crate::engine::frist::iter_cap(art, iters_eff) {
solver.iterate();
done += 1;
if baum && crate::engine::frist::notbremse() {
break;
}
let jetzt = crate::engine::frist::thread_cpu_ms();
if done == 30 && !letzte && erzwungen.is_none() && (jetzt - cpu_stufe) / 30.0 * MIN_ITERS as f64 > budget - (jetzt - cpu0) {
if !baum && done == 30 && !letzte && erzwungen.is_none() && (jetzt - cpu_stufe) / 30.0 * MIN_ITERS as f64 > budget - (jetzt - cpu0) {
zu_gross = true;
break;
}
if done % 50 == 0 && jetzt - cpu0 > budget {
if !baum && done % 50 == 0 && jetzt - cpu0 > budget {
// Over the budget: enough iterations end the solve; too few hand the spot to a smaller game, the
// smallest one runs on to its minimum.
if done >= min_iter {
@@ -761,6 +784,10 @@ pub fn solve_multi3(spot: &Spot) -> Option<SolvedM> {
continue;
}
crate::engine::frist::iter_log(art, done as u64);
if baum {
crate::engine::baum::buche(setup_baum + done as f64 * p_baum);
}
crate::engine::baum::log(art.name(), &format!("{} {:?} {} {}", order.len(), combos, nodes, sl), cpu_s0 - cpu0, crate::engine::frist::thread_cpu_ms() - cpu_s0, done as u64);
// The smallest game under ALLE may rest on fewer iterations: a coarse solve still beats the heuristic.
if done < min_iter {
return weg("mw zu wenig iterationen");
+20 -3
View File
@@ -143,7 +143,12 @@ pub fn solve_river3(spot: &Spot) -> Option<Solved3> {
if spot.street != Street::River || spot.board.len() != 5 || spot.hero_cards.len() != 2 || villains < 2 {
return weg("mw lage");
}
let budget = crate::engine::frist::budget_ms(crate::engine::multi3_spieler::cap_ms(BUDGET_MS), crate::engine::frist::RIVER_MS);
let baum = crate::engine::baum::aktiv();
let budget = if baum {
crate::engine::multi3_spieler::cap_ms(BUDGET_MS).min(crate::engine::frist::RIVER_MS - crate::engine::frist::MARGIN_MS - crate::engine::baum::konto())
} else {
crate::engine::frist::budget_ms(crate::engine::multi3_spieler::cap_ms(BUDGET_MS), crate::engine::frist::RIVER_MS)
};
if budget <= 0.0 {
return weg("mw keine zeit");
}
@@ -238,15 +243,27 @@ pub fn solve_river3(spot: &Spot) -> Option<Solved3> {
}
let mut done = 0u32;
let mut zeit_stopp = false;
while done < crate::engine::frist::iter_cap(crate::engine::frist::Art::MwRiver, ITERS) {
let cpu_l0 = crate::engine::frist::thread_cpu_ms();
// `BUDGET=baum`: the iterations the cap allows on an idle core, from the tree size (never fewer than `MIN_ITERS`: no drop to the fallback for time).
let p_baum = crate::engine::baum::mw_iter_ms(crate::engine::frist::Art::MwRiver, order.len(), &combos);
let setup_baum = crate::engine::baum::mw_setup_ms(nodes);
let iters_eff = if baum { crate::engine::baum::iters_fuer(budget, setup_baum, p_baum, 200, MIN_ITERS, ITERS) } else { ITERS };
while done < crate::engine::frist::iter_cap(crate::engine::frist::Art::MwRiver, iters_eff) {
solver.iterate();
done += 1;
if done % 200 == 0 && crate::engine::frist::thread_cpu_ms() - cpu0 > budget || crate::engine::frist::notbremse() {
if baum && crate::engine::frist::notbremse() {
break;
}
if !baum && done % 200 == 0 && crate::engine::frist::thread_cpu_ms() - cpu0 > budget || crate::engine::frist::notbremse() {
zeit_stopp = true;
break;
}
}
crate::engine::frist::iter_log(crate::engine::frist::Art::MwRiver, done as u64);
if baum {
crate::engine::baum::buche(setup_baum + done as f64 * p_baum);
}
crate::engine::baum::log("mw_river", &format!("{} {:?} {} 0", order.len(), combos, nodes), cpu_l0 - cpu0, crate::engine::frist::thread_cpu_ms() - cpu_l0, done as u64);
if done < crate::engine::frist::iter_min(crate::engine::frist::Art::MwRiver, MIN_ITERS) {
return crate::engine::multi3_spieler::weg("mw zu wenig iterationen");
}
+1 -1
View File
@@ -816,7 +816,7 @@ fn setzer_index(spot: &Spot) -> usize {
/// Rückfall-Antwort für diesen Spot; `None` bei ausgeschaltetem Schalter oder ausserhalb der Scheibe (Omaha, keine Gegner-Range).
pub fn entscheide(spot: &Spot, lists: &[Option<List>], lage: Option<&Turnierlage>) -> Option<Decision> {
let c = cfg()?;
if c.nur_zeit && !(crate::engine::frist::notbremse() || (crate::engine::frist::elapsed_ms() >= ZEIT_AB_MS && !crate::engine::frist::iter_aktiv())) {
if c.nur_zeit && !(crate::engine::frist::notbremse() || (crate::engine::frist::elapsed_ms() >= ZEIT_AB_MS && !crate::engine::frist::iter_aktiv() && !crate::engine::baum::aktiv()) || (crate::engine::baum::aktiv() && !crate::engine::frist::iter_aktiv() && crate::engine::baum::konto() >= ZEIT_AB_MS)) {
return None;
}
entscheide_mit(spot, lists, c, lage)
+57 -4
View File
@@ -1257,6 +1257,10 @@ pub fn solve(spot: &Spot, c: &Cfg) -> Option<Geloest> {
if !ohne_uhr && (crate::engine::frist::elapsed_ms() > NOTFALL_MS || crate::engine::frist::notbremse()) {
return None;
}
let baum = crate::engine::baum::aktiv();
if baum && (crate::engine::baum::konto() > NOTFALL_MS || crate::engine::frist::notbremse()) {
return None;
}
let started = std::time::Instant::now();
let cpu0 = crate::engine::frist::thread_cpu_ms();
// Ranges zum River-Beginn: die River-Aktionen kommen nur über den Baum.
@@ -1367,15 +1371,26 @@ pub fn solve(spot: &Spot, c: &Cfg) -> Option<Geloest> {
}
let mut done = 0;
let mut zeit_stopp = false;
while done < crate::engine::frist::iter_cap(crate::engine::frist::Art::HuRiver, c.iters) {
let cpu_l0 = crate::engine::frist::thread_cpu_ms();
// `BUDGET=baum`: the iterations the live cap would allow on an idle core, computed from the tree size up front.
let p_baum = crate::engine::baum::hu_river_iter_ms(combos[0], combos[1], nodes);
let iters_eff = if baum { crate::engine::baum::iters_fuer(BUDGET_MS, crate::engine::baum::HU_SETUP_MS, p_baum, 5, MIN_ITERS, c.iters) } else { c.iters };
while done < crate::engine::frist::iter_cap(crate::engine::frist::Art::HuRiver, iters_eff) {
solver.iterate();
done += 1;
if baum && crate::engine::frist::notbremse() {
break;
}
if !ohne_uhr && done % 5 == 0 && (crate::engine::frist::thread_cpu_ms() - cpu0 > BUDGET_MS || crate::engine::frist::elapsed_ms() > NOTFALL_MS || crate::engine::frist::notbremse()) {
zeit_stopp = true;
break;
}
}
crate::engine::frist::iter_log(crate::engine::frist::Art::HuRiver, done as u64);
if baum {
crate::engine::baum::buche(crate::engine::baum::HU_SETUP_MS + done as f64 * p_baum);
}
crate::engine::baum::log("hu_river", &format!("{} {} {}", combos[0], combos[1], nodes), cpu_l0 - cpu0, crate::engine::frist::thread_cpu_ms() - cpu_l0, done as u64);
if done < crate::engine::frist::iter_min(crate::engine::frist::Art::HuRiver, MIN_ITERS) {
return None;
}
@@ -1876,6 +1891,10 @@ fn solve_frueh_roh(spot: &Spot, c: &Cfg, strasse: Street) -> Option<TurnGeloest>
if !ohne_uhr && (crate::engine::frist::elapsed_ms() > NOTFALL_MS || crate::engine::frist::notbremse()) {
return weg("frist");
}
let baum = crate::engine::baum::aktiv();
if baum && (crate::engine::baum::konto() > NOTFALL_MS || crate::engine::frist::notbremse()) {
return weg("frist");
}
let started = std::time::Instant::now();
let cpu0 = crate::engine::frist::thread_cpu_ms();
let mut start = spot.clone();
@@ -1912,8 +1931,25 @@ fn solve_frueh_roh(spot: &Spot, c: &Cfg, strasse: Street) -> Option<TurnGeloest>
let villain_weights = hands[1].weights.clone();
let pct = brett_perzentil(&hands[1].masks, board);
let root = game.root;
let mut solver = if flop {
let (iters, kappe) = if flop { (c.flop_iters, FLOP_BUDGET_MS) } else { (c.turn_iters, TURN_BUDGET_MS) };
// `BUDGET=baum`: river cards of the turn solve and iterations from the tree size (see `baum.rs`), never from the clock.
// A flop solve that is too big for its cap at the minimum iterations goes the `eng` way (`SKALA`, solved again smaller).
let mut turn_karten_baum = c.karten;
if baum && !flop {
let k0 = if c.eng { ((ENG_GRENZE / (combos[0] * combos[1]).max(1) as f64) as usize).clamp(2, c.karten) } else { c.karten };
turn_karten_baum = if let Some(n) = crate::engine::baum::karten_vorgabe() { n } else if c.eng { crate::engine::baum::karten_fuer(k0, 2, kappe, MIN_TURN_ITERS, &|k| crate::engine::baum::hu_turn_iter_ms(combos[0], combos[1], nodes, k)) } else { k0 };
}
let schritt = baum && crate::engine::baum::wahl_schritt();
let mut solver = if schritt && flop {
TrSolver::new(game, hands, board, Some(c.flop_karten)).with_river_equity(board)
} else if schritt {
TrSolver::new(game, hands, board, Some(turn_karten_baum))
} else if flop && baum {
TrSolver::new_gleichmaessig(game, hands, board, crate::engine::baum::karten_vorgabe().unwrap_or(c.flop_karten)).with_river_equity(board)
} else if flop {
TrSolver::new(game, hands, board, Some(c.flop_karten)).with_river_equity(board)
} else if baum {
TrSolver::new_gleichmaessig(game, hands, board, turn_karten_baum)
} else {
// `eng`: die Kosten (Aufbau und jede Iteration) wachsen mit Kombos x Kombos x River-Karten; breite Ranges bekommen
// von vornherein weniger Karten, statt erst nach einem verlorenen Aufbau.
@@ -1962,9 +1998,22 @@ fn solve_frueh_roh(spot: &Spot, c: &Cfg, strasse: Street) -> Option<TurnGeloest>
let art = if flop { crate::engine::frist::Art::HuFlop } else if crate::engine::frist::breit_hier() { crate::engine::frist::Art::HuTurnBreit } else { crate::engine::frist::Art::HuTurn };
let mut done = 0;
let cpu_iter0 = crate::engine::frist::thread_cpu_ms();
while done < crate::engine::frist::iter_cap(art, iters) {
let p_baum = if flop { crate::engine::baum::hu_flop_iter_ms(combos[0], combos[1], nodes, karten) } else { crate::engine::baum::hu_turn_iter_ms(combos[0], combos[1], nodes, karten) };
let iters_eff = if baum {
if flop && c.eng && p_baum * MIN_TURN_ITERS as f64 * 1.3 > kappe - crate::engine::baum::HU_SETUP_MS {
SKALA.with(|x| x.set(Some(((kappe - crate::engine::baum::HU_SETUP_MS) / (p_baum * MIN_TURN_ITERS as f64 * 1.5)).clamp(0.05, 0.9))));
return weg("zu gross (eng)");
}
crate::engine::baum::iters_fuer(kappe, crate::engine::baum::HU_SETUP_MS, p_baum, 5, MIN_TURN_ITERS, iters)
} else {
iters
};
while done < crate::engine::frist::iter_cap(art, iters_eff) {
solver.iterate();
done += 1;
if baum && crate::engine::frist::notbremse() {
break;
}
if c.eng && !ohne_uhr && done == 2 {
let je = (crate::engine::frist::thread_cpu_ms() - cpu_iter0) / 2.0;
if je * MIN_TURN_ITERS as f64 * 1.3 > kappe - (cpu_iter0 - cpu0) {
@@ -1977,6 +2026,10 @@ fn solve_frueh_roh(spot: &Spot, c: &Cfg, strasse: Street) -> Option<TurnGeloest>
}
}
crate::engine::frist::iter_log(art, done as u64);
if baum {
crate::engine::baum::buche(crate::engine::baum::HU_SETUP_MS + done as f64 * p_baum);
}
crate::engine::baum::log(art.name(), &format!("{} {} {} {}", combos[0], combos[1], nodes, karten), cpu_iter0 - cpu0, crate::engine::frist::thread_cpu_ms() - cpu_iter0, done as u64);
if done < crate::engine::frist::iter_min(art, MIN_TURN_ITERS) {
return weg("zu wenig iterationen");
}
@@ -2115,7 +2168,7 @@ fn turn_decision_neu(raw: &Spot, c: &'static Cfg) -> Option<Decision> {
}
}
let mut breit = false;
if c.turn_gegen_stark_breit && stark_fold && !crate::engine::frist::fixed() && crate::engine::frist::elapsed_ms() > TGSTARK_SPAET_MS {
if c.turn_gegen_stark_breit && stark_fold && (!crate::engine::frist::fixed() && crate::engine::frist::elapsed_ms() > TGSTARK_SPAET_MS || crate::engine::baum::aktiv() && crate::engine::baum::konto() > TGSTARK_SPAET_MS) {
// Keine Zeit fuer die zweite Rechnung: die beste Nicht-Fold-Antwort dieser Rechnung statt des Folds.
if let Some(k2) = (0..g.acts.len()).filter(|&k| !matches!(g.acts[k], Act::Fold)).max_by(|&x, &y| g.werte[x].total_cmp(&g.werte[y])) {
(act, pick, breit) = (g.acts[k2], k2, true);