Files
mmintel f2650dc3be Cockpit and runner 5.11. late: no ESC stop, hidden tables stay open, gapless tiling, teacher core
- ESC no longer triggers the emergency stop (an ESC in another app stopped the run at 20:29);
  stopping only via ctrl-opt-cmd-S or the stop button
- a table whose program runs counts as open even when its window is not visible (other
  desktop, Cockpit without screen recording): no reopening, no giving up, correct table
  count; teardown and closing a full table work over the channel
- Cockpit checks and requests the screen recording permission
- gapless tiling (sicht/kacheln.py): tables fill the full height, the Cockpit bar takes the
  rest and never goes below its minimum width; own animated resize no longer stored as minimum
- earlier today: top-up safety net, leave after the hand (sit out next hand), tournament lock,
  waitlist left on close, Cockpit start lock, warning throttle, preflop raise-war reading,
  Bomb Pot practice, tournament break and level-up on the stage
- teacher core for the streamer mode (betrieb/lehrer.py, betrieb/grund_lesen.py) and its plan
2026-11-05 22:39:41 +01:00

81 lines
4.4 KiB
Python

"""Grund lesen: das Fachkuerzel einer Entscheidung des Kerns, in seine Teile zerlegt.
Der Kern begruendet jede Entscheidung knapp und exakt - Vorflop (src/preflop/advise.rs) etwa
"BB vs open, fold outside top 42% -> fold" oder "EP open, CFR open 26bb vs 4 defenders: fold 100%",
nach dem Flop (src/engine/postflop.rs, read_label.rs) etwa "top pair weak kicker on medium board
(2-way): equity 0.68 vs break-even 0.00, EV check +0.38" - "(n-way)" zaehlt die Gegner, ohne
Angabe ist es einer. Der Lehrer (betrieb/lehrer.py) formuliert daraus Saetze fuer Anfaenger; hier
steht nur, WAS da steht. Spezifikation: tests/lehrer_spec.py (GrundLesen).
"""
import re
from dataclasses import dataclass
from typing import Optional
# Nach der Lage ein Satzzeichen oder das Ende - keine Wortgrenze: nach "3-bet+" gibt es keine.
VORFLOP = re.compile(r"^(?P<pos>BTN/SB|EP|MP|HJ|CO|BTN|SB|BB) (?P<lage>vs 3-bet\+|vs all-in|vs limp|vs open|open)"
r"(?=[,:\s]|$)(?P<rest>.*)$")
BEREICH = re.compile(r"(?P<aus>fold outside )?(?:call )?top (?P<x>[\d.]+)%")
THEORIE = re.compile(r"CFR [^:]*: (?P<verb>fold|call|raise|jam) (?P<p>[\d.]+)%")
NACHFLOP = re.compile(r"^(?:double board: board (?P<db>\d) judged better .*? - )?(?P<kopf>.+?) on (?P<board>[\w-]+) board"
r"(?: \((?P<n>\d+)-way\))?:(?P<rest>.*)$")
CHANCE = re.compile(r"equity (?P<e>[\d.]+)(?: \(realised [\d.]+\))? vs break-even (?P<b>[\d.]+)")
PLAN = re.compile(r"EV (?P<plan>thin value raise|semibluff raise|bluff raise|raise|check|call|fold|lead|bet)\b")
PLAENE = {"thin value raise": "wert", "semibluff raise": "halbbluff", "bluff raise": "bluff"}
DRAWS = {"gutshot": "gutshot", "open-ended draw": "open-ended", "flush draw": "flush", "combo draw": "combo"}
@dataclass(frozen=True)
class Lesart:
art: str = "unbekannt" # vorflop | nachflop | unbekannt
position: Optional[str] = None # EP, MP, HJ, CO, BTN, SB, BB, BTN/SB
lage: Optional[str] = None # open, vs limp, vs open, vs 3-bet+, vs all-in
bereich: Optional[float] = None # "top X%" - der Handbereich in Prozent
ausserhalb: bool = False # "fold outside top X%": die Hand liegt nicht darin
theorie: Optional[str] = None # Spieltheorie (CFR): fold, call, raise, jam
anteil: Optional[float] = None # wie oft die Theorie das spielt, in Prozent
blatt: Optional[str] = None # air, middle pair, top pair good kicker, ...
draw: Optional[str] = None # gutshot, open-ended, flush, combo
board: Optional[str] = None # dry, medium, wet, four-flush
gegner: Optional[int] = None # Zahl der Gegner nach dem Flop
chance: Optional[float] = None # Gewinnchance 0..1
noetig: Optional[float] = None # noetige Chance zum Mitgehen 0..1 (0: nichts zu zahlen)
plan: Optional[str] = None # check, call, raise, bluff, halbbluff, wert, lead, fold
knapp: bool = False # innerhalb der Unsicherheit: Chance und Preis fast gleich
doppelboard: Optional[int] = None # Bomb Pot mit zwei Boards: auf welchem es besser steht
def _vorflop(m):
rest = m.group("rest")
theorie = THEORIE.search(rest)
bereich = BEREICH.search(rest)
return Lesart("vorflop", m.group("pos"), m.group("lage"),
bereich=float(bereich.group("x")) if bereich else None,
ausserhalb=bool(bereich and bereich.group("aus")),
theorie=theorie.group("verb") if theorie else None,
anteil=float(theorie.group("p")) if theorie else None)
def _nachflop(m):
blatt, _, draw = m.group("kopf").partition(" with ")
rest = m.group("rest")
chance, plan = CHANCE.search(rest), PLAN.search(rest)
return Lesart("nachflop", blatt=blatt, draw=DRAWS.get(draw), board=m.group("board"),
gegner=int(m.group("n") or 1),
chance=float(chance.group("e")) if chance else None,
noetig=float(chance.group("b")) if chance else None,
plan=PLAENE.get(plan.group("plan"), plan.group("plan")) if plan else None,
knapp="uncertainty band" in rest,
doppelboard=int(m.group("db")) if m.group("db") else None)
def lesen(grund):
"""Grund des Kerns -> Lesart; was sich nicht lesen laesst, ist "unbekannt"."""
text = (grund or "").strip()
m = VORFLOP.match(text)
if m:
return _vorflop(m)
m = NACHFLOP.match(text)
if m:
return _nachflop(m)
return Lesart()