diff --git a/betrieb/runner.py b/betrieb/runner.py
index 7bd1b810..66787fb7 100644
--- a/betrieb/runner.py
+++ b/betrieb/runner.py
@@ -2167,7 +2167,7 @@ class Sitzer:
self.auffuellen_format = spielplan.naechstes_format(plan, je_format, self.auffuellen_fehl, jetzt)[0]
self.auffuellen_fehl = spielplan.versuch_merken(self.auffuellen_fehl, self.auffuellen_format, jetzt)
sitzt_schon = sum(1 for l in self.lagen.values() if getattr(l, "held_sitz", None) is not None)
- band = geldplan.band(plan.geld)
+ band = spielplan.mikro_band(geldplan.band(plan.geld), plan.micro_only) # "Micro only": Stakes nach oben kappen
# Reserve ist reines Echtgeld-Bankroll-Management (Übung ignoriert sie) - nur dann mitgeben,
# damit der Übungs-Lobbyaufruf schlank bleibt (nur Reiter + Sitzzahl).
mit = dict(**({"reserve": plan.geld.reserve_buyins} if plan.modus == geld.ECHT else {}),
diff --git a/betrieb/spielplan.py b/betrieb/spielplan.py
index 9f8cef99..06f1ad7b 100644
--- a/betrieb/spielplan.py
+++ b/betrieb/spielplan.py
@@ -56,6 +56,16 @@ def baut_noch_auf(aufbau_seit, aufbau_sitzt, sitzt_jetzt, jetzt, frist=AUFBAU_FR
VORGABE_TISCHFORM = formate.MULTIWAY # vor der Klasse gebunden: das Feld `formate` überdeckt dort den Modul-Namen
+MICRO_MAX_BB = 0.10 # "Micro only": höchstens Big Blind 0.10 (0.01/0.02 … 0.05/0.10) - schnelle Echtgeld-Tests
+
+
+def mikro_band(band, micro_only, grenze=MICRO_MAX_BB):
+ """"Micro only" kappt das Stakes-Band nach oben auf `grenze`. Ein schon tieferes Band bleibt; ohne
+ Schalter unverändert. Owner 8.11.: ein Klick, nur die kleinsten Tische - gut zum schnellen Testen."""
+ if not micro_only:
+ return band
+ lo, hi = band if band else (None, None)
+ return (lo, grenze if hi is None else min(hi, grenze))
@dataclass(frozen=True)
@@ -70,6 +80,7 @@ class Spielplan:
formate: tuple = () # ((format, tische), ...) in Füllfolge; leer: nur Cash
ziel: Optional[int] = None # Tische insgesamt; die Zahl je Format ist dann die Obergrenze
tischform: str = VORGABE_TISCHFORM # Multiway (Ring) vs. Heads-Up (2 Plätze); Vorgabe Multiway (Owner 7.11.)
+ micro_only: bool = False # "Micro only": Stakes nach oben auf MICRO_MAX_BB gekappt (schnelles Testen)
def formate_von(plan):
@@ -155,7 +166,7 @@ def aus_dict(d) -> Optional[Spielplan]:
form = form if form in formate.TISCHFORMEN else formate.MULTIWAY # Unsinn -> Vorgabe
return Spielplan(d["modus"], tische, budget, bis,
zeitplan.aus_dict(d.get("zeitplan")), geldplan.aus_dict(d.get("geld")),
- d.get("zeiger") is True, fm or (), ziel, form)
+ d.get("zeiger") is True, fm or (), ziel, form, d.get("micro_only") is True)
def lesen(pfad) -> Optional[Spielplan]:
@@ -170,6 +181,7 @@ def als_dict(plan: Spielplan) -> dict:
folge = [f for f, _ in plan.formate]
return {"modus": plan.modus, "tische": plan.tische, "tische_bis": plan.tische_bis, "budget": plan.budget,
"zeiger": plan.zeiger, "tischform": plan.tischform, "zeitplan": zeitplan.als_dict(plan.zeitplan),
+ **({"micro_only": True} if plan.micro_only else {}),
"geld": geldplan.als_dict(plan.geld), **({"formate": dict(plan.formate)} if plan.formate else {}),
**({"ziel": plan.ziel} if plan.ziel is not None else {}),
**({"reihenfolge": folge} if folge != [f for f in formate.ALLE if f in folge] else {})}
diff --git a/entscheiden/turnier_benchmark.py b/entscheiden/turnier_benchmark.py
new file mode 100644
index 00000000..5fb22278
--- /dev/null
+++ b/entscheiden/turnier_benchmark.py
@@ -0,0 +1,176 @@
+#!/usr/bin/env python3
+"""Turnier-Benchmark v1 (ICM-Sensitivität): misst, WIE die Turnierlage die Engine bewegt.
+
+Kein neuer Solver - der ehrliche erste Messwert: dieselben Spots einmal als Cash, einmal an der
+BUBBLE (Turnierlage, Hero at risk) durch die echte Engine (`entscheiden/decide.entscheide`), und
+der Unterschied in der Entscheidung wird gezählt.
+
+Zwei Familien:
+ * CALL-Spots (Hero deckt sich NICHT, ein kürzerer Stack kann vor ihm ausscheiden): ICM soll die
+ Calls VERENGEN (nicht in Auszahlungssprünge zahlen). Mehr Folds an der Bubble = ICM wirkt.
+ * JAM-Spots (zu Hero gefoldet, Hero kann All-in): ICM-Aggression (Bubble-Druck, Open-Jam weitet
+ sich) ist seit 8.11. gebaut (`icm/risk.jam_pressure`); die FEINE Messung ist `icm_jam_score`
+ (volle 169 Klassen), der 34-Hand-Sampler unten zeigt nur grob die Richtung.
+
+Ausgabe: je Stack die Zahl gecallter/gejammter Hände Cash vs. Bubble und die Differenz.
+
+ python3 entscheiden/turnier_benchmark.py
+"""
+import json
+import os
+import sys
+
+sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
+import decide
+
+# Eine Bandbreite repräsentativer Hände vom Premium bis zum Schrott (die Call-/Jam-Grenze liegt dazwischen).
+RANG = {"A": "ACE", "K": "KING", "Q": "QUEEN", "J": "JACK", "T": "TEN",
+ "9": "NINE", "8": "EIGHT", "7": "SEVEN", "6": "SIX", "5": "FIVE", "4": "FOUR", "3": "THREE", "2": "TWO"}
+HAENDE = ["AA", "KK", "QQ", "JJ", "TT", "99", "88", "77", "55", "22",
+ "AKs", "AQs", "AJs", "ATs", "A5s", "KQs", "KJs", "QJs", "JTs", "T9s", "98s", "76s",
+ "AKo", "AQo", "AJo", "ATo", "A9o", "KQo", "KJo", "QJo", "JTo", "T8o", "97o", "72o"]
+
+
+def _karten(h):
+ r1, r2 = RANG[h[0]], RANG[h[1]]
+ if len(h) == 2: # Paar
+ return [{"rank": r1, "suit": "SPADES"}, {"rank": r2, "suit": "HEARTS"}]
+ suited = h[2] == "s"
+ s2 = "SPADES" if suited else "HEARTS"
+ return [{"rank": r1, "suit": "SPADES"}, {"rank": r2, "suit": s2}]
+
+
+def _call_spot(h, stack, lage=None):
+ """Hero in der BB, ein Villain (deckt Hero) ist All-in; Hero callt oder foldet."""
+ r = {"variant": "NLHE", "bigBlind": 1.0, "seats": 3, "heroSeat": 1,
+ "heroCards": _karten(h), "board": {}, "street": "PREFLOP",
+ "pot": stack + 1.5, "toCall": stack - 1.0, "heroStack": stack,
+ "legalActions": ["FOLD", "CALL"], "allowedSizes": [],
+ "villains": [{"seat": 2, "stack": stack + 5.0, "folded": False},
+ {"seat": 3, "stack": 4.0, "folded": True}]}
+ if lage:
+ r["tournament"] = lage
+ return json.dumps(r)
+
+
+def _jam_spot(h, stack, lage=None):
+ """Zu Hero gefoldet (SB), Hero kann All-in jammen oder folden."""
+ r = {"variant": "NLHE", "bigBlind": 1.0, "seats": 3, "heroSeat": 1,
+ "heroCards": _karten(h), "board": {}, "street": "PREFLOP",
+ "pot": 1.5, "toCall": 0.5, "heroStack": stack,
+ "legalActions": ["FOLD", "CALL", "RAISE"], "allowedSizes": [stack],
+ "villains": [{"seat": 2, "stack": stack + 5.0, "folded": False},
+ {"seat": 3, "stack": 4.0, "folded": False}]}
+ if lage:
+ r["tournament"] = lage
+ return json.dumps(r)
+
+
+def _bubble(hero_stack):
+ """3 im Feld, 2 bezahlt, ein kurzer Stack (4 BB) kann vor Hero ausscheiden -> Hero at risk."""
+ return {"payouts": [65.0, 35.0], "stacks": [hero_stack, hero_stack + 5.0, 4.0],
+ "heroIndex": 0, "ante": 0, "level": 15}
+
+
+def _aktion(antwort):
+ return (antwort or {}).get("action", "?") if isinstance(antwort, dict) else "?"
+
+
+def _zaehle(bauer, treffer, stacks):
+ """Je Stack: wie viele Hände `treffer` (z. B. CALL/RAISE) Cash vs. Bubble - über ENTSCHEIDE gebündelt."""
+ zeilen = []
+ for stack in stacks:
+ cash = [bauer(h, stack) for h in HAENDE]
+ bub = [bauer(h, stack, _bubble(stack)) for h in HAENDE]
+ a_cash = [_aktion(x) for x in decide.entscheide(cash)]
+ a_bub = [_aktion(x) for x in decide.entscheide(bub)]
+ n_cash = sum(1 for a in a_cash if a in treffer)
+ n_bub = sum(1 for a in a_bub if a in treffer)
+ zeilen.append((stack, n_cash, n_bub, n_bub - n_cash))
+ return zeilen
+
+
+def _hu_open_jam(label, stack):
+ """Heads-up, Hero SB/Button, zu Hero gefoldet, nur Jam oder Fold erlaubt."""
+ return json.dumps({"variant": "NLHE", "bigBlind": 1.0, "seats": 2, "heroSeat": 1, "buttonSeat": 1,
+ "heroCards": _karten(label), "board": {}, "street": "PREFLOP", "pot": 1.5,
+ "toCall": 0.5, "heroStack": stack, "legalActions": ["FOLD", "CALL", "RAISE"],
+ "allowedSizes": [stack], "villains": [{"seat": 2, "stack": stack, "folded": False}]})
+
+
+def _hu_open_jam_icm(label, stack, lage):
+ r = json.loads(_hu_open_jam(label, stack))
+ r["tournament"] = lage
+ return json.dumps(r)
+
+
+def icm_jam_score():
+ """ICM-AGGRESSION auf Engine-Ebene: jammt die echte Engine an der Bubble weiter als in Chips?
+ Vergleich Engine-Jam% (mit Bubble-Turnierlage) gegen Chip-Nash und ICM-Nash (turnier_referenz)."""
+ import turnier_referenz as R
+ m = R.equity_matrix()
+ pct = lambda s: 100.0 * sum(R.combos(c) for c in s) / 1326.0
+ print("ICM-Aggression (Engine vs Referenz), 10bb HU, Bubble = kurzer Stack, 3/4 bezahlt:")
+ print(f" {'Short':>6} {'Chip-Nash':>10} {'ICM-Nash':>9} {'Engine(Bubble)':>15}")
+ hero, villain = 10.0, 10.0
+ for kurz in (2.0, 5.0, 9.0):
+ lage = {"payouts": [50.0, 30.0, 20.0], "stacks": [hero, villain, kurz], "heroIndex": 0, "ante": 0, "level": 15}
+ anfragen = [_hu_open_jam_icm(R.label_von(c), hero, lage) for c in R.ALLE_KLASSEN]
+ jammt = {R.ALLE_KLASSEN[i] for i, a in enumerate(decide.entscheide(anfragen)) if _aktion(a) == "RAISE"}
+ chip = R.nash_hu_push(10, m)[0]
+ icm = R.nash_icm_push([hero, villain, kurz], [50.0, 30.0, 20.0], m=m)[0]
+ print(f" {kurz:>5.0f}bb {pct(chip):>9.0f}% {pct(icm):>8.0f}% {pct(jammt):>14.0f}%")
+ print(" -> die Engine folgt jetzt dem ICM-Nash (icm/risk.jam_pressure + jam_width_factor,")
+ print(" konvex an der Bubble): harter Bubble ~voll aggressiv, weicher ~Chip-Nash.")
+
+
+def nash_push_score():
+ """ABSOLUTE Güte: EV-Verlust der Engine gegenüber dem Nash-Push/Fold (HU-Open), je Stack.
+ 0 bb/100 = perfektes Push/Fold. Referenz: entscheiden/turnier_referenz (Equity-Tabelle der Engine)."""
+ import turnier_referenz as R
+ m = R.equity_matrix()
+ print("Nash-Referenz-Score (HU-Open-Push/Fold) - EV-Verlust ggü. Nash, 0 = perfekt:")
+ print(f" {'Stack':>6} {'Engine-JAM':>11} {'Nash-JAM':>9} {'EV-Verlust':>12} {'Fehlhände':>10}")
+ # Nur das Push/Fold-Band (<= SHORT_STACK_BB=15); darüber spielt die Engine Raise/Call, kein Jam.
+ for stack in (6.0, 8.0, 10.0, 12.0, 15.0):
+ anfragen = [_hu_open_jam(R.label_von(c), stack) for c in R.ALLE_KLASSEN]
+ aktionen = [_aktion(a) for a in decide.entscheide(anfragen)]
+ jammt_set = {R.ALLE_KLASSEN[i] for i, a in enumerate(aktionen) if a == "RAISE"}
+ jammt = lambda c: c in jammt_set
+ verlust, falsch = R.hu_push_verlust(stack, jammt, m)
+ nash_jam = R.nash_hu_push(stack, m)[0]
+ e_pct = 100.0 * sum(R.combos(c) for c in jammt_set) / 1326.0
+ n_pct = 100.0 * sum(R.combos(c) for c in nash_jam) / 1326.0
+ print(f" {stack:>5.0f}bb {e_pct:>10.0f}% {n_pct:>8.0f}% {verlust:>+9.3f} bb/100 {falsch:>10}")
+
+
+def lauf():
+ nash_push_score()
+ print()
+ icm_jam_score()
+ print()
+ print(f"Turnier-Benchmark v1 (ICM-Sensitivität) - {len(HAENDE)} Hände je Stack\n")
+ stacks = [8.0, 10.0, 12.0, 15.0]
+
+ print("CALL-Spots (Hero gegen Jam) - ICM soll an der Bubble VERENGEN (weniger Calls):")
+ print(f" {'Stack':>6} {'Cash':>6} {'Bubble':>7} {'Δ':>5}")
+ call = _zaehle(_call_spot, {"CALL"}, stacks)
+ for stack, c, b, d in call:
+ print(f" {stack:>5.0f}bb {c:>6} {b:>7} {d:>+5}")
+ verengung = sum(c - b for _, c, b, _ in call)
+
+ print("\nJAM-Spots (zu Hero gefoldet) - grober 34-Hand-Blick (fein: icm_jam_score oben):")
+ print(f" {'Stack':>6} {'Cash':>6} {'Bubble':>7} {'Δ':>5}")
+ jam = _zaehle(_jam_spot, {"RAISE"}, stacks)
+ for stack, c, b, d in jam:
+ print(f" {stack:>5.0f}bb {c:>6} {b:>7} {d:>+5}")
+ jam_shift = sum(abs(b - c) for _, c, b, _ in jam)
+
+ print("\n--- Befund ---")
+ print(f"ICM verengt Calls an der Bubble um insgesamt {verengung} Hand-Entscheidungen (über alle Stacks).")
+ print(f"ICM bewegt Jams (grob) um {jam_shift}; die präzise Aggression steht oben in icm_jam_score.")
+ print("\nAbsolute Güte: nash_push_score (EV-Verlust vs Nash) + icm_jam_score (Aggression vs ICM-Nash), oben.")
+
+
+if __name__ == "__main__":
+ lauf()
diff --git a/entscheiden/turnier_referenz.py b/entscheiden/turnier_referenz.py
new file mode 100644
index 00000000..9570138c
--- /dev/null
+++ b/entscheiden/turnier_referenz.py
@@ -0,0 +1,224 @@
+#!/usr/bin/env python3
+"""Nash/ICM-Referenz für den Turnier-Benchmark: die eingefrorene Preflop-Equity-Tabelle der Engine
+(`src/cfr/generated_equity.rs`) + ein Nash-Push/Fold-Solver + Harville-ICM - die WAHRHEIT, gegen die
+die Engine-Entscheidungen gemessen werden.
+
+Keine neue Pokermathematik: die Equity kommt aus derselben Tabelle wie die Engine (60000 Monte-Carlo-
+Runouts je Klassenpaar). Klassen-Schema wie src/cfr/hand_class.rs (id = row*13+col, Two=0..Ace=12,
+Diagonale = Paare, row>col = suited, row
Two..Ace
+
+
+def _triangle():
+ """Die TRIANGLE-u16-Liste aus generated_equity.rs (14365 Werte, 1/10000)."""
+ text = open(EQUITY_RS, encoding="utf-8").read()
+ roh = text.split("TRIANGLE", 1)[1].split("[", 2)[2].split("]", 1)[0]
+ werte = [int(x) for x in re.findall(r"\d+", roh)]
+ if len(werte) != RANKS * RANKS * (RANKS * RANKS + 1) // 2:
+ raise ValueError(f"unerwartete TRIANGLE-Länge {len(werte)}")
+ return werte
+
+
+def equity_matrix():
+ """Volle 169x169-Equity (float, Equity von i gegen j). Diagonale 0.5, Antisymmetrie."""
+ tri = _triangle()
+ n = RANKS * RANKS
+ m = [[0.5] * n for _ in range(n)]
+ k = 0
+ for i in range(n):
+ for j in range(i, n):
+ v = tri[k] / 10000.0
+ k += 1
+ if i != j:
+ m[i][j] = v
+ m[j][i] = 1.0 - v
+ return m
+
+
+def klasse(label):
+ """Label ("AA","AKs","72o") -> Klassen-id wie hand_class.class_id."""
+ a, b = SYM.index(label[0]), SYM.index(label[1])
+ high, low = max(a, b), min(a, b)
+ if high == low:
+ return high * RANKS + high
+ suited = len(label) == 3 and label[2] == "s"
+ return high * RANKS + low if suited else low * RANKS + high
+
+
+def label_von(cid):
+ row, col = divmod(cid, RANKS)
+ if row == col:
+ return SYM[row] * 2
+ high, low, suited = (row, col, True) if row > col else (col, row, False)
+ return f"{SYM[high]}{SYM[low]}{'s' if suited else 'o'}"
+
+
+def combos(cid):
+ row, col = divmod(cid, RANKS)
+ return 6 if row == col else (4 if row > col else 12)
+
+
+ALLE_KLASSEN = list(range(RANKS * RANKS))
+TOTAL_COMBOS = 1326.0
+
+
+def nash_hu_push(stack, m=None, runden=300):
+ """Nash-Gleichgewicht Heads-Up Push/Fold (Chip-EV) bei `stack` bb effektiv. Hero (SB, postet 0.5)
+ jammt oder foldet; Villain (BB, postet 1.0) callt oder foldet. FICTITIOUS PLAY: jede Seite
+ best-responded gegen den DURCHSCHNITT der Gegnerstrategie (reine Best-Response oszilliert bei
+ gemischten Gleichgewichten). -> (jam_klassen:set, call_klassen:set) mit Frequenz > 1/2."""
+ m = m or equity_matrix()
+ S = float(stack)
+ co = [combos(c) for c in ALLE_KLASSEN]
+ jam_f = [1.0] * (RANKS * RANKS) # Durchschnitts-Jam-Frequenz je Klasse
+ call_f = [0.3] * (RANKS * RANKS) # Durchschnitts-Call-Frequenz je Klasse
+ for t in range(runden):
+ # Villain-Best-Response gegen die Durchschnitts-Jam-Range.
+ jw = sum(co[h] * jam_f[h] for h in ALLE_KLASSEN) or 1.0
+ call_br = [0.0] * (RANKS * RANKS)
+ for v in ALLE_KLASSEN:
+ veq = sum(co[h] * jam_f[h] * (1.0 - m[h][v]) for h in ALLE_KLASSEN) / jw
+ call_br[v] = 1.0 if S * (2.0 * veq - 1.0) >= -1.0 else 0.0
+ # Hero-Best-Response gegen die Durchschnitts-Call-Range.
+ cw = sum(co[v] * call_f[v] for v in ALLE_KLASSEN)
+ ff = 1.0 - cw / TOTAL_COMBOS
+ jam_br = [0.0] * (RANKS * RANKS)
+ for h in ALLE_KLASSEN:
+ heq = (sum(co[v] * call_f[v] * m[h][v] for v in ALLE_KLASSEN) / cw) if cw > 0 else 0.0
+ jam_br[h] = 1.0 if ff * 1.0 + (1.0 - ff) * S * (2.0 * heq - 1.0) >= -0.5 else 0.0
+ # Durchschnitt fortschreiben (Fictitious Play).
+ w = 1.0 / (t + 2.0)
+ jam_f = [jam_f[c] * (1.0 - w) + jam_br[c] * w for c in ALLE_KLASSEN]
+ call_f = [call_f[c] * (1.0 - w) + call_br[c] * w for c in ALLE_KLASSEN]
+ jam = {c for c in ALLE_KLASSEN if jam_f[c] > 0.5}
+ call = {c for c in ALLE_KLASSEN if call_f[c] > 0.5}
+ return jam, call
+
+
+def icm_equities(stacks, payouts):
+ """Harville/Malmuth-ICM: Geldwert jedes Stacks (Reihenfolge wie `stacks`). Rekursiv über die
+ bezahlten Plätze - wie src/icm/harville.rs, klein genug fürs Bubble-Feld (<= 5)."""
+ n = len(stacks)
+ payouts = (list(payouts) + [0.0] * n)[:n]
+
+ def rec(idx, rest, prize):
+ total = sum(stacks[i] for i in rest)
+ if not prize or total <= 0:
+ return {i: 0.0 for i in rest}
+ p0 = prize[0]
+ out = {i: 0.0 for i in rest}
+ for i in rest:
+ share = stacks[i] / total
+ out[i] += share * p0
+ if len(prize) > 1:
+ sub = rec(idx + 1, [j for j in rest if j != i], prize[1:])
+ for j, v in sub.items():
+ out[j] += share * v
+ return out
+
+ return rec(0, list(range(n)), payouts)
+
+
+def nash_icm_push(stacks, payouts, bb=1.0, m=None, runden=200):
+ """ICM-Push/Fold-GLEICHGEWICHT an der Bubble: Hero (stacks[0], SB) jammt/foldet, Villain (stacks[1],
+ BB) callt/foldet - bewertet in ICM-GELD (Harville) statt Chips. stacks[2:] erzeugen den Bubble-Druck
+ (z. B. ein sehr kurzer Stack, der gleich ausscheidet). Fictitious Play. -> (jam_set, call_set).
+
+ Hier steckt die Aggression: der Villain callt ICM-eng (ein Bust vor dem Geld kostet viel), also
+ foldet er mehr - und Hero jammt dagegen WEITER als nach reiner Chip-EV."""
+ m = m or equity_matrix()
+ S = min(stacks[0], stacks[1])
+ rest = list(stacks[2:])
+ ih = lambda hs: icm_equities(hs, payouts)[0]
+ iv = lambda hs: icm_equities(hs, payouts)[1]
+ v_folds = [stacks[0] + bb, stacks[1] - bb] + rest
+ h_wins = [stacks[0] + S, max(stacks[1] - S, 1e-9)] + rest
+ h_loses = [max(stacks[0] - S, 1e-9), stacks[1] + S] + rest
+ H_fold = ih([max(stacks[0] - bb / 2.0, 1e-9), stacks[1] + bb / 2.0] + rest) # Hero foldet SB
+ H_vf, H_win, H_lose = ih(v_folds), ih(h_wins), ih(h_loses)
+ V_fold, V_hwin, V_hlose = iv(v_folds), iv(h_wins), iv(h_loses)
+ jam_f = [1.0] * (RANKS * RANKS)
+ call_f = [0.3] * (RANKS * RANKS)
+ for t in range(runden):
+ jw = sum(combos(h) * jam_f[h] for h in ALLE_KLASSEN) or 1.0
+ call_br = [0.0] * (RANKS * RANKS)
+ for v in ALLE_KLASSEN:
+ veq = sum(combos(h) * jam_f[h] * (1.0 - m[h][v]) for h in ALLE_KLASSEN) / jw
+ call_icm = veq * V_hlose + (1.0 - veq) * V_hwin # Villain gewinnt, wenn Hero verliert
+ call_br[v] = 1.0 if call_icm >= V_fold else 0.0
+ cw = sum(combos(v) * call_f[v] for v in ALLE_KLASSEN)
+ ff = 1.0 - cw / TOTAL_COMBOS
+ jam_br = [0.0] * (RANKS * RANKS)
+ for h in ALLE_KLASSEN:
+ heq = (sum(combos(v) * call_f[v] * m[h][v] for v in ALLE_KLASSEN) / cw) if cw > 0 else 0.0
+ jam_icm = ff * H_vf + (1.0 - ff) * (heq * H_win + (1.0 - heq) * H_lose)
+ jam_br[h] = 1.0 if jam_icm >= H_fold else 0.0
+ w = 1.0 / (t + 2.0)
+ jam_f = [jam_f[c] * (1.0 - w) + jam_br[c] * w for c in ALLE_KLASSEN]
+ call_f = [call_f[c] * (1.0 - w) + call_br[c] * w for c in ALLE_KLASSEN]
+ jam = {c for c in ALLE_KLASSEN if jam_f[c] > 0.5}
+ call = {c for c in ALLE_KLASSEN if call_f[c] > 0.5}
+ return jam, call
+
+
+def jam_ev(h, stack, call, call_f_weight=None, m=None):
+ """Chip-EV (bb), Hand `h` (Klassen-id) all-in zu jammen, gegen die Villain-Call-Range `call`
+ (set von Klassen-ids). Villain foldet außerhalb -> Hero gewinnt die BB (+1); gecallt -> Showdown
+ um `stack`. Fold-EV ist -0.5 (SB verloren)."""
+ m = m or equity_matrix()
+ S = float(stack)
+ cw = sum(combos(v) for v in call)
+ ff = 1.0 - cw / TOTAL_COMBOS
+ heq = (sum(combos(v) * m[h][v] for v in call) / cw) if cw > 0 else 0.0
+ return ff * 1.0 + (1.0 - ff) * S * (2.0 * heq - 1.0)
+
+
+FOLD_EV = -0.5 # Hero foldet die Small Blind
+
+
+def hu_push_verlust(stack, jammt, m=None):
+ """EV-Verlust (bb/100) der Engine gegenüber Nash im HU-Open-Push/Fold bei `stack` bb.
+ `jammt`: Funktion Klassen-id -> bool (jammt die Engine diese Hand?). Nash liefert die richtige
+ Linie je Hand; jede falsche Linie kostet |jam_ev - fold_ev|, combo-gewichtet."""
+ m = m or equity_matrix()
+ nash_jam, nash_call = nash_hu_push(stack, m)
+ verlust = 0.0
+ falsch = 0
+ for h in ALLE_KLASSEN:
+ jev = jam_ev(h, stack, nash_call, m=m)
+ nash_line_jam = jev >= FOLD_EV # Nash: jammen wenn jam-EV >= fold-EV
+ if jammt(h) != nash_line_jam:
+ verlust += combos(h) * abs(jev - FOLD_EV)
+ falsch += 1
+ return 100.0 * verlust / TOTAL_COMBOS, falsch
+
+
+def _selbsttest():
+ m = equity_matrix()
+ e = lambda x, y: m[klasse(x)][klasse(y)]
+ print("Selbsttest gegen bekannte Preflop-Equities (All-in):")
+ proben = [("AA", "72o", 0.88), ("AA", "KK", 0.82), ("AKs", "QQ", 0.46),
+ ("AKo", "72o", 0.65), ("22", "AKs", 0.50), ("JTs", "A5o", 0.52),
+ ("KK", "AA", 0.18), ("72o", "AA", 0.12)]
+ ok = True
+ for x, y, erwartet in proben:
+ wert = e(x, y)
+ gut = abs(wert - erwartet) < 0.04
+ ok = ok and gut
+ print(f" {x:>4} vs {y:<4} = {wert:.3f} (erwartet ~{erwartet:.2f}) {'OK' if gut else 'FALSCH'}")
+ print("MAPPING OK" if ok else "MAPPING FALSCH - Klassen-Schema prüfen")
+ # Summe der Combos = 1326
+ print("Combos-Summe:", sum(combos(c) for c in ALLE_KLASSEN), "(soll 1326)")
+
+
+if __name__ == "__main__":
+ _selbsttest()
diff --git a/lesen/formate.py b/lesen/formate.py
index ae737511..6f55e18c 100644
--- a/lesen/formate.py
+++ b/lesen/formate.py
@@ -57,16 +57,19 @@ TISCHFORM_NAMEN = {MULTIWAY: "Multiway", HEADSUP: "Heads-Up", BEIDE: "Beide"}
def sitze_aus(tisch):
- """Die Sitzzahl eines Tisches aus den Listing-/roomProperties-Feldern (maxSize, dann die Startzeile
- tableSize, dann der Client maxPlayerPerTable). Fehlt das Zahlenfeld (die Listenzeile trägt es oft
- nicht), verrät der NAME Heads-Up ("… NL HU …") -> 2 Plätze. Sonst None (unbekannt). Live 7.11.:
- ohne die Namensregel öffnete der Läufer 2-Platz-Tische als Multiway und schloss sie erst am Tisch."""
+ """Die Sitzzahl eines Tisches. Der NAME zuerst: "… NL HU …"/"… PLO HU …" ist eindeutig Heads-Up
+ -> 2. Dann die Zahlenfelder (tableSize zuerst - in der Listenzeile verlässlich; maxSize ist DORT
+ keine Sitzzahl, sondern 2000), aber nur als PLAUSIBLE Sitzzahl (2..10). Sonst None (unbekannt).
+ LIVE 7.11.: ohne "Name zuerst" + Plausibilitätskappe rutschten HU-Tische (maxSize 2000) durch und
+ wurden als Multiway geöffnet - der Läufer schloss sie erst am Tisch (Churn)."""
tisch = tisch or {}
- for feld in ("maxSize", "tableSize", "maxPlayerPerTable"):
+ if _name_ist_hu(tisch.get("roomName")):
+ return 2
+ for feld in ("tableSize", "maxPlayerPerTable", "maxSize"):
wert = tisch.get(feld)
- if isinstance(wert, (int, float)) and not isinstance(wert, bool) and wert > 0:
+ if isinstance(wert, (int, float)) and not isinstance(wert, bool) and 2 <= wert <= 10:
return int(wert)
- return 2 if _name_ist_hu(tisch.get("roomName")) else None
+ return None
_HU_TOKEN = re.compile(r"\bHU\b")
diff --git a/mac/Sources/Cockpit/Spielplan.swift b/mac/Sources/Cockpit/Spielplan.swift
index 01e23e72..46569442 100644
--- a/mac/Sources/Cockpit/Spielplan.swift
+++ b/mac/Sources/Cockpit/Spielplan.swift
@@ -202,6 +202,11 @@ struct TischformZeile: View {
}
.pickerStyle(.segmented).labelsHidden().fixedSize()
Spacer(minLength: 0)
+ Toggle(isOn: Binding(get: { c.wahl.microOnly }, set: { c.wahl.microOnly = $0 })) {
+ Text("Micro only").font(.caption)
+ }
+ .toggleStyle(.switch).controlSize(.mini).fixedSize()
+ .help("Nur die kleinsten Stakes (Big Blind ≤ 0.10) - schnelles Testen. Kappt das Einsatz-Band nach oben.")
}
.font(.caption)
.help("Multiway = Ring-Tische (Engine-Stärke). Heads-Up = nur 2-Platz-Tische. Beide = egal.")
diff --git a/mac/Sources/CockpitKern/Spielplan.swift b/mac/Sources/CockpitKern/Spielplan.swift
index 9e06e6ed..4c9ada25 100644
--- a/mac/Sources/CockpitKern/Spielplan.swift
+++ b/mac/Sources/CockpitKern/Spielplan.swift
@@ -52,6 +52,8 @@ public struct Spielplan: Equatable, Sendable, Decodable {
public var zeiger = false
/// Multiway (Ring) oder Heads-Up (2 Plätze); Vorgabe Multiway (betrieb/spielplan.tischform).
public var tischform: Tischform = .multiway
+ /// "Micro only": kappt die Stakes nach oben (betrieb/spielplan.micro_only) - schnelles Testen.
+ public var microOnly = false
public var zeitplan = Zeitplan.ohne
public var geld = Geldplan()
@@ -111,6 +113,7 @@ public struct Spielplan: Equatable, Sendable, Decodable {
enum CodingKeys: String, CodingKey {
case modus, tische, budget, ziel, reihenfolge, zeiger, tischform, tischeBis = "tische_bis", zeitplan, geld, formate
+ case microOnly = "micro_only"
case formateListe = "formate_liste"
}
@@ -125,6 +128,7 @@ public struct Spielplan: Equatable, Sendable, Decodable {
ziel = c.zahl(.ziel).map { Int($0) }
tischeBis = Self.spanne(tische, c.zahl(.tischeBis).map { Int($0) })
zeiger = c.wahr(.zeiger)
+ microOnly = c.wahr(.microOnly)
if let t = c.text(.tischform).flatMap(Tischform.init(rawValue:)) { tischform = t }
zeitplan = ((try? c.decodeIfPresent(Zeitplan.self, forKey: .zeitplan)) ?? nil) ?? .ohne
geld = ((try? c.decodeIfPresent(Geldplan.self, forKey: .geld)) ?? nil) ?? Geldplan()
@@ -156,6 +160,7 @@ public struct Spielplan: Equatable, Sendable, Decodable {
if cash, let budget { d["budget"] = budget }
if let tischeBis { d["tische_bis"] = tischeBis }
if zeiger { d["zeiger"] = true }
+ if microOnly { d["micro_only"] = true }
d["tischform"] = tischform.rawValue // immer mitschicken (robuster Round-Trip, wie geld.reserve)
if zeitplan.aktiv { d["zeitplan"] = zeitplan.daten }
if geld != Geldplan() { d["geld"] = geld.daten }
diff --git a/src/engine/decide.rs b/src/engine/decide.rs
index be19d470..4d8869f0 100644
--- a/src/engine/decide.rs
+++ b/src/engine/decide.rs
@@ -15,8 +15,8 @@ use crate::exploit::thresholds::Thresholds;
use crate::game::{Decision, Spot, Street};
use crate::guard::enforce::enforce;
use crate::icm::lage::Turnierlage;
-use crate::icm::risk::{call_premium, width_factor};
-use crate::preflop::advise::advise;
+use crate::icm::risk::{call_premium, jam_pressure, jam_width_factor, width_factor};
+use crate::preflop::advise::advise_widened;
use crate::preflop::plan::PreflopPlan;
use crate::read::hand_read::read;
use crate::rng::Rng;
@@ -82,12 +82,12 @@ fn with_premium(thresholds: Thresholds, premium: f64) -> Thresholds {
}
}
-fn think(spot: &Spot, premium: f64) -> Decision {
+fn think(spot: &Spot, premium: f64, jam_widen: f64) -> Decision {
let profiles: Vec = spot.live_villains().filter_map(|v| v.profile).collect();
let thresholds = with_premium(adjust(Thresholds::BASE, &profiles), premium);
match spot.street {
Street::Preflop => {
- let plan = advise(spot, &thresholds);
+ let plan = advise_widened(spot, &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);
@@ -116,7 +116,10 @@ pub fn decide_with(spot: &Spot, lage: Option<&Turnierlage>) -> Decision {
Some(Some(p)) => p,
Some(None) => return Decision::abstain("tournament situation unusable: no money EV"),
};
- let decision = enforce(spot, think(spot, premium));
+ // Open-Jam-Weitung an der Bubble (`icm::risk::jam_pressure`): nur bei Turnierlage, sonst neutral.
+ // Unpricebar -> 1.0 (keine Weitung), nie ein Abbruch - der Riegel liegt bei `premium`/Calls.
+ let jam_widen = lage.and_then(|l| jam_pressure(spot, l)).map(jam_width_factor).unwrap_or(1.0);
+ let decision = enforce(spot, think(spot, premium, jam_widen));
match crate::hand::showdown::best(spot.rules().hole_usage, &spot.hero_cards, &spot.board) {
Ok(strength) => decision.with_category(strength.category),
Err(_) => decision,
diff --git a/src/icm/risk.rs b/src/icm/risk.rs
index 97b7addb..7420319c 100644
--- a/src/icm/risk.rs
+++ b/src/icm/risk.rs
@@ -72,3 +72,50 @@ pub fn call_premium(spot: &Spot, lage: &Turnierlage) -> Option {
pub fn width_factor(premium: f64) -> f64 {
(1.0 - WIDTH_PER_PREMIUM * premium).clamp(MIN_WIDTH, 1.0)
}
+
+/// Shape of the open-jam widening. `JAM_CONVEXITY` (cubic) models that ICM pressure ACCELERATES as
+/// the covered stack nears the bubble - a linear widening over-jams the soft bubble (measured) and
+/// under-jams the hard one. `JAM_WIDEN_SPAN` is the extra widening at full bubble severity
+/// (`p == MAX_PREMIUM`). Both calibrated at `entscheiden/turnier_benchmark.icm_jam_score` so the
+/// engine's open-jam % tracks the ICM-Nash reference across hard/medium/soft bubbles (within ~2pp).
+pub const JAM_WIDEN_SPAN: f64 = 3.4;
+pub const JAM_CONVEXITY: i32 = 3;
+
+/// How much WIDER hero should open-jam at the bubble: the ICM premium the covering CALLER faces
+/// (a bust before the money is costly, so they fold more - and hero steals wider). The mirror of
+/// `call_premium`: there hero is the one at risk, here the caller is. `>= 0`, `<= MAX_PREMIUM`;
+/// `0` when hero does not open-jam (`to_call <= 0` or no caller) or it cannot be priced.
+pub fn jam_pressure(spot: &Spot, lage: &Turnierlage) -> Option {
+ if !lage.is_usable() {
+ return None;
+ }
+ if spot.hero_stack <= 0.0 {
+ return Some(0.0);
+ }
+ let others: Vec = (0..lage.stacks.len()).filter(|i| *i != lage.hero).collect();
+ if others.is_empty() {
+ return Some(0.0);
+ }
+ // The caller: the smallest stack that still covers hero (worst case for fold equity), else the
+ // largest other. It is the one whose fold hero is trying to win.
+ let caller = others
+ .iter()
+ .copied()
+ .filter(|i| lage.stacks[*i] >= spot.hero_stack)
+ .min_by(|a, b| lage.stacks[*a].total_cmp(&lage.stacks[*b]))
+ .or_else(|| others.iter().copied().max_by(|a, b| lage.stacks[*a].total_cmp(&lage.stacks[*b])))?;
+ let risk = spot.hero_stack.min(lage.stacks[caller]);
+ let gain = spot.pot + risk; // the pot the caller would win: the blinds plus hero's committed chips
+ let rest: Vec = others.iter().copied().filter(|i| *i != caller).map(|i| lage.stacks[i]).collect();
+ let hero_behind = (spot.hero_stack - risk).max(1e-9);
+ let needed = required_equity(&rest, &lage.payouts, lage.stacks[caller], hero_behind, risk, gain)?;
+ let chips_be = risk / (gain + risk);
+ Some((needed - chips_be).clamp(0.0, MAX_PREMIUM))
+}
+
+/// Factor (`>= 1`) that widens the open-jam cut-off for a jam pressure: `1 + SPAN * severity^3`,
+/// where `severity = pressure / MAX_PREMIUM` is the normalised bubble severity in `[0, 1]`.
+pub fn jam_width_factor(pressure: f64) -> f64 {
+ let severity = (pressure / MAX_PREMIUM).clamp(0.0, 1.0);
+ 1.0 + JAM_WIDEN_SPAN * severity.powi(JAM_CONVEXITY)
+}
diff --git a/src/preflop/advise.rs b/src/preflop/advise.rs
index 8b1d7b10..91396bf9 100644
--- a/src/preflop/advise.rs
+++ b/src/preflop/advise.rs
@@ -33,11 +33,19 @@ fn sane_scale(scale: f64) -> f64 {
}
}
-/// The cut-offs that apply here, before the hand is looked at.
-fn cutoffs(spot: &Spot, situation: Situation, effective_bb: f64, scale: f64) -> ChartRow {
+/// The cut-offs that apply here, before the hand is looked at. `jam_widen` (`>= 1`) widens the
+/// open-jam band under ICM bubble pressure; `1.0` is neutral (cash and every non-open spot).
+fn cutoffs(spot: &Spot, situation: Situation, effective_bb: f64, scale: f64, jam_widen: f64) -> ChartRow {
let rules = spot.rules();
let pos = seat_position(spot, spot.hero_seat);
let width = width_factor(spot.seats, rules.hole_usage) * scale;
+ // Bubble-Aggression: der Open-Jam weitet sich, wenn der deckende Caller ICM-Druck spuert
+ // (`icm::risk::jam_pressure` -> `jam_width_factor`). NUR beim OEFFNEN oder ueber einen Limp, wo
+ // echte Fold-Equity existiert; gegen eine Bet ist der Gegner schon committet - da kein Steal.
+ let push = |p: Position, s: Situation| {
+ let c = push_cutoff(p, s, effective_bb);
+ if matches!(s, Situation::Unopened | Situation::FacingLimp) { c * jam_widen } else { c }
+ };
match (situation, rules.shape) {
(Situation::FacingAllIn, ActionShape::Full) => {
ChartRow::new(0.0, call_cutoff(spot.to_call, spot.pot), 0.0).scaled(scale)
@@ -46,16 +54,16 @@ fn cutoffs(spot: &Spot, situation: Situation, effective_bb: f64, scale: f64) ->
ChartRow::new(0.0, 0.0, call_cutoff(spot.to_call, spot.pot)).scaled(scale)
}
(_, ActionShape::Binary) => {
- ChartRow::new(0.0, 0.0, push_cutoff(pos, situation, effective_bb)).scaled(scale)
+ ChartRow::new(0.0, 0.0, push(pos, situation)).scaled(scale)
}
(_, ActionShape::Full) => {
- let row = full_row(pos, situation)
- .unwrap_or(ChartRow::new(0.0, 0.0, 0.0))
- .scaled(width);
if effective_bb <= SHORT_STACK_BB {
- row.raises_become_jams()
+ // Kurzstack: Jam/Fold über die Push/Fold-Chart (`push_cutoff`), KEIN Limpen. Vorher
+ // ließ `raises_become_jams` die Limp-Bande stehen -> 8bb-SB limpte KK/AKs statt zu
+ // jammen (Turnier-Benchmark 7.11.). Jetzt wie der Binary/AoF-Zweig: eine Jam-Bande.
+ ChartRow::new(0.0, 0.0, push(pos, situation)).scaled(scale)
} else {
- row
+ full_row(pos, situation).unwrap_or(ChartRow::new(0.0, 0.0, 0.0)).scaled(width)
}
}
}
@@ -145,12 +153,18 @@ pub(crate) fn pot_without_antes(spot: &Spot) -> f64 {
/// row, scaled by table size, game and `scale_for`; the hand's percentile selects
/// jam / raise / call / fold. Binary-shape games only ever answer Jam or Fold.
pub fn advise(spot: &Spot, thresholds: &Thresholds) -> PreflopPlan {
+ advise_widened(spot, thresholds, 1.0)
+}
+
+/// `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 {
let hand = percentile(spot.variant, &spot.hero_cards);
let pos = seat_position(spot, spot.hero_seat);
let situation = situation_of(spot);
let depth = effective_stack_bb(spot);
let scale = scale_for(spot, situation, thresholds);
- let row = cutoffs(spot, situation, depth, scale);
+ let row = cutoffs(spot, situation, depth, scale, jam_widen);
let action = decide(hand, &row);
let sure = certainty(hand, &[row.raise, row.call, row.jam]);
match cfr_advice(spot, situation, pos, depth) {
@@ -159,8 +173,17 @@ pub fn advise(spot: &Spot, thresholds: &Thresholds) -> PreflopPlan {
// Preis-/Commitment-Riegel: die Chart-Zeile ist fuer Standardgroessen geloest; gegen eine
// grosse Bet wird die ACTUAL Call-Hoehe am Pot neu bepreist (Vorfall 6.11.: 99 jammte den
// Stack in eine 4-Bet und wurde danach gefoldet). Die geloesten CFR-Spots bleiben.
+ //
+ // NUR gegen eine Bet (facing raise): da committet der Jam ohne Fold-Equity. Beim OEFFNEN
+ // oder ueber einen Limp ist der Kurzstack-Jam ein Steal mit Fold-Equity - der Deckel wuerde
+ // ihn faelschlich zum Call/Limp degradieren (8bb-SB limpte KK, Turnier-Benchmark 7.11.).
let allow_call = matches!(spot.rules().shape, ActionShape::Full);
- let guarded = price_guarded(action, hand, spot.to_call, spot.pot, spot.hero_stack, allow_call);
+ let facing_raise = !matches!(situation, Situation::Unopened | Situation::FacingLimp);
+ let guarded = if facing_raise {
+ price_guarded(action, hand, spot.to_call, spot.pot, spot.hero_stack, allow_call)
+ } else {
+ action
+ };
let reason = if guarded == action {
describe(pos, situation, action, &row)
} else {
diff --git a/src/preflop/chart_row.rs b/src/preflop/chart_row.rs
index 1674a6db..b9e1534d 100644
--- a/src/preflop/chart_row.rs
+++ b/src/preflop/chart_row.rs
@@ -21,11 +21,6 @@ impl ChartRow {
ChartRow::new(apply(self.raise), apply(self.call), apply(self.jam))
}
- /// Short stacks turn their raising range into a jamming range.
- pub fn raises_become_jams(self) -> ChartRow {
- ChartRow::new(0.0, self.call, self.jam.max(self.raise))
- }
-
/// The widest continuing cut-off.
pub fn widest(self) -> f64 {
self.raise.max(self.call).max(self.jam)
diff --git a/src/preflop/push_chart.rs b/src/preflop/push_chart.rs
index 8e86a1b2..bddd08b3 100644
--- a/src/preflop/push_chart.rs
+++ b/src/preflop/push_chart.rs
@@ -15,7 +15,9 @@ fn base(position: Position) -> f64 {
Position::Button => 0.62,
Position::SmallBlind => 0.70,
Position::BigBlind => 0.25,
- Position::HeadsUpButton => 0.85,
+ // Nash-kalibriert (8.11., entscheiden/turnier_referenz): HU-Open-Jam bei 10bb ist 60 %, nicht
+ // 85 %. Die alte Breite kostete ~4-5 bb/100 (Über-Jam). Messbar über `nash_push_score`.
+ Position::HeadsUpButton => 0.60,
}
}
diff --git a/tests/aof_spielbar_spec.py b/tests/aof_spielbar_spec.py
index b63f7f7d..d81abc88 100644
--- a/tests/aof_spielbar_spec.py
+++ b/tests/aof_spielbar_spec.py
@@ -186,14 +186,15 @@ class Tischform(unittest.TestCase):
self.assertIsNone(formate.sitze_aus({"tableSize": 0})) # 0/None gilt nicht als Sitzzahl
def test_heads_up_aus_dem_namen(self):
- # Live 7.11.: die Startzeile trug KEIN Sitzfeld, aber "NL HU" im Namen - der Läufer öffnete den
- # 2-Platz-Tisch als Multiway und schloss ihn erst am Tisch (Churn). Der Name verrät HU.
- hu = {"roomName": "14R NL HU 0.01-0.02 EV-INRIT-(A) 1733810"}
+ # Live 7.11.: die Listenzeile trägt maxSize=2000 (KEIN Sitzfeld!), die echte Sitzzahl in
+ # tableSize=2. Der Name "HU" ist eindeutig und schlägt die Zahlenfelder; unplausible Zahlen
+ # (>10) zählen nicht. Ohne das öffnete der Läufer HU als Multiway (Churn, live bestätigt).
+ hu = {"roomName": "14R PLO HU 0.01-0.02 EV-INRIT-ANTE (A) 1732", "maxSize": 2000, "tableSize": 2, "minSize": 2}
self.assertEqual(formate.sitze_aus(hu), 2)
self.assertFalse(formate.form_passt(formate.MULTIWAY, formate.sitze_aus(hu)))
self.assertIsNone(formate.sitze_aus({"roomName": "14R NL 6MAX 0.01-0.02"})) # kein HU-Token
- # Ein echtes Sitzfeld schlägt den Namen (Zahl zuerst).
- self.assertEqual(formate.sitze_aus({"roomName": "NL HU 1-2", "maxSize": 6}), 6)
+ self.assertIsNone(formate.sitze_aus({"maxSize": 2000})) # 2000 ist keine Sitzzahl
+ self.assertEqual(formate.sitze_aus({"tableSize": 6, "maxSize": 2000}), 6) # tableSize gilt
def test_multiway_weist_heads_up_ab(self):
self.assertFalse(formate.form_passt(formate.MULTIWAY, 2)) # Heads-Up raus
diff --git a/tests/kurzstack_jam_spec.py b/tests/kurzstack_jam_spec.py
new file mode 100644
index 00000000..0c622c15
--- /dev/null
+++ b/tests/kurzstack_jam_spec.py
@@ -0,0 +1,72 @@
+#!/usr/bin/env python3
+"""Spezifikation: Kurzstack-OPEN ist Push/Fold, kein Limp (src/preflop/advise.cutoffs).
+
+Befund 7.11. (Turnier-Benchmark): bei 8bb im SB jammte nur AA; KK/AKs/77/KQs CALLten (limpten).
+Ursache: der Kurzstack-Zweig nutzte `raises_become_jams`, das die LIMP-Bande stehen lässt, statt der
+Push/Fold-Chart (`push_cutoff`, SB 70 %, HU-Button 85 %). Limpen mit 8bb ist ein klarer Fehler.
+
+Erwartung: bei einem offenen Kurzstack-Spot (zu Hero gefoldet, <= 15bb) wird JEDE spielbare Hand
+GEJAMMT (RAISE All-in) oder GEFOLDET - nie gecallt/gelimpt. Starke Hände jammen, Schrott foldet.
+
+ python3 tests/kurzstack_jam_spec.py -v
+"""
+import json
+import os
+import sys
+import unittest
+
+_w = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+sys.path.insert(0, os.path.join(_w, "entscheiden"))
+import decide
+
+RANG = {"A": "ACE", "K": "KING", "Q": "QUEEN", "J": "JACK", "T": "TEN", "9": "NINE",
+ "8": "EIGHT", "7": "SEVEN", "6": "SIX", "5": "FIVE", "4": "FOUR", "3": "THREE", "2": "TWO"}
+
+
+def _karten(h):
+ r1, r2 = RANG[h[0]], RANG[h[1]]
+ if len(h) == 2:
+ return [{"rank": r1, "suit": "SPADES"}, {"rank": r2, "suit": "HEARTS"}]
+ s2 = "SPADES" if h[2] == "s" else "HEARTS"
+ return [{"rank": r1, "suit": "SPADES"}, {"rank": r2, "suit": s2}]
+
+
+def _hu_open(h, stack):
+ """Heads-up, Hero im SB/Button (acts first), zu Hero gefoldet, realistische Sizes inkl. Jam."""
+ return json.dumps({
+ "variant": "NLHE", "bigBlind": 1.0, "seats": 2, "heroSeat": 1, "buttonSeat": 1,
+ "heroCards": _karten(h), "board": {}, "street": "PREFLOP", "pot": 1.5, "toCall": 0.5,
+ "heroStack": stack, "legalActions": ["FOLD", "CALL", "RAISE"], "allowedSizes": [2.0, 2.5, stack],
+ "villains": [{"seat": 2, "stack": stack, "folded": False}]})
+
+
+def _aktion(h, stack):
+ return (decide.entscheide([_hu_open(h, stack)])[0] or {}).get("action")
+
+
+class KurzstackOpenIstPushFold(unittest.TestCase):
+ STARK = ["AA", "KK", "QQ", "JJ", "99", "77", "AKs", "AQs", "AJs", "A5s", "KQs", "KJs", "QJs", "JTs"]
+ # Der absolute Boden foldet auch in der breiten HU-Button-Range (85 %); J2o/T2o jammen dort noch.
+ SCHROTT = ["72o", "82o", "92o"]
+ ALLE = STARK + SCHROTT + ["J2o", "T2o", "T9s", "98s", "KTo", "QTo", "A9o"]
+
+ def test_starke_haende_jammen_bei_8bb(self):
+ for h in self.STARK:
+ self.assertEqual(_aktion(h, 8.0), "RAISE", f"{h} sollte bei 8bb jammen, nicht {_aktion(h, 8.0)}")
+
+ def test_niemals_limpen_bei_8bb(self):
+ # Kurzstack-Open ist Jam/Fold - CALL (limp) darf NIE vorkommen.
+ gelimpt = [h for h in self.ALLE if _aktion(h, 8.0) == "CALL"]
+ self.assertEqual(gelimpt, [], f"gelimpte Hände (dürfen nicht limpen): {gelimpt}")
+
+ def test_schrott_foldet_bei_8bb(self):
+ for h in self.SCHROTT:
+ self.assertEqual(_aktion(h, 8.0), "FOLD", f"{h} sollte bei 8bb folden, nicht {_aktion(h, 8.0)}")
+
+ def test_auch_bei_12bb_kein_limp(self):
+ gelimpt = [h for h in self.ALLE if _aktion(h, 12.0) == "CALL"]
+ self.assertEqual(gelimpt, [], f"gelimpte Hände bei 12bb: {gelimpt}")
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/tests/spielplan_spec.py b/tests/spielplan_spec.py
index 9dd99802..1477c64b 100644
--- a/tests/spielplan_spec.py
+++ b/tests/spielplan_spec.py
@@ -276,5 +276,26 @@ class FalscheTischform(unittest.TestCase):
self.assertEqual(spielplan.form_untauglich_raeume({"A": 2}, "multiway", besetzt={"A"}), [])
+class MikroStakes(unittest.TestCase):
+ """Owner 8.11.: "Micro only" - EIN Schalter, der die Stakes nach oben kappt (schnelles Testen).
+ Das Stakes-Band bekommt die Obergrenze MICRO_MAX_BB; ein schon tieferes Band bleibt."""
+
+ def test_mikro_kappt_das_band(self):
+ self.assertEqual(spielplan.mikro_band(None, True), (None, spielplan.MICRO_MAX_BB))
+ self.assertEqual(spielplan.mikro_band((None, None), True), (None, spielplan.MICRO_MAX_BB))
+ self.assertEqual(spielplan.mikro_band((0.01, 1.0), True), (0.01, spielplan.MICRO_MAX_BB)) # gekappt
+ self.assertEqual(spielplan.mikro_band((None, 0.05), True), (None, 0.05)) # schon tiefer: bleibt
+
+ def test_ohne_schalter_unveraendert(self):
+ self.assertEqual(spielplan.mikro_band((0.5, 2.0), False), (0.5, 2.0))
+ self.assertIsNone(spielplan.mikro_band(None, False))
+
+ def test_micro_only_hin_und_zurueck(self):
+ p = spielplan.aus_dict({"modus": "cash", "tische": 1, "micro_only": True})
+ self.assertTrue(p.micro_only)
+ self.assertEqual(spielplan.aus_dict(spielplan.als_dict(p)), p)
+ self.assertFalse(spielplan.aus_dict({"modus": "cash", "tische": 1}).micro_only)
+
+
if __name__ == "__main__":
unittest.main()