Coldwave Read the docs

Steps and determinism#

Note. The command is ven in today's builds and becomes frost at launch, and so do the names built from it.

Your game plays the same way every time, on every machine. That is what makes replays, tests, time travel and multiplayer possible, and it comes from one rule: a game moves in fixed steps, sixty a second, each exactly 1/60 s of game time, however fast the machine draws. A step takes the step's input, runs the engine's stages in one declared order and ends with a checksum of the whole world. The same files, the same seed and the same input give the same world at every step, bit for bit, on a Mac, on Linux, in a browser and on a phone. Everything else the engine does (replays, tests, time travel, multiplayer, "who wrote this value") is built on that.

One step#

StageDoes
inputThe step's actions: held keys, sticks, the pointer, fingers, or a recording's
interfaceMenus and controls (Node, Button, ...) use the input; a use sends its event
physicsBox2D in 2D, Jolt in 3D: bodies and movers move, contacts and sensors send events
scriptsEach script's step(dt), in the project's order, reading where physics left things
animationClips and tweens write their frames and fields
layoutThe interface again, reading no input, so a menu a script showed is laid out this step
eventsThe step's events are kept for the next step's scripts

Drawing is not a stage: a picture is drawn from the world after a step, as often as the display asks, and drawing changes nothing. A window that is hidden gets no frames and the game still steps.

What keeps it the same everywhere#

  • Fixed time. dt is always 1/60. A slow frame is dropped, never queued, so lag never builds up.
  • Seeded random. math.random starts from the project's seed. The same seed plays the same game.
  • The same arithmetic. Machines' C libraries differ in the last digit of sin and its kin, so scripts' math functions are the engine's own and Luau is built so a multiply and an add are never fused. Use math.pow for a power that is not a written 2, 3 or 0.5.
  • A declared order. Systems run in the order above; events come sorted by kind and by the things' slots; physics steps the same on one thread or eight.

The checksum#

frost run --headless --steps 600 game.toml prints two numbers:

  • world checksum: the world after the last step, 16 hex digits. Equal checksums mean equal worlds, on any machine.
  • run checksum: every world from the start to there, summed. A project's replay holds this one; recorded runs explain how frost test uses it.

The world is every thing's components, every script's state, the physics' own state and the random generator. It is not the picture, the sound, the time a step took or a script's local variables.

What to keep where#

What the game is lives in the world or in state. A local at the top of a script is a cache: the checksum does not cover it, a reload empties it, and a world put back by a seek, a test or a rollback does not bring it back. Keep there only what can be built again from the world and state (in on_scene, or when first needed), and empty it in on_restore(), which the engine calls after a world is put back. frost test --restore finds a script that breaks this rule.

state holds plain data only: numbers, text, true or false, and tables of those.

Sound is output, never game state: a game never reads what it played. Input is read by action (input.get(0, "move")), never by device, so a key, a pad, a finger and a recording drive the same game.

Where it pays off#