SOURCE / PINNED RELEASE
Made of little things.
Pursuit PIT
- Release
- 565f4981bdc3…
- Author-recorded commit
- 197afdbed44b…
- License
- LICENSE
- Author’s source reference
- nostr://npub12lm3rxsva8kfempyjkxupt09e02n3fezurkyadyqfejdc5e0r2kscqty6r/wss%3A%2F%2Fgit.napplet.soy%2F/n-951414e7fd7
Archive hash verified: 3b0485589942fd5c…. The source-to-build association is the author’s claim; it has not been independently rebuilt.
// Runs the PIT bot until a successful PIT, then plays the replay loop twice and checks that
// no car appears or disappears partway through. Run with: bun tools/replay-check.ts
import { Recorder } from '../src/game/replay.ts';
import { Sim, forwardSpeed, wrapAngle, type Input } from '../src/game/sim.ts';
function bot(sim: Sim): Input {
const p = sim.player, t = sim.suspect, gap = t.s - p.s, side = p.x <= t.x ? -1 : 1;
const tx = gap < 7 && gap > 1 ? t.x + side * 1.2 : gap < 25 ? t.x + side * 2.2 : t.x;
const wantYaw = Math.max(-0.25, Math.min(0.25, (tx - p.x) * 0.12 - p.vx * 0.05));
const closing = forwardSpeed(p) - forwardSpeed(t);
return { throttle: gap > 20 ? 1 : closing > (gap - 3) * 0.8 ? -0.4 : 1, steer: Math.max(-1, Math.min(1, (wantYaw - wrapAngle(p.yaw)) * 6)) };
}
for (let attempt = 0; attempt < 10; attempt++) {
const sim = new Sim(1);
const rec = new Recorder();
let pitAt = -1;
while (sim.time < 240) {
sim.step(1 / 120, pitAt < 0 ? bot(sim) : { throttle: 0, steer: 0 });
rec.record(sim);
sim.events.length = 0;
if (pitAt < 0 && sim.outcome === 'pit') pitAt = sim.time;
if (pitAt >= 0 && sim.time > pitAt + 2.5) break;
if (pitAt < 0 && sim.outcome !== 'running') break;
}
if (pitAt < 0) continue;
const replay = rec.replay(sim.lastRearHit);
let ids: string | null = null, frames = 0, changes = 0, loops = 0;
while (loops < 2 && frames < 5000) {
replay.advance(1 / 60);
if (replay.camera().snap && frames > 0) loops++;
const now = replay.state().cars.map((c) => c.id).sort((a, b) => a - b).join(',');
if (ids !== null && now !== ids) changes++;
ids = now;
frames++;
}
console.log(`PIT at ${pitAt.toFixed(1)}s; ${frames} replay frames over ${loops} loops; ${ids!.split(',').length} cars; car set changed ${changes} times`);
process.exit(changes ? 1 : 0);
}
console.log('no PIT in 10 attempts');
