ocamllabs / 2048-tutorial

OCaml tutorial based on the 2048 game
49 stars 12 forks source link

Order and improve tests #24

Closed yallop closed 10 years ago

yallop commented 10 years ago

Turn the tests into more of a guide through the steps. There are now six tutorial steps, four "core" and two "extended", and the tests can be progressively enabled to follow the implementation order.

Core steps

  1. Logic for whether a board is a winning board:
    • write is_square_2048
    • write is_board_winning using is_square_2048
  2. Logic for shifting the board left, right, up and down.
    • write shift_left_helper
    • write shift_board using shift_left_helper
  3. Logic for inserting new squares
    • write insert_into_row using replace_one from Utils
    • write insert_square using replace_one and insert_into_row

(At this point the game should be somewhat playable.)

  1. Logic for whether a board is a losing board
    • write is_complete_row
    • write is_game_over using is_complete_row

      Extension steps

  2. Provenance of tiles. This enables sliding animations.
    • write square_provenances
    • update the shifts / string_of_square / etc. functions
  3. Making new square insertion non-deterministic
    • Update insert_square to use a random position, using Utils.replace_at