diff --git a/messung/motor/live_motor.py b/messung/motor/live_motor.py index ec09debc..f7284a7f 100644 --- a/messung/motor/live_motor.py +++ b/messung/motor/live_motor.py @@ -9,7 +9,7 @@ Pruefung (bricht ab): die gebaute Umgebung muss fuer jeden BEKANNTE_SCHALTER gen ausdruecklich genannten Abweichungen `extra` (setzen) und `ohne` (entfernen). import live_motor as LM; m = LM.starte(exe, extra={"MOTOR_RNR_GEGEN": "1"}, ohne=("MOTOR_RNR",)); a = LM.frag(m, q) python -X utf8 live_motor.py -> zeigt Umgebung und Befehl""" -import json, os, queue, subprocess, sys, threading +import hashlib, json, os, queue, subprocess, sys, threading LIVE = "D:/Projects/pokerfreak/.claude/worktrees/engine-lecks-angreifen-de7b88" _HOLE = r''' @@ -88,8 +88,17 @@ def starte(exe, extra=None, ohne=(), faeden="2", live=LIVE, schalter=None): return p, out, fehler, {"befehl": befehl, "schalter": {k: env[k] for k in sorted(set(u) | set(extra or {})) if k in env}, "ohne": list(ohne)} +def mit_saat(q): + """Live (schatten.py) schickt je Anfrage eine 62-Bit-Zufallssaat; ohne seed zieht der Motor Saat 1 fuer jede Anfrage + (auch die VERTRAUEN-Dosierung). Hier: Saat aus dem Anfrageinhalt, je Anfrage verschieden, in allen Armen gleich + (gleiche Rechnung wie poolmodell 2ac37ea7). 29.11. 18:10""" + if q.get("seed") is not None: return q + h = hashlib.sha256(json.dumps(q, sort_keys=True, ensure_ascii=False).encode("utf-8")).digest() + return dict(q, seed=int.from_bytes(h[:8], "big") >> 2) + + def frag(m, q, frist=600): - m[0].stdin.write(json.dumps(q) + "\n"); m[0].stdin.flush() + m[0].stdin.write(json.dumps(mit_saat(q)) + "\n"); m[0].stdin.flush() return json.loads(m[1].get(timeout=frist)) diff --git a/messung/motor/rnr/richter2/lauf.py b/messung/motor/rnr/richter2/lauf.py index ce5cca89..17a8402a 100644 --- a/messung/motor/rnr/richter2/lauf.py +++ b/messung/motor/rnr/richter2/lauf.py @@ -13,10 +13,13 @@ import collections, hashlib, json, os, random import numpy as np HIER = os.path.dirname(os.path.abspath(__file__)); W = os.path.normpath(os.path.join(HIER, "..", "..", "..", "..")) PM = "D:/Projects/pokerfreak/.claude/worktrees/motor-poolmodell-57fd0b/messung/motor" -sys.path[:0] = [PM, os.path.join(PM, "riverbr"), os.path.join(HIER, "..", "..")] +sys.path[:0] = [os.path.join(HIER, "..", ".."), PM, os.path.join(PM, "riverbr")] # eigenes live_motor zuerst (poolmodell hat seit 17:29 ein gleichnamiges mit Saat) +import importlib.util +_s = importlib.util.spec_from_file_location("live_motor", os.path.join(HIER, "..", "..", "live_motor.py")) +LM = importlib.util.module_from_spec(_s); sys.modules["live_motor"] = LM; _s.loader.exec_module(LM) # eigenes, ohne Saat; vor richter laden import sicher as SI import richter as RI -import live_motor as LM +assert os.path.normcase(os.path.dirname(os.path.abspath(LM.__file__))) == os.path.normcase(os.path.normpath(os.path.join(HIER, "..", ".."))), LM.__file__ sys.path.insert(0, os.path.join(LM.LIVE, "entscheiden")) RB = RI.RB EXE = os.path.join(W, "entscheiden", "motor", "target", "release", "pokerbench-rnr-live2.exe") @@ -103,6 +106,7 @@ def _lauf_mit(arm, m): with open(aus, "a", encoding="utf-8") as f: for i, (hk, q) in enumerate(F): if i in fertig or q["street"] != "RIVER" or (arm == "live_k" and i % 10): continue + q = LM.mit_saat(q) # 29.11. 18:15: Saat aus der Grundanfrage (vor VERTRAUEN), je Spot in allen Armen gleich; live sendet je Anfrage eine if vertrauen_an: q = vertrauen.setze(q) a = LM.frag(m, q, 600) SI.warte_platz(aus); f.write(json.dumps({"i": i, "street": q["street"], "p": q.get("p"), "a": {k: a.get(k) for k in ("action", "size")}, "rnr": "RNR p" in str(a.get("reason")), "nach": a.get("nach")}) + "\n"); f.flush()