Skip to content
→ All work

Case study 24 / 37

Emberline

A 2D game engine where time is a data structure: fixed-step deterministic simulation, hold-to-rewind, replays and save files that are verifiable input logs.

Status
Research
Period
2026
Domain
Web · Experiments
Language
TypeScript
Last push
26 OCT 2026
License
MIT
Source of claims
README.md, ARCHITECTURE.md
Ember Run pixel platformer level rendered by the Emberline engine

01/The problem

In most engines, time travel, replays and deterministic saves are things you build yourself, and you find out too late that randomness and wall-clock time are scattered through your systems.

02/The system

Emberline records every input frame of a deterministic, fixed-step simulation, which gives rewind, replays, tamper-evident saves and, in the demo, a bot that completes a level by searching the future and rewinding. TypeScript with zero runtime dependencies; runs in the browser and headless in Node.

03/Implementation

  1. 01An ECS with JSON-only components, deterministic query order and deep snapshot/restore.
  2. 02A timeline at the core: fixed-hz steps, keyframes, rewind, seek, hashing and serialisation, with an accumulator loop and render interpolation.
  3. 03AABB physics, scenes, a Canvas2D renderer with camera and DPR-aware backing store, an asset packer that reads PNG headers, and Web Audio triggered from tick events.
  4. 04Saves are a keyframe plus the input log; loading replays them and rejects a file whose replay diverges.
  5. 05A debug overlay and an entity inspector.

04/Engineering

Determinism is enforced, not hoped for

A lint fails the build if engine code touches Math.random, Date.now, performance.now or the DOM outside the backends that own them.

The engine can search

Because stepping and rewinding are cheap and exact, the headless bot completes the level by depth-first search over inputs, using the same code path players use.

05/Interface

The bundled Ember Run platformer demo rendered on Canvas2D at its first frame, with coins, spikes, platforms and the goal.
The demo after a short run with the backtick debug overlay on, showing the simulation tick, entity count, state hash and keyframe interval.
Holding R rewinds the deterministic simulation; the banner shows the tick being rewound to.

Real screenshots of the running software. Captions state the data shown.

06/Tech stack

  • TypeScript
  • Zero runtime dependencies
  • ECS
  • Canvas2D
  • Web Audio
  • Node test runner

07/Result

Verified outcomes

  • 17 tests: identical hashes for identical inputs, exact rewind, save/load round trip and tamper rejection; CI runs the headless demo end to end.

Known limitations

  • Canvas2D only; AABB physics without dynamic-vs-dynamic response; cross-browser bit-exactness not yet verified in CI.

08/Links

Related work

Next case study

ArchitectFlow →