package knights_tour

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
type t

A GameState.t represents the complete state of the game at a given point in time. This includes the state of the board as well as the current position of the knight on the board.

val make : int -> t

Creates a 'fresh' gamestate consisting of an empty board and the knight at its starting position.

val valid_moves : t -> move list

Returns a list of moves that is currently valid given the current state of the game.

val steps : t -> int

Returns the number of steps the knight has taken so far. Placing the knight at the start position is counted as a step. (So the number starts a 1 on a 'fresh' board)

val board : t -> Board.t

Returns current state of the board.

val do_move : t -> move -> unit

Update the game state by doing a given move.

val undo_move : t -> move -> unit

Update the game state in reverse, i.e. undo a move. That 'do' and 'undo' are paired in a 'LIFO' order.

val isWinning : t -> bool

Decide whether the current state represents a winning / solved state.

OCaml

Innovation. Community. Security.