Skip to main content

Module history

Module history 

Source
Expand description

A game’s history: the state it started in and every command applied since. Its rules are deterministic (TurnRules), so any earlier point is rebuilt by replaying, which is what replays, rewinds and saving a game in progress need. What a rewind costs, if anything, is the game’s.

§Rules

  • Points. Point n is the game after its first n commands (History::state_at); point 0 is the state it started in. Rewinding to point n (History::rewind_to) forgets command n and every one after it.
  • A refused command replays as nothing, as it changed nothing when it was sent; a history that recorded one by mistake replays as if it had not.
  • Saving. A history is written as its first state and its commands: (initial: …, commands: [ … ]).

Structs§

History
A game’s first state and the commands applied since, oldest first.
NoSuchPoint
Why a rewind was refused: there is no earlier point n (it must be below the number of commands). Nothing changed.
Replayed
One past command, replayed (History::replay).