logo
By Lawrence

15 minutes

Spawning and Pools

This lesson runs in the same lab as lesson 2, with the attackers still switched off. Your WeaveMeter can stay. Comment out the nervous block for now, since the numbers here were measured without it.

The civilian budget

Lesson 1.7 showed that a budget beats a clock: keep about so many cars per 100 m of road, and top up when one leaves. It did not say how hard the spawner works to hold that budget, or why the window's edges sit where they do.

The lab runs at level 3. levelPlan turns that into a traffic factor of 1.16, so the budget is:

src/components/HighwaySpawner/HighwaySpawner.core.ts
/** How many civilians the window should hold. */
export function civilianTarget(windowLength: number, density: number, max: number): number {
  return Math.min(max, Math.round((windowLength / 100) * density));
}
civilianTarget(240, 2.1 * 1.16, 11)   // 6   (5.85, rounded)

That is six cars at any speed. Higher levels add a car every few levels, up to 8. The cap of 11 never comes into play at this density.

Continue reading

Unlock the Full Course

Every lesson, the runnable examples, and the finished build — yours to keep.

$5one-time

Was this page helpful?

We read every note — tell us what's working and what isn't.

↑↓ NavigateEnter SelectEsc CloseCtrl+K Open Search