/// m05 game: one `update` turns every action into a new state; replaying a game is a fold over its actions. module Snake.Game open Snake.Model /// How many frames pass between game steps (m10): `max 2 (8 - score / 3)` (integer division). /// Score 0-2 -> 8, 3-5 -> 7, ..., 18 and up -> 2. let movesEvery (score: int) : int = failwith "TODO m10" /// The one function that says how the game changes: `state -> action -> state`. /// /// m05: `Tick` runs a game step (`Spawn.tick`), `Turn` asks to change direction (`Rules.turn`); /// every other action returns the state unchanged. /// /// (m10) `TogglePause` switches Playing <-> Paused and does nothing in any other status. /// (m10) `Restart` gives `Spawn.newGame state.Seed`, whatever the status. /// (m10) `Frame` does nothing unless Playing; otherwise it adds 1 to `Frame`, and when the new `Frame` is a multiple of /// `movesEvery Score` it also runs a game step (`Spawn.tick`) on that incremented state. /// In m10, match every case of `Action` explicitly (no `| _ ->`), so the compiler tells you if one is forgotten. let update (state: GameState) (action: Action) : GameState = failwith "TODO m05" /// Apply all actions in order, starting from `state`, and return the final state. let replay (state: GameState) (actions: Action list) : GameState = failwith "TODO m05" /// Like `replay`, but keep every state: `[state; afterFirst; afterSecond; ...]`, so its length is `List.length actions + 1`. let history (state: GameState) (actions: Action list) : GameState list = failwith "TODO m05"