Files
Syplheed-Reborn/tools/re-capture/whatchanges.py
Claude (auto-RE) 72365b217a re: memory-driven autopilot -- infrastructure, and an honest account of what is not solved
Reads the live world out of guest RAM and drives the pad from it. Working:
loop-rate memory reads, whole-RAM float scanning with numpy (1270 orthonormal
3x3 blocks in 6.2 s), entity enumeration by unit type (116 live instances in
Stage 02), pad control written straight into the vgamepad FIFO (the CLI spawns
a process per command and its tap/hold sleep inside the server, so neither is
usable in a control loop), unattended mission entry, and the Hangar loadout --
the "Recommended" control is AUTO SELECT, which at 5 % progress is a no-op
because only two weapons are developed and both are already mounted.

Not working, and the reason the craft is not yet flown: the class 0x820af030
is NOT the live entity. It has one object per spawned thing and carries the
unit-ID string, which is why it looked like the entity list, but every one of
its 384 words is constant across a 29 s in-flight capture. No transform lives
in it or one pointer hop from it. Input correlation (hard left yaw vs hard
right, looking for a turn axis that reverses) does find self-like objects at
cos = -0.99, but they cluster in what looks like a camera volume rather than
the craft, and with no definition pointer near them the trick of learning one
entity's layout and applying it to the rest has nothing to anchor on -- so the
33418 moving triples in a firefight cannot be split into enemies, friendlies
and bullets, and there is nothing to aim at.

Two dead ends are recorded so they are not repeated: RT is not the throttle
(the two-state speed scan therefore found nothing), and comparing orientation
matrices 2 s apart is outside the small-angle regime, which is what produced
"angular velocities" of 30000.

Also corrects the claim in unit-struct-runtime.md that 0x820af030 holds live
state. The definition class 0x820af844 and every value derived from it are
unaffected.

autopilot2.py (a PD controller using body angular velocity from consecutive
rotation matrices) is committed but has never had a valid config to run
against, and is marked as untested.
2026-07-29 19:04:33 +00:00

77 lines
2.5 KiB
Python

#!/usr/bin/env python3
"""Encoding-agnostic: which words of an object actually carry live state?
Rather than assume the orientation is a matrix (it is not) or a quaternion,
classify every 4-byte word of the captured window by how it behaves over the
capture: constant, smoothly varying (a continuous quantity), or jumpy.
Usage: whatchanges.py <probe.bin> [name-substring] [max-report]
"""
import math
import struct
import sys
sys.path.insert(0, "/home/fabi/RE - Project Sylpheed/sylpheed-reborn/tools/re-capture")
from flight_analyze import load # noqa: E402
def main():
path = sys.argv[1]
want = sys.argv[2] if len(sys.argv) > 2 else "Player"
top = int(sys.argv[3]) if len(sys.argv) > 3 else 60
insts, window, frames = load(path)
i = next(k for k, (_, _, nm) in enumerate(insts) if want in nm)
print(f"# {insts[i][2]} @ {insts[i][0]:#010x}, {len(frames)} frames, window {window:#x}")
nconst = nsmooth = njump = 0
smooth = []
for o in range(0, window - 3, 4):
vals = []
ok = True
for t, inp, lab, bufs in frames:
(v,) = struct.unpack_from(">f", bufs[i], o)
if not math.isfinite(v):
ok = False
break
vals.append(v)
if not ok:
continue
lo, hi = min(vals), max(vals)
if lo == hi:
nconst += 1
continue
rng = hi - lo
steps = [abs(b - a) for a, b in zip(vals, vals[1:])]
mx = max(steps)
# smooth = no single step is a large fraction of the whole excursion
if mx < 0.25 * rng:
nsmooth += 1
smooth.append((o, lo, hi, vals))
else:
njump += 1
print(f"# constant {nconst} smooth {nsmooth} jumpy {njump}")
print(f"\n# smoothly varying words (candidate continuous state):")
for o, lo, hi, vals in smooth[:top]:
print(f" +{o:#05x} [{lo:12.4g} .. {hi:12.4g}] "
f"start {vals[0]:12.4g} end {vals[-1]:12.4g}")
# consecutive runs of smooth words -> vectors
offs = [o for o, _, _, _ in smooth]
runs, cur = [], []
for o in offs:
if cur and o == cur[-1] + 4:
cur.append(o)
else:
if len(cur) >= 3:
runs.append(cur)
cur = [o]
if len(cur) >= 3:
runs.append(cur)
print(f"\n# runs of >=3 consecutive smooth words (vector-shaped):")
for r in runs:
print(f" +{r[0]:#05x} .. +{r[-1]:#05x} ({len(r)} words)")
if __name__ == "__main__":
main()