drive
Advances the world world builds through seconds seconds of fixed-rate steps, its input commanded by controls — a whole game session run headlessly.
Every step advances by exactly 1/tickRate seconds, so a session is deterministic: no wall clock, no display frames, no remainder steps. controls is evaluated once per step, before the step runs, with the elapsed seconds at the step's start and the world itself — a time-scripted session ignores the world, a closed-loop one reads it. Edges are synthesized by diffing consecutive controls: a key present that was absent the step before reads as a press edge on exactly that step, a key gone as a release edge, matching the sampled-input latching contract — one press per hold, never one per step. The pointer follows the same rule through Controls.pointerDown, and a pointer that vanishes while down yields its release edge at its last position. The first step diffs against Controls.NONE, so state held from the very start still edges.
onStep runs after every step with the elapsed seconds at the step's end — the observation hook a session records itself through. A step ending in restart discards the world: world builds the replacement within that same step, onStep observes the replacement from that step on, and the next step advances it — the step count is unchanged. Controls diff across the swap as across any two steps, so a key held through a restart is still down in the replacement without a fresh press edge. An exception thrown by controls, onStep, or the world's update propagates unchanged, ending the session — Restart is the one the driver consumes.
Return
The world live after the last step — the last one world built.
Parameters
Builds the world to advance — at the session's start, and again on each restart.
The session length; the step count is seconds * tickRate, rounded to nearest.
The step frequency in Hz; every step's dt is 1/tickRate.
Observation hook run after each step; defaults to doing nothing.
The input policy evaluated before each step; defaults to Controls.NONE.
Type Parameters
The world type driven.