"""Take the on-screen predictions from board `genesis`: each test's first value, by position. python tools/predict.py [path to md-run] The table is patched into the ROM after linking, so filling it moves no code. These are what our board does today: what we want checked, not the truth. """ import json import subprocess import sys import tempfile from pathlib import Path ROOT = Path(__file__).resolve().parent.parent sys.path.insert(0, str(ROOT / "tools")) import decode RUN = sys.argv[1] if len(sys.argv) > 1 else r"D:\dev\pin2\target-megadrive-rust-fast\release\md-run.exe" subprocess.run([sys.executable, "build.py"], cwd=ROOT, check=True, capture_output=True) with tempfile.TemporaryDirectory() as t: save = Path(t) / "p.sav" subprocess.run([RUN, "out/alewman-probe.bin", "--machine", "genesis", "--frames", "7000", "--save", str(save)], cwd=ROOT, check=True, capture_output=True) run = decode.latest(decode.parse(save)) table = [t["records"][0][2] if t["records"] else None for t in run["tests"]] (ROOT / "predict.json").write_text(json.dumps(table) + "\n") subprocess.run([sys.executable, "build.py"], cwd=ROOT, check=True) print(len(table), "predictions")