Game
The rules of Invaders, as a pure function.
step takes a world and one input snapshot and returns the next world. It has no clock,
no window, and no IO, and its randomness is threaded through as data. That is what lets
the whole game be tested headlessly, and what makes an identical input script replay to an
identical world.
step is a pipeline of small stages. Each one is worth reading on its own, and each is
tested on its own.
Definitions
An exact, comparable rendering of a world.
Flix records do not derive Eq, and comparing worlds is what the replay tests do, so
the game provides this instead. It is deliberately exact rather than rounded -- two
runs of the same code on the same machine produce bit-identical floats, and IEEE
arithmetic is deterministic across machines too, so there is nothing to be gained by
blurring it. A digest also gives a readable diff when a replay does drift.