← Lessons

quiz vs the machine

Platinum1740

System Design

Replay And Spectator Systems

Recording inputs to replay matches and stream them to watchers.

6 min read · advanced · beat Platinum to climb

Record inputs, not video

A naive replay records the rendered video, which is huge and cannot change camera angle. Because the simulation is deterministic, a far cheaper approach records only the inputs and the initial seed. Re running the same simulation reproduces the match exactly, frame for frame.

Deterministic playback

  • Store the starting state, the random seed, and every player input per tick.
  • To replay, feed those inputs back through the same simulation code.
  • Any camera or angle is possible because the full world is reconstructed.

This demands that the simulation be fully deterministic, so floating point and ordering must be controlled, or the replay diverges over time.

Spectators and delay

Spectators are a live replay. They subscribe to the match snapshot stream rather than driving inputs. A deliberate broadcast delay, often tens of seconds, prevents a spectator from feeding live positions to a competitor. For huge audiences, snapshots fan out through a relay tier instead of hitting the game server directly.

Key idea

Replays store inputs and a seed for deterministic playback, and spectators are a delayed, relayed live stream of the same simulation.

Check yourself

Answer to earn rating on the learn ladder.

1. Why record inputs and a seed instead of video for replays?

2. What does input based replay require of the simulation?

3. Why add a broadcast delay for spectators?