poolwelt_decke: sequential port checks (self-play vs Python, stage 0 decomposed for v4/v4.1) then tree probes, one table run at a time, guard on disk and swap

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-02 18:32:32 +01:00
co-authored by Claude Opus 5.5
parent a7890a6dc1
commit c278cdbf3e
2 changed files with 104 additions and 1 deletions
@@ -0,0 +1,103 @@
#!/usr/bin/env python3
"""Pruefung des Pool-Ports nach Stufe 0 (+13,1 gegen live -3,9), danach die Gegenproben des neuen Baums (Hauptsession 02.12. 18:31).
python3 messung/innovation/poolwelt_decke/pruefen.py
Nacheinander, jeder Motor-Prozess ueber `motorplatz.py --plaetze 1` (projektweit hoechstens ein Lauf mit Strategie-Tafeln), nice 10:
1. selbst_v4 Selbstspiel im Port (sechs Welt-Gegner, kein Baum), dann vergleich.py gegen das Python-Selbstspiel
2. stufe0_v4 Rohbaum gegen Welt v4, voller Tisch, Zerlegung nach Hand-Ende
3. stufe0_v41 dasselbe gegen Welt v4.1
4. nacht.py Gegenproben des neuen Baums (wertklassen_baum), einzeln nacheinander
Waechter: faellt / unter 8 GB oder steigt die Auslagerung ueber 15 GB, wird der laufende Schritt beendet und nichts weiter gestartet.
Ergebnisse (nur angehaengt) unter <AUS>; Stand <AUS>/pruefen.json (atomar). Not-Aus: Datei <AUS>/stop.
"""
import json
import os
import re
import shutil
import signal
import subprocess
import sys
import time
HIER = os.path.dirname(os.path.abspath(__file__))
WURZEL = "/Users/marcmintel/Projects/pokerfreak"
D = "/Volumes/Alpha SSD/pokerfreak-daten"
AUS = D + "/innovation/poolwelt_decke"
EXE = "/Users/marcmintel/Projects/fremd/motor-mac/bin/pokerbench-poolwelt-pruef"
GRUND = D + "/grundstrategie-mitzaehler"
VERGLEICH = "/Users/marcmintel/Projects/pf-poolwelt/messung/innovation/poolwelt/vergleich.py"
MIN_ROOT_GB, MAX_SWAP_MB = 8.0, 15000.0
PLATZ = [sys.executable, os.path.join(WURZEL, "werkzeuge", "motorplatz.py"), "--plaetze", "1", "--", "nice", "-n", "10"]
def swap_mb():
out = subprocess.run(["sysctl", "-n", "vm.swapusage"], capture_output=True, text=True).stdout
m = re.search(r"used = ([\d.]+)M", out)
return float(m.group(1)) if m else 0.0
def alarm():
frei = shutil.disk_usage("/").free / 1e9
sw = swap_mb()
if frei < MIN_ROOT_GB or sw > MAX_SWAP_MB:
return "/ %.1f GB frei, Auslagerung %.0f MB" % (frei, sw)
return ""
def schritte():
decke = lambda welt: [EXE, "decke", "sechs100", GRUND, "2000-600-400", "200", GRUND + "/sechs100-v2.bin", D + "/poolwelt/" + welt,
"mix", "1.0", "0.01", "8", "0.2", "teil=voll", "zerlegen=1"]
return [("selbst_v4", PLATZ + [EXE, "poolselbst", D + "/poolwelt/welt_v4.json", "200000", "4", "lauf", "welt", "1"], AUS + "/selbst_v4.json"),
("vergleich_v4", [sys.executable, "-I", VERGLEICH, AUS + "/selbst_v4.json", D + "/welt_v4/selbstspiel", AUS + "/zusatz_v4.txt"], AUS + "/vergleich_v4.txt"),
("stufe0_v4", PLATZ + decke("welt_v4.json"), AUS + "/stufe0_v4_zerlegt.jsonl"),
("stufe0_v41", PLATZ + decke("welt_v4_1.json"), AUS + "/stufe0_v41_zerlegt.jsonl"),
("gegenproben", [sys.executable, os.path.join(WURZEL, ".claude/worktrees/innovation-055a7a/messung/innovation/wertklassen_baum/nacht.py"),
"--ab", time.strftime("%Y-%m-%dT%H:%M")], AUS + "/gegenproben.log")]
def atomar(pfad, obj):
with open(pfad + ".tmp", "w") as f:
json.dump(obj, f, indent=1)
os.replace(pfad + ".tmp", pfad)
def main():
stand_pfad = AUS + "/pruefen.json"
stand = json.load(open(stand_pfad)) if os.path.exists(stand_pfad) else {"schritte": {}}
with open(os.path.join(HIER, "STARTER.pid"), "w") as f:
f.write(str(os.getpid()))
for name, argv, aus in schritte():
if stand["schritte"].get(name, {}).get("status") == "fertig":
continue
if os.path.exists(AUS + "/stop") or alarm():
stand["abbruch"] = "vor %s: %s" % (name, alarm() or "Stop-Datei")
break
stand["schritte"][name] = {"status": "laeuft", "start": time.strftime("%H:%M:%S")}
atomar(stand_pfad, stand)
t = time.time()
with open(aus, "a") as f, open(AUS + "/%s.err" % name, "a") as err:
p = subprocess.Popen(argv, stdout=f, stderr=err, start_new_session=True, cwd=WURZEL)
grund = ""
while p.poll() is None:
grund = alarm() or ("Stop-Datei" if os.path.exists(AUS + "/stop") else "")
if grund:
os.killpg(p.pid, signal.SIGTERM)
p.wait()
break
time.sleep(20)
rc = p.returncode
stand["schritte"][name].update({"status": "abgebrochen: " + grund if grund else ("fertig" if rc == 0 else "fehler"), "rc": rc,
"sekunden": round(time.time() - t)})
atomar(stand_pfad, stand)
if grund or rc != 0:
stand["abbruch"] = name + ": " + (grund or "rc %d" % rc)
break
stand["ende"] = time.strftime("%H:%M:%S")
atomar(stand_pfad, stand)
print(json.dumps(stand, indent=1))
return 0
if __name__ == "__main__":
sys.exit(main())
+1 -1
View File
@@ -167,7 +167,7 @@ def main(argv):
stand["schritte"][name] = {"status": "laeuft", "start": time.strftime("%Y-%m-%d %H:%M:%S"), "log": log, "argv": argv_s}
atomar_json(stand_pfad, stand)
with open(log, "a") as f:
rc = subprocess.call([sys.executable, MOTORPLATZ, "--", "nice", "-n", "10"] + argv_s, stdout=f, stderr=subprocess.STDOUT)
rc = subprocess.call([sys.executable, MOTORPLATZ, "--plaetze", "1", "--", "nice", "-n", "10"] + argv_s, stdout=f, stderr=subprocess.STDOUT)
stand["schritte"][name].update({"status": "fertig" if rc == 0 else "fehler", "rc": rc, "sekunden": round(time.time() - t)})
atomar_json(stand_pfad, stand)
if rc != 0 and name in ("wertklassen", "lernen"):