Motor: stiller Schattenlauf im Laeufer (MOTOR_SCHATTEN), klickt nie

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-24 19:32:59 +01:00
co-authored by Claude Opus 5.5
parent db377287e4
commit 9b2ff657e0
5 changed files with 111 additions and 2 deletions
+3
View File
@@ -78,3 +78,6 @@ messung/sim-raus/bin/
# HTML-Messbericht (lesen/bericht_html.py): je Baum erzeugt, nie ins Repo (Live-Baum spult nur vor)
archiv/bericht/
# Schattenlauf des Motors: Anfragen mit Nutzerkennungen
archiv/lauf/schatten.jsonl
+4
View File
@@ -259,3 +259,7 @@ SPAET_FOLD=D:\Projects\pokerfreak\.claude\worktrees\engine-lecks-angreifen-de7b8
# richtiger Open-Jam-Preis, Call gegen kurze 4-/5-Bet-Jams nach Preis. hhDealer: praemie +0,009, openjam +0,007, kurzcall +0,05 bb/100.
# Kern 0BD74D33: aus = c3533f95 auf 1.163 Live-Anfragen; an = 0 Kipps auf denselben. splash, SPLASH_UNKLAR, VORFLOP_BREITE NICHT live (PLAN).
VORFLOP_FIX=praemie,openjam,kurzcall
#
# Owner 24.11.: der neue Motor rechnet still mit (entscheiden/schatten.py -> archiv/lauf/schatten.jsonl), klickt nie.
MOTOR_SCHATTEN=D:\Projects\pokerfreak
+6
View File
@@ -92,6 +92,7 @@ import formate
import antworten
import fraud
import decide
import schatten # der Motor rechnet still mit (entscheiden/schatten.py), klickt nie
import aof_push_fold
import denkzeit
import humanisierung
@@ -5193,6 +5194,10 @@ def _kreislauf(klicken, profil, zufall, sitzer, stopp_beim_start, kreis=None):
kreis.setdefault("fenster", "")
kreis.setdefault("luecken", strom_log.luecken)
kreis.setdefault("still_seit", time.time())
try:
schatten.starte(decide.SCHALTER.get("MOTOR_SCHATTEN"))
except Exception as e:
print("Motor-Schatten aus:", e)
# Echte Read-Zaehlungen (Zaehlbuch): einmal von der Platte, jede fertige Hand je Tisch genau einmal
# gebucht (beim Handwechsel im Lesen), periodisch geschrieben; `live` sichert den Rest beim Ende.
@@ -5458,6 +5463,7 @@ def _kreislauf(klicken, profil, zufall, sitzer, stopp_beim_start, kreis=None):
antwort = aof_push_fold.entscheide(anfrage)
else:
antwort = decide.entscheide([zeile])[0]
schatten.melde(zeile, antwort, raum, hand)
antwort = tischregeln.antwort_an_tisch(antwort, anfrage, z) # Regeln des Tisches
if klicken:
antwort = nie_verstreichen(antwort, anfrage) # kein Zug verstreicht (5.11. 12:35)
+2 -2
View File
@@ -47,7 +47,7 @@ BEKANNTE_SCHALTER = ("FAUSTREGEL", "DROSSEL", "MDF_UNREAD", "RAISE_DRAWS", "RAIS
"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", "VORFLOP_FIX", "SPLASH_UNKLAR", "VORFLOP_BREITE", "VORFLOP_EINTRITT", "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",
"VORWISSEN", "VORWISSEN_ART", "VORWISSEN_KERN", "VORWISSEN_OHNE", "VORWISSEN_FOLD", "VORWISSEN_BLUFF",
"VORWISSEN_ALTER", "GEGNERZAHL_FEST", "TISCHWAHL_GEWICHTE", "SPAET_FOLD", "PROFIL_OHNE")
"VORWISSEN_ALTER", "GEGNERZAHL_FEST", "TISCHWAHL_GEWICHTE", "SPAET_FOLD", "PROFIL_OHNE", "MOTOR_SCHATTEN")
# 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
@@ -58,7 +58,7 @@ BEKANNTE_SCHALTER = ("FAUSTREGEL", "DROSSEL", "MDF_UNREAD", "RAISE_DRAWS", "RAIS
LAEUFER_SCHALTER = ("TISCHWAHL", "TISCHWAHL_AB", "SITZWAHL", "GEGNER_GEDAECHTNIS", "VORWISSEN", "VORWISSEN_ART", "VORWISSEN_OHNE",
"GEGNERZAHL_FEST", "TISCHWAHL_GEWICHTE", "SPLASH_UNKLAR")
# Pfade gehoeren nicht in die Arm-Marke.
OHNE_MARKE = ("GRUNDSTRATEGIE", "GEGNER_LINIEN", "VORWISSEN")
OHNE_MARKE = ("GRUNDSTRATEGIE", "GEGNER_LINIEN", "VORWISSEN", "MOTOR_SCHATTEN")
def lies_schalter(pfad=SCHALTER_DATEI):
+96
View File
@@ -0,0 +1,96 @@
"""Schattenlauf des Motors (entscheiden/motor): rechnet jede echte Cash-Entscheidung mit und schreibt sie nach
archiv/lauf/schatten.jsonl. Er klickt nie, aendert keine Antwort, haelt den Laeufer nie auf.
An nur mit Schalter MOTOR_SCHATTEN=<Baum mit entscheiden/motor/target und daten/grundstrategie/motor>
(betrieb/kern_schalter.txt). Fehlt Binary oder Datei, oder stirbt der Motor zweimal: aus, ein Satz in der Datei.
"""
import json
import os
import queue
import subprocess
import sys
import threading
import time
ZIEL = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "archiv", "lauf", "schatten.jsonl")
FAEDEN = "2" # Rechenfaeden neben dem Spiel
SCHLANGE_MAX = 64 # haengt der Motor, wird verworfen statt gestaut
class Schatten:
def __init__(self, befehl, ziel=ZIEL):
self.befehl, self.ziel = befehl, ziel
self.schlange = queue.Queue(SCHLANGE_MAX)
self.verworfen = 0
self.faden = threading.Thread(target=self._lauf, name="motor-schatten", daemon=True)
self.faden.start()
def melde(self, zeile, antwort, raum=None, hand=None):
try:
q = json.loads(zeile)
if q.get("variant") != "NLHE" or q.get("_turnier") or not q.get("legalActions"):
return
self.schlange.put_nowait((time.time(), zeile, {k: antwort.get(k) for k in ("action", "size", "reason")}, str(raum), str(hand)))
except queue.Full:
self.verworfen += 1
except Exception: # der Schatten darf das Spiel nie stoeren
pass
def _start(self):
kw = {"creationflags": 0x4000 | 0x08000000} if sys.platform == "win32" else {} # BelowNormal, kein Fenster
return subprocess.Popen(self.befehl, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL,
text=True, encoding="utf-8", env={**os.environ, "RAYON_NUM_THREADS": FAEDEN}, **kw)
def _schreibe(self, satz):
with open(self.ziel, "a", encoding="utf-8") as f:
f.write(json.dumps(satz, ensure_ascii=False) + "\n")
def _lauf(self):
p, tode = None, 0
try:
while tode < 2:
try:
if p is None:
p = self._start()
t, zeile, antwort, raum, hand = self.schlange.get()
t1 = time.time()
p.stdin.write(json.dumps(dict(json.loads(zeile), seed=1)) + "\n")
p.stdin.flush()
r = p.stdout.readline()
if not r:
raise OSError("Motor beendet")
self._schreibe({"zeit": time.strftime("%Y-%m-%dT%H:%M:%S", time.localtime(t)), "raum": raum, "hand": hand,
"wartet_s": round(t1 - t, 3), "rechnet_s": round(time.time() - t1, 3), "verworfen": self.verworfen,
"kern": antwort, "motor": json.loads(r), "q": json.loads(zeile)})
except Exception as e:
tode += 1
self._schreibe({"zeit": time.strftime("%Y-%m-%dT%H:%M:%S"), "fehler": str(e)[:200]})
if p is not None:
p.kill()
p = None
except Exception:
pass
_schatten = None
def starte(wurzel, ziel=ZIEL):
"""Motor laden (im Hintergrund). Ohne Dateien: aus."""
global _schatten
if not wurzel or _schatten is not None:
return _schatten
m = os.path.join(wurzel, "entscheiden", "motor", "target", "pokerbench-motor-schatten.exe")
d = os.path.join(wurzel, "daten", "grundstrategie", "motor")
g = [os.path.join(d, x) for x in ("sechs100-v2.bin", "hu100-v1.bin", "hu200-v2.bin")]
fehlt = [x for x in [m, *g] if not os.path.exists(x)]
if fehlt:
print("Motor-Schatten aus, es fehlt:", ", ".join(fehlt))
return None
_schatten = Schatten([m, "dienst", "sechs100", d, "2000-600-400", "200", g[0], "genau", f"hu={g[1]},{g[2]}"], ziel)
return _schatten
def melde(zeile, antwort, raum=None, hand=None):
if _schatten is not None:
_schatten.melde(zeile, antwort, raum, hand)