Pruefbatterie v2 laeuft am Mac: Pfade per BATTERIE_*-Umgebung, Plattformweichen (Speicher, nice, Baum beenden)
Windows-Standards bleiben; macOS nutzt memory_pressure x hw.memsize und os.nice(10). Rauchprobe: 2 Blaetter poolk, motor + motor~station, 24 Zeilen, mk vorhanden. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -18,11 +18,12 @@ ZEIT = collections.defaultdict(lambda: [0, 0.0])
|
||||
HIER = os.path.dirname(os.path.abspath(__file__)); W = os.path.normpath(os.path.join(HIER, "..", ".."))
|
||||
sys.path.insert(0, os.path.join(W, "messung", "pruef"))
|
||||
import tisch6 as T
|
||||
import plattform as P
|
||||
import pool_gegner as G
|
||||
import slumbot as S
|
||||
|
||||
LIVE = T.LIVE
|
||||
D = os.path.join(W, "daten", "grundstrategie", "motor")
|
||||
D = os.environ.get("TISCH_DATEN") or os.path.join(W, "daten", "grundstrategie", "motor")
|
||||
MOTOR_QUELLE = os.path.join(W, "entscheiden", "motor", "target", "pokerbench-motor-schatten.exe") # live: MOTOR_SCHATTEN = Hauptbaum
|
||||
MOTOR_EXE = os.path.join(W, "entscheiden", "motor", "target", "pokerbench-batterie-motor.exe")
|
||||
FREMD = [sys.executable, "-I", os.path.join(W, "messung", "pruef", "fremd6.py"),
|
||||
@@ -39,6 +40,7 @@ KINDER = []
|
||||
|
||||
|
||||
def niedrig(p):
|
||||
if not P.WIN: return # Mac/Linux: Prioritaet setzt schon P.niedrig_args() beim Start (os.nice)
|
||||
try:
|
||||
import ctypes
|
||||
ctypes.windll.kernel32.SetPriorityClass(ctypes.c_void_p(int(p._handle)), 0x4000)
|
||||
@@ -49,12 +51,12 @@ def niedrig(p):
|
||||
|
||||
def aufraeumen():
|
||||
for p in KINDER: # ganzer Baum (fremd6.py startet nplayer_serve, das sonst verwaist und 10 GB haelt)
|
||||
subprocess.run(["taskkill", "/F", "/T", "/PID", str(p.pid)], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
P.beende_baum(p)
|
||||
|
||||
|
||||
def starte(cmd, env=None, cwd=None):
|
||||
p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, env=env, cwd=cwd, text=True,
|
||||
encoding="utf-8", bufsize=1, creationflags=0x4000)
|
||||
encoding="utf-8", bufsize=1, **P.niedrig_args())
|
||||
niedrig(p); KINDER.append(p); return p
|
||||
|
||||
|
||||
|
||||
@@ -49,3 +49,14 @@ cd D:\Projects\pf-batterie\messung\batterie\v2
|
||||
python -X utf8 batterie_v2.py holdout,poolk,station,nit,reg,maniac,nemesis,limper,gemischt2 0 400 laeufe/abnahme-v2.jsonl motor,motor~station,motor~fold50,motor~rivercall,motor~passiv,motor~zufall --abgleich 1 --warte-min 120
|
||||
```
|
||||
Zwischenauswertung alle 16 Blätter: `python -X utf8 auswertung_v2.py laeufe/abnahme-v2.jsonl --basis motor`. Neue Motor-Fassung gepaart gegen die Basis: Engines `motor,neu=D:/Projects/pf-schwachjam/.../pokerbench-motor-schwachjam.exe@K=V` und die Spalte `neu` in `auswertung_v2.py` als Fremde lesen (heute zählt dort nur `alt`, `fremd`, `dezhou`; eine Zeile `FREMDE`). Vor dem Start `laeufer.pid` im Live-Baum und `messung_engine/BUDGET_JETZT.txt` prüfen (dann TISCH_FAEDEN=2, setzt der Harness selbst).
|
||||
|
||||
## Start am Mac (02.12.2026)
|
||||
Pfade kommen aus Umgebungsvariablen (Standard = Windows): `BATTERIE_HAUPT`, `BATTERIE_LIVE_BAUM`, `BATTERIE_DATEN`, `BATTERIE_SCHALTER`, `BATTERIE_MOTOR_QUELLE`, `BATTERIE_ALT_EXE`, `BATTERIE_GEGNER_EXE` (dazu `TISCH_DATEN`). Plattformweichen (Speicher, Prioritaet, Baum beenden) stehen in `messung/pruef/plattform.py`: Mac nutzt `memory_pressure` x `hw.memsize` und `os.nice(10)`.
|
||||
Motor: `fremd/motor-mac/bauen.sh <worktree>`. Gegnerdienst: `cargo build --release --features sim --bin trainer_gegner -j 4`, Kopie nach `lauf/pokerbench-batterie-gegner.exe`.
|
||||
```
|
||||
cd messung/batterie/v2
|
||||
BATTERIE_HAUPT=~/Projects/pokerfreak BATTERIE_LIVE_BAUM=~/Projects/pokerfreak BATTERIE_DATEN="/Volumes/Alpha SSD/pokerfreak-daten/grundstrategie/motor" \
|
||||
BATTERIE_MOTOR_QUELLE=~/Projects/fremd/motor-mac/pf-batterie2/target/release/motor BATTERIE_SCHALTER=~/Projects/pokerfreak/betrieb/kern_schalter.txt \
|
||||
python3 -X utf8 batterie_v2.py <typen> 0 400 laeufe/<name>.jsonl motor,motor~station,... --abgleich 1 --warte-min 120
|
||||
```
|
||||
Rauchprobe am Mac: `poolk`, Blaetter 0-2, `motor,motor~station`: 24 Zeilen, 12 mit `mk`, `auswertung_v2.py` laeuft. Nicht portiert: `abgleich.py`, `matrix_probe.py`, `persona_eichung.py` (feste D:-Pfade), `fremd` (D:-Pfade in `batterie.py`).
|
||||
|
||||
@@ -14,24 +14,27 @@
|
||||
# --motor-quelle --lauf-ordner --warte-min <Minuten auf freien Speicher> --frei-gb 24
|
||||
# Fortsetzbar: vorhandene (typ, blatt, platz, engine) werden uebersprungen; Ausgabe nur angehaengt.
|
||||
import sys; sys.dont_write_bytecode = True
|
||||
import argparse, ctypes, json, os, random, shutil, time
|
||||
import argparse, json, os, random, shutil, time
|
||||
HIER = os.path.dirname(os.path.abspath(__file__)); W = os.path.normpath(os.path.join(HIER, "..", "..", ".."))
|
||||
sys.path.insert(0, HIER); sys.path.insert(0, os.path.join(HIER, ".."))
|
||||
import batterie as B1 # huelle(), gegner(), etikett(), starte(), aufraeumen() (alte Batterie, unveraendert)
|
||||
import tisch6 as T
|
||||
import plattform as P
|
||||
import pool_gegner as G
|
||||
import slumbot as S
|
||||
import varred as V
|
||||
import typen_v2 as TV
|
||||
|
||||
HAUPT = "D:/Projects/pokerfreak"
|
||||
LIVE_BAUM = HAUPT + "/.claude/worktrees/engine-lecks-angreifen-de7b88"
|
||||
# Pfade: Windows-Standard, je Rechner ueberschreibbar (Umgebungsvariablen BATTERIE_*), siehe BERICHT.md "Start am Mac".
|
||||
HAUPT = os.environ.get("BATTERIE_HAUPT", "D:/Projects/pokerfreak")
|
||||
LIVE_BAUM = os.environ.get("BATTERIE_LIVE_BAUM", HAUPT + "/.claude/worktrees/engine-lecks-angreifen-de7b88")
|
||||
DATEN = os.environ.get("BATTERIE_DATEN", HAUPT + "/daten/grundstrategie/motor")
|
||||
SCHALTER = os.environ.get("BATTERIE_SCHALTER", LIVE_BAUM + "/betrieb/kern_schalter.txt")
|
||||
MOTOR_QUELLE = os.environ.get("BATTERIE_MOTOR_QUELLE", HAUPT + "/entscheiden/motor/target/pokerbench-motor-schatten.exe")
|
||||
ALT_EXE = os.environ.get("BATTERIE_ALT_EXE", os.path.join(LIVE_BAUM, "target", "release", "rechner.exe"))
|
||||
|
||||
|
||||
def frei_gb():
|
||||
class M(ctypes.Structure):
|
||||
_fields_ = [("l", ctypes.c_ulong), ("p", ctypes.c_ulong), ("tot", ctypes.c_ulonglong), ("av", ctypes.c_ulonglong)] + [("x%d" % i, ctypes.c_ulonglong) for i in range(5)]
|
||||
m = M(); m.l = ctypes.sizeof(M); ctypes.windll.kernel32.GlobalMemoryStatusEx(ctypes.byref(m)); return m.av / 2 ** 30
|
||||
frei_gb = P.frei_gb
|
||||
|
||||
|
||||
def platz_gb(pfad):
|
||||
@@ -69,7 +72,7 @@ class Feld2:
|
||||
self.sha[b] = B1.sha(ziel)[:12]
|
||||
brauche = {t for t in typen if t in ("alt", "fremd")} | {b for b in basen if b in ("alt", "fremd")}
|
||||
if "alt" in brauche:
|
||||
self.p["alt"] = B1.starte([os.path.join(LIVE_BAUM, "target", "release", "rechner.exe")], self.env, LIVE_BAUM)
|
||||
self.p["alt"] = B1.starte([ALT_EXE], self.env, LIVE_BAUM)
|
||||
if "fremd" in brauche:
|
||||
self.p["fremd"] = B1.starte(B1.FREMD)
|
||||
G.EXE = a.gegner_exe
|
||||
@@ -166,13 +169,14 @@ def main():
|
||||
ap.add_argument("--crn", type=int, default=1); ap.add_argument("--var", type=int, default=1); ap.add_argument("--abgleich", type=int, default=0); ap.add_argument("--linien", type=int, default=0)
|
||||
ap.add_argument("--lauf-ordner", default=os.path.join(HIER, "lauf"))
|
||||
ap.add_argument("--gegner-exe", default=None)
|
||||
ap.add_argument("--daten", default=HAUPT + "/daten/grundstrategie/motor")
|
||||
ap.add_argument("--schalter", default=LIVE_BAUM + "/betrieb/kern_schalter.txt")
|
||||
ap.add_argument("--motor-quelle", default=HAUPT + "/entscheiden/motor/target/pokerbench-motor-schatten.exe")
|
||||
ap.add_argument("--daten", default=DATEN)
|
||||
ap.add_argument("--schalter", default=SCHALTER)
|
||||
ap.add_argument("--motor-quelle", default=MOTOR_QUELLE)
|
||||
ap.add_argument("--warte-min", type=float, default=0); ap.add_argument("--frei-gb", type=float, default=24)
|
||||
a = ap.parse_args()
|
||||
os.makedirs(a.lauf_ordner, exist_ok=True)
|
||||
a.gegner_exe = a.gegner_exe or os.path.join(a.lauf_ordner, "pokerbench-batterie-gegner.exe")
|
||||
os.makedirs(os.path.dirname(os.path.abspath(a.aus)), exist_ok=True)
|
||||
a.gegner_exe = a.gegner_exe or os.environ.get("BATTERIE_GEGNER_EXE") or os.path.join(a.lauf_ordner, "pokerbench-batterie-gegner.exe")
|
||||
typen, engines = a.typen.split(","), a.engines.split(",")
|
||||
schwer = len({e.split("~")[0] for e in engines if not e.startswith("pool:")}) + sum(t in ("alt", "fremd") for t in typen)
|
||||
if schwer and not warten(9.7 * schwer, a.frei_gb, a.warte_min, a.lauf_ordner): sys.exit(3)
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
"""Plattformweichen fuer die Messwerkzeuge (Windows ist der Standard, macOS ist die zweite Heimat).
|
||||
|
||||
Windows: BelowNormal ueber creationflags, Speicher ueber GlobalMemoryStatusEx, Baum beenden mit taskkill.
|
||||
macOS/Linux: os.nice(10) im Kind, eigene Sitzung je Kind (damit der Baum beendet werden kann), Speicher ueber memory_pressure.
|
||||
"""
|
||||
import os
|
||||
import re
|
||||
import signal
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
WIN = sys.platform == "win32"
|
||||
MAC = sys.platform == "darwin"
|
||||
BELOW_NORMAL = 0x4000
|
||||
|
||||
|
||||
def _kind_start():
|
||||
os.setsid()
|
||||
os.nice(10)
|
||||
|
||||
|
||||
def niedrig_args():
|
||||
"""Zusatzargumente fuer subprocess.Popen: Prioritaet unter Normal."""
|
||||
return {"creationflags": BELOW_NORMAL} if WIN else {"preexec_fn": _kind_start}
|
||||
|
||||
|
||||
def frei_gb():
|
||||
"""Freier Arbeitsspeicher in GB."""
|
||||
if WIN:
|
||||
import ctypes
|
||||
|
||||
class M(ctypes.Structure):
|
||||
_fields_ = [("l", ctypes.c_ulong), ("p", ctypes.c_ulong), ("tot", ctypes.c_ulonglong), ("av", ctypes.c_ulonglong)] + [("x%d" % i, ctypes.c_ulonglong) for i in range(5)]
|
||||
m = M()
|
||||
m.l = ctypes.sizeof(M)
|
||||
ctypes.windll.kernel32.GlobalMemoryStatusEx(ctypes.byref(m))
|
||||
return m.av / 2 ** 30
|
||||
if MAC:
|
||||
gesamt = int(subprocess.run(["sysctl", "-n", "hw.memsize"], capture_output=True, text=True, check=True).stdout.strip())
|
||||
text = subprocess.run(["memory_pressure"], capture_output=True, text=True, check=True).stdout
|
||||
z = re.search(r"System-wide memory free percentage:\s*([\d.]+)%", text)
|
||||
if not z:
|
||||
raise RuntimeError("memory_pressure: keine Zeile 'System-wide memory free percentage'")
|
||||
return gesamt * float(z.group(1)) / 100 / 2 ** 30
|
||||
seiten = os.sysconf("SC_AVPHYS_PAGES") * os.sysconf("SC_PAGE_SIZE")
|
||||
return seiten / 2 ** 30
|
||||
|
||||
|
||||
def beende_baum(p):
|
||||
"""Beendet den Prozess samt Kindern."""
|
||||
if WIN:
|
||||
subprocess.run(["taskkill", "/F", "/T", "/PID", str(p.pid)], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
return
|
||||
try:
|
||||
os.killpg(p.pid, signal.SIGKILL) # Kind ist Leiter der eigenen Sitzung (niedrig_args)
|
||||
except (ProcessLookupError, PermissionError):
|
||||
try:
|
||||
p.kill()
|
||||
except OSError:
|
||||
pass
|
||||
@@ -7,8 +7,10 @@ import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
import plattform as P
|
||||
|
||||
W = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", ".."))
|
||||
EXE = os.path.join(W, "entscheiden", "motor", "target", "pokerbench-motor-gegner.exe")
|
||||
EXE = os.environ.get("BATTERIE_GEGNER_EXE") or os.path.join(W, "entscheiden", "motor", "target", "pokerbench-motor-gegner.exe")
|
||||
RK = {"TWO": "2", "THREE": "3", "FOUR": "4", "FIVE": "5", "SIX": "6", "SEVEN": "7", "EIGHT": "8", "NINE": "9", "TEN": "T",
|
||||
"JACK": "J", "QUEEN": "Q", "KING": "K", "ACE": "A"}
|
||||
k = lambda c: RK[c["rank"]] + c["suit"][0].lower()
|
||||
@@ -55,7 +57,7 @@ def lage(q, kenn, typ):
|
||||
class Pool:
|
||||
def __init__(self):
|
||||
self.p = subprocess.Popen([EXE], stdin=subprocess.PIPE, stdout=subprocess.PIPE, text=True, encoding="utf-8", bufsize=1,
|
||||
creationflags=0x4000)
|
||||
**P.niedrig_args())
|
||||
|
||||
def zug(self, q, kenn, typ):
|
||||
self.p.stdin.write(json.dumps(lage(q, kenn, typ)) + "\n")
|
||||
|
||||
@@ -14,12 +14,13 @@ import random
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
import plattform as P
|
||||
import slumbot as S
|
||||
|
||||
W = S.WURZEL
|
||||
D = os.environ.get("TISCH_DATEN") or os.path.join(W, "daten", "grundstrategie", "motor")
|
||||
T = os.path.join(W, "entscheiden", "motor", "target")
|
||||
LIVE = os.path.join(W, ".claude", "worktrees", "engine-lecks-angreifen-de7b88")
|
||||
LIVE = os.environ.get("BATTERIE_LIVE_BAUM") or os.path.join(W, ".claude", "worktrees", "engine-lecks-angreifen-de7b88")
|
||||
STR = ("PREFLOP", "FLOP", "TURN", "RIVER")
|
||||
DECK = [r + s for r in "23456789TJQKA" for s in "cdhs"]
|
||||
RV = {r: i for i, r in enumerate("23456789TJQKA")}
|
||||
@@ -40,7 +41,7 @@ def start(name):
|
||||
cmd, cwd = [os.path.join(T, os.environ.get("TISCH_EXE", "pokerbench-motor-tisch.exe")), "dienst", spiel, D, k2, km, os.path.join(D, datei)] + genau, None
|
||||
env["RAYON_NUM_THREADS"] = os.environ.get("TISCH_FAEDEN", "2")
|
||||
p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, env=env, cwd=cwd, text=True, encoding="utf-8",
|
||||
bufsize=1, creationflags=0x4000)
|
||||
bufsize=1, **P.niedrig_args())
|
||||
ohne_eco(p)
|
||||
return p
|
||||
|
||||
|
||||
Reference in New Issue
Block a user