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.
// Measures the "always a route" rule while the patrol car hangs back at 55 mph:
// how often traffic blocks more than MAX_BLOCKED lanes in a ROUTE_BAND stretch, and why.
// Run with: bun tools/route-check.ts
import { LANES, ROUTE_BAND, Sim, forwardSpeed, laneX, maxBlocked, nearestLane } from '../src/game/sim.ts';
import { curvature } from '../src/game/road.ts';
import { closedAhead } from '../src/game/zones.ts';
/** Keep the patrol car in an open lane through the bends (as attract mode does). */
function steer(sim: Sim): number {
const p = sim.player, v = forwardSpeed(p);
const rate = (1.5 * Math.min(1, v / 7)) / (1 + v / 45);
const lane = Math.max(3, closedAhead(p.s, 300));
return Math.max(-1, Math.min(1, (curvature(p.s) * v + 0.12 * (laneX(lane) - p.x) - 1.6 * p.yaw) / Math.max(rate, 0.1)));
}
let withWreck = 0, sliding = 0, moving = 0, samples = 0, wrecks = 0;
for (let r = 0; r < 6; r++) {
const sim = new Sim(1);
for (let step = 0; step < 120 * 90; step++) {
sim.step(1 / 120, { throttle: forwardSpeed(sim.player) < 24.6 ? 1 : 0, steer: steer(sim) });
sim.events.length = 0;
if (step % 30) continue;
for (let s = sim.player.s - 50; s < sim.player.s + 300; s += 10) {
samples++;
const cars = sim.cars.filter((c) => c.kind === 'traffic' && c.ramp === null && c.s >= s && c.s <= s + ROUTE_BAND);
const lanes = new Set(cars.map((c) => (c.wrecked ? nearestLane(c.x) : c.lane)).filter((l) => l < LANES));
if (lanes.size <= maxBlocked(s)) continue; // two open lanes stay free (one on a three-lane road)
if (cars.some((c) => c.wrecked)) withWreck++;
else if (cars.some((c) => c.slide > 0)) sliding++;
else moving++;
}
}
wrecks += sim.cars.filter((c) => c.wrecked).length;
}
console.log({ samples, blocked: { withWreck, sliding, moving }, wrecksLeftAtEnd: wrecks });
