Back to Pursuit PIT
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.

tools/getaway-check.ts
// Getaway mode, headless: a driver who just holds a lane flat out (braking for traffic) against
// the three police cars. Reports how each run ends. Run with: bun tools/getaway-check.ts
import { Sim, forwardSpeed, laneX, MPS_TO_MPH } from '../src/game/sim.ts';
import { curvature, setRoadSeed } from '../src/game/road.ts';
import { closedAhead } from '../src/game/zones.ts';
const results: Record<string, number> = {};
for (let r = 0; r < 8; r++) {
  setRoadSeed(r + 1);
  const sim = new Sim(0.75 * 0.6, false, 'red', true);
  let pits = 0, bumps = 0, minGap = Infinity, maxGap = -Infinity;
  while (sim.outcome === 'running' && sim.time < 180) {
    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));
    // Flat out in a lane, steering only to keep it (no evasion); brake for traffic just ahead.
    const ahead = sim.cars.some((c) => c !== p && c.kind !== 'police' && Math.abs(c.x - p.x) < 2.2 && c.s - p.s > 0 && c.s - p.s < 25 + v * 0.8);
    sim.step(1 / 120, { throttle: ahead ? -1 : 1, steer: 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))) });
    for (const e of sim.events) { if (e.type === 'pit' && e.car === p.id) pits++; if (e.type === 'bump' && e.other?.kind === 'police') bumps++; }
    sim.events.length = 0;
    const g = sim.policeGap;
    if (isFinite(g)) { minGap = Math.min(minGap, g); maxGap = Math.max(maxGap, g); }
  }
  const key = sim.time >= 180 ? 'timeout' : sim.outcome;
  results[key] = (results[key] ?? 0) + 1;
  const wrecked = sim.police.filter((c) => c.wrecked).length;
  console.log(`run ${r}: ${key} at ${sim.time.toFixed(0)} s, PITs on player ${pits}, police bumps ${bumps}, police wrecked ${wrecked}, gap ${minGap.toFixed(0)}..${maxGap.toFixed(0)} m, top ${(Math.max(...sim.police.map((c) => forwardSpeed(c))) * MPS_TO_MPH).toFixed(0)} mph`);
}
console.log(results);