Districts that remember you, and roads worth staying on

Area heat. Road heat alone rewarded a strange kind of play: work one part of
town hard but take a different street every time, and nothing ever got hot. A
second, coarser pool now accrues from being inside a district at all — on-road
or off — and bleeds into every road running through it, including ones never
driven. Deliberately capped below the barricade threshold: a hot district gets
roads patrolled, but concrete still takes somebody actually using that road. It
also decays slower than road heat, because one patrol re-secures a road while a
district's reputation lingers.

Surfaces. Off the route the car now makes about 40% of its road top speed, loses
grip and scrubs momentum in a fifth of the distance, so the road hierarchy is
something you feel rather than something the map merely claims. A first tuning
made off-road a 12 km/h crawl, which removed the choice instead of pricing it —
going round a checkpoint cross-country has to stay a legitimate move.

Speed. Heat scales with how fast you were going, not just how far, and stops
rewarding ever-higher speed past a point so the answer is never one exact number
on the clock. With the road classes, that makes the routing decision real: the
trunk fast and noticed, or the lanes slow and ignored.

Save format goes to v2 for the district pool; older saves are refused rather
than half-restored. Also fixes a population test that hardcoded densities since
tuned, and README claims about patrols and AI that Phase 6 made untrue.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
dejvino
2026-08-08 12:06:59 +02:00
co-authored by Claude Opus 5
parent 9ae00dc978
commit 9eaa05d7ef
15 changed files with 443 additions and 85 deletions
+8 -4
View File
@@ -1,5 +1,5 @@
import type { DriverInput } from '../core/input';
import type { Handling } from '../sim/car';
import { TARMAC, type Handling, type Surface } from '../sim/car';
import type { PhysicsWorld } from './physics';
import { WHEELS } from '../carSpec';
@@ -36,6 +36,7 @@ export function drive(
input: DriverInput,
handling: Handling,
dt: number,
surface: Surface = TARMAC,
): void {
const { vehicle } = physics;
const speed = vehicle.currentVehicleSpeed();
@@ -54,13 +55,16 @@ export function drive(
// Throttle vs. brake: pressing back while rolling forward is braking, not reverse.
const wantsReverse = input.throttle < 0;
const braking = input.handbrake || (wantsReverse && speed > 1) || (input.throttle > 0 && speed < -1);
const engineForce = braking ? 0 : input.throttle * handling.engineForce;
// Off the tarmac the engine is fighting the ground for traction.
const engineForce = braking ? 0 : input.throttle * handling.engineForce * surface.drive;
let brakeForce: number;
if (input.handbrake) brakeForce = handling.brakeForce * 1.6;
else if (braking) brakeForce = handling.brakeForce;
else if (input.throttle === 0) brakeForce = handling.coastBrake;
else brakeForce = 0;
// Rough ground drags on you whether or not you are asking it to.
brakeForce += handling.coastBrake * surface.drag;
// At a crawl with no throttle, hold the car still instead of letting it creep.
// Otherwise "stop the car" for a mission is a fight against a rolling wreck.
@@ -74,7 +78,7 @@ export function drive(
vehicle.setWheelEngineForce(i, w.driven ? engineForce : 0);
// Handbrake locks the rear only — that is where the rotation comes from.
vehicle.setWheelBrake(i, input.handbrake && w.steered ? 0 : brakeForce);
vehicle.setWheelFrictionSlip(i, handling.frictionSlip);
vehicle.setWheelSideFrictionStiffness(i, handling.sideFrictionStiffness);
vehicle.setWheelFrictionSlip(i, handling.frictionSlip * surface.grip);
vehicle.setWheelSideFrictionStiffness(i, handling.sideFrictionStiffness * surface.grip);
}
}
+43 -1
View File
@@ -1,7 +1,14 @@
import { describe, expect, it } from 'vitest';
import { createPhysics } from './physics';
import { createDriveState, drive } from './drive';
import { deriveHandling, freshCondition } from '../sim/car';
import {
deriveHandling,
freshCondition,
ROUGH,
surfaceFor,
TARMAC,
type Surface,
} from '../sim/car';
import type { DriverInput } from '../core/input';
import { generateWorld } from '../sim/world';
@@ -170,6 +177,41 @@ describe('taking a junction', () => {
});
});
describe('roads are worth using', () => {
/** Flat out on a given surface for long enough to find its ceiling. */
async function topSpeed(surface: Surface) {
const physics = await createPhysics(generateWorld(1, 0));
const state = createDriveState();
const handling = deriveHandling(freshCondition());
let top = 0;
for (let i = 0; i < 30 / STEP; i++) {
drive(physics, state, { ...IDLE, throttle: 1 }, handling, STEP, surface);
physics.step(STEP);
top = Math.max(top, physics.vehicle.currentVehicleSpeed());
}
return top;
}
it('goes markedly faster on tarmac than across country', async () => {
const road = await topSpeed(TARMAC);
const rough = await topSpeed(ROUGH);
expect(rough).toBeLessThan(road * 0.6);
});
it('still lets you leave the road when you need to', async () => {
// Going around a checkpoint cross-country has to cost something without
// being impossible. An earlier tuning made off-road a 12 km/h crawl, which
// is not a decision — it is a wall.
const rough = await topSpeed(ROUGH);
expect(rough).toBeGreaterThan(12);
});
it('is chosen by whether the car is on a route at all', () => {
expect(surfaceFor(true)).toBe(TARMAC);
expect(surfaceFor(false)).toBe(ROUGH);
});
});
describe('vehicle', () => {
it('settles on its suspension instead of sinking or bouncing away', async () => {
const r = await run({}, 2);