farm_sharingan_frage: SHARINGAN B direkt mit voller Mischung fragen (ohne Motor, ohne NL2), Knopf aus dem Small Blind, fortsetzbar

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-03 13:47:46 +01:00
co-authored by Claude Opus 5.5
parent e7a3807f87
commit 1cee40ffb6
@@ -0,0 +1,50 @@
# SHARINGAN B direkt fragen (ohne unseren Motor, ohne NL2), mit seiner vollen Mischung (options.include_probs), 03.12. fuer flopsuche/exakt.
# Uebersetzung der Vertrags-Anfrage wie im pruef6-Duplikat (sh6.anfrage). Eingabe je Zeile: die Anfrage selbst (mit "_fall") oder {"id", "q"}.
# Ausgabe nur anhaengen, Fortsetzen ueberspringt Erledigtes: {"_fall"|"id", "ok", "response"|"error"} (response samt probs, source, timing).
# python -X utf8 farm_sharingan_frage.py <sh6.py> <sharingan-stdio.exe> <plcp> <buckets> <ein.jsonl> <aus.jsonl> [--suche] (ohne: --no-search)
import sys; sys.dont_write_bytecode = True
import importlib.util, json, os, subprocess
def main():
sh6p, exe, bp, bk, ein, aus = sys.argv[1:7]
suche = "--suche" in sys.argv[7:]
spec = importlib.util.spec_from_file_location("sh6", sh6p); sh6 = importlib.util.module_from_spec(spec); spec.loader.exec_module(sh6)
fertig = set()
if os.path.exists(aus):
for z in open(aus, encoding="utf-8"):
try:
r = json.loads(z); fertig.add(json.dumps(r.get("_fall", r.get("id"))))
except ValueError:
pass
flags = ["--search-threads", "1", "--search-concurrency", "1", "--budget-ms", "600000", "--set", "iters=200000"] if suche else ["--no-search"]
p = subprocess.Popen([exe, "--blueprint", bp, "--buckets", bk, "--sizing", "local", "--bind", "127.0.0.1:0"] + flags, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, env=dict(os.environ, STDIO_THREADS="1"), text=True, encoding="utf-8", bufsize=1, creationflags=0x08000000 | 0x4000)
n = neu = 0
with open(aus, "a", encoding="utf-8") as f:
for z in open(ein, encoding="utf-8"):
if not z.strip():
continue
n += 1
e = json.loads(z)
q = e["q"] if "q" in e else e
schluessel = {"_fall": e["_fall"]} if "_fall" in e else {"id": e.get("id", n)}
if json.dumps(list(schluessel.values())[0]) in fertig:
continue
if "buttonSeat" not in q: # Archiv-Anfragen ohne Knopf: Knopf sitzt vor dem Small Blind (zu zweit ist der SB der Knopf)
sb = next((int(h["seat"]) for h in q.get("history") or [] if h.get("action") == "POST_SB"), None)
if sb is not None:
k = int(q["seats"]); q = dict(q, buttonSeat=sb if k == 2 else (sb - 2) % k + 1)
try:
a = sh6.anfrage(q, n); a["options"]["include_probs"] = True
p.stdin.write(json.dumps(a, separators=(",", ":")) + "\n"); p.stdin.flush()
r = json.loads(p.stdout.readline())
except Exception as x: # noqa: BLE001 - als Zeile festhalten, nicht abbrechen
r = {"ok": False, "error": {"code": "bruecke", "message": str(x)[:200]}}
f.write(json.dumps(dict(schluessel, ok=r.get("ok"), response=r.get("response"), error=r.get("error")), separators=(",", ":")) + "\n"); f.flush()
neu += 1
print("SHARINGAN gefragt: %d Zeilen, neu %d" % (n, neu), flush=True)
if __name__ == "__main__":
main()