Twenty_fourty_eight.Game
type direction =
| Up
| Down
| Left
| Right
Defines all possible movement directions.
type state =
| Won
| Over
| Playing
Defines all possible game states. The player can keep playing after winning, and the state will be kept as `Won`.
type cell = {
value : int;
position : int;
}
Represents a game cell with a value and an index position.
type t = cell list
Represents the actual game state, which is a list of all cells.
val new_game : unit -> t
Creates a new game with a single random cell.
val move : direction -> t -> t * state * int
Moves all cells into the given direction,generates a new cell, and returns a tuple of the new cells and the game state.