Files
pokerfreak/hand/hudquelle.py
T
mmintel 9c79d8236b Acceptance 5.11.: channel play without AFK, quiet focus, working Cockpit, stronger play
- Practice tables: 20-min session 54/54 turns at the server, control session 28 turns,
  0 timeouts; stage: 3 tables, two rounds each, clean teardown.
- Never let the clock run: an engine abstention becomes check or fold (nie_verstreichen).
- Mittler join in a fixed order (kill the duplicate, then announce), a mittler ends with its
  game, the laufwache opens no tables, stop waits for the runner to stand up.
- Focus: no lobby connections from HUD, probes or layout; "Focus Window on Turn" off.
- Tables: disconnected or sitting-out opponents do not count; a table without channel is
  closed and avoided after 45 s; the join event keeps the writer's pid (strict invariants).
- Geldwache: same room list as the runner, the table's own report, stand up before closing.
- Engine: the small blind completes the top 65 % against limpers (price per fair share);
  the calling range of a bet is as wide as the villain calls - value bets into stations.
- Cockpit: the source tree never comes from SHELL; one operating set for laufwache and
  Cockpit (sicht/start.py --client, ServerStart).
- Project lives in ~/Projects/pokerfreak (kern was a detour).
2026-11-05 16:10:43 +01:00

79 lines
2.9 KiB
Python

#!/usr/bin/env python3
"""Die HUD-Zahlen des Clients als zweite Gegnerquelle - gemischt, nicht gerechnet.
`zahlen` liefert nur, was im Cache liegt - und holt NICHTS nach. Frueher stiess es je Abfrage
einen Abruf ueber die Lobby-Pipe an (hand/kanal.hud). Jede neue Verbindung dort gilt der Lobby aber
als "die Bruecke hat sich verbunden" und holt jeden Tisch, an dem wir sitzen, nach vorn
(app.asar `onClientConnected` -> `UNITY_PROCESS_AUTO_TABLE_OPEN` -> `focusTable`): gemessen 5.11.
39 Verbindungen in 30 s, der Bediener verlor alle paar Sekunden den Fokus (tests/fokusruhe_spec.py).
Wer den Cache fuellt, darf dafuer keine Lobby-Verbindung oeffnen.
zahlen(raum, kennungen) -> {kennung: {feld: 0..1}} aus dem Cache (nie blockierend)
mischen(profil_je_sitz, kennung, zahlen) -> Profil mit den Client-Zahlen darin
Regeln:
* Der Client hat mehr Stichproben als unser Log - seine Zahlen gewinnen, wo sie da sind.
* `hands` bleibt unsere Angabe, wird aber mindestens GLAUBHAFT, weil die Zahl aus einer Quelle
mit Historie kommt (so vertraut der Kern ihr auch).
* Alte Zahlen bleiben nutzbar; ihr Alter steht im Cache (siehe FRIST_S).
Spezifikation: tests/hudquelle_spec.py.
"""
import os
import sys
import threading
_w = os.path.dirname(os.path.abspath(__file__))
while _w != "/" and not os.path.isdir(os.path.join(_w, "lesen")):
_w = os.path.dirname(_w)
for _u in ("hand", "client", "lesen"):
_q = os.path.join(_w, _u)
if _q not in sys.path:
sys.path.insert(0, _q)
import profil
FRIST_S = 60.0 # so lange gelten geholte Zahlen als frisch
_sperre = threading.Lock()
_cache = {} # raum -> {"stand": zeit, "zahlen": {kennung: {feld: 0..1}}}
def zahlen(raum, kennungen=(), frist_ab=FRIST_S):
"""Gecachte Zahlen fuer diesen Raum - sofort, ohne Abruf (siehe Kopf: keine Lobby-Verbindung)."""
if not raum:
return {}
with _sperre:
eintrag = _cache.get(raum)
return dict((eintrag or {}).get("zahlen") or {})
def mischen(profil_je_sitz, kennung_je_sitz, gecacht):
"""Das Profil je Sitz um die Client-Zahlen ergaenzen (Client gewinnt, `hands` bleibt mindestens
GLAUBHAFT). Sitze ohne Client-Zahlen bleiben, wie sie sind."""
if not gecacht:
return profil_je_sitz
aus = {}
for sitz, p in profil_je_sitz.items():
neu = dict(p)
werte = gecacht.get(str(kennung_je_sitz.get(sitz) or ""))
if werte:
neu.update(werte)
neu["hands"] = max(neu.get("hands", 0) or 0, profil.GLAUBHAFT)
aus[sitz] = neu
return aus
def anwenden(raum, sitz_kennung, profil_je_sitz):
"""Bequem fuer den Aufrufer: holen (aus dem Cache), mischen, zurueckgeben."""
return mischen(profil_je_sitz, sitz_kennung, zahlen(raum, (sitz_kennung or {}).values()))
def vergessen():
"""Cache leeren (Pruefungen)."""
with _sperre:
_cache.clear()
if __name__ == "__main__":
print("Cache:", zahlen(sys.argv[1] if len(sys.argv) > 1 else "", []))