#!/usr/bin/env python3 """Pin the world-unit / displayed-speed ratio at the one unambiguous point. At neutral throttle the HUD reads exactly `CruisingVelocity` (350 for the player), so no digit-reading is needed to know the game's own number — only a clean measurement of how far the craft actually travels in world units. Cleanliness matters more than length here: earlier ratios (1.19–1.29) were sampled in a firefight where the craft is shoved around, and with a stick input the path is longer than the displacement. So this flies straight, holds neutral throttle, and takes ONE long displacement over a 20 s window, plus screenshots at both ends to confirm the HUD never moved off 350. Usage: cruise_ratio.py [window_s] """ import math, os, subprocess, sys, time sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) import speed_law CRUISE = 350.0 # UN_f001_TCAF_DeltaSaber_T_Player CruisingVelocity def pad(*a): subprocess.run(["vgamepad", *a], capture_output=True) def shot(name): subprocess.run(["screenshot", f"/sylph-home/re/shots/{name}.png"], capture_output=True) def main(): win = float(sys.argv[1]) if len(sys.argv) > 1 else 20.0 w, off, nm = speed_law.find_player() if not w: sys.exit("player entity not found after retries") print(f"# locked on {nm}") pad("reset") pad("trig", "RT", "0.0"); pad("trig", "LT", "0.0") time.sleep(6.0) # settle at cruise, sticks centred shot("cruise_start") p0, t0 = speed_law.pos_at(w.fd, off), time.time() samples = [(0.0, *p0)] while time.time() - t0 < win: time.sleep(0.25) samples.append((round(time.time() - t0, 3), *speed_law.pos_at(w.fd, off))) shot("cruise_end") p1, t1 = samples[-1][1:], samples[-1][0] disp = math.dist(p0, p1) path = sum(math.dist(samples[i][1:], samples[i + 1][1:]) for i in range(len(samples) - 1)) print(f"# window {t1:.1f}s displacement {disp:8.0f} path {path:8.0f} " f"straightness {disp / path:.3f}") print(f"# speed by displacement {disp / t1:7.1f}/s by path {path / t1:7.1f}/s") print(f"# ratio vs HUD {CRUISE:.0f}: displacement {disp / t1 / CRUISE:.3f} path {path / t1 / CRUISE:.3f}") if __name__ == "__main__": main()