package knights_tour

  1. Overview
  2. Docs

Module Knights_tour.GameSource

Sourcetype point = {
  1. x : int;
  2. y : int;
}

A coordinate of a square on the board.

Sourcetype move = {
  1. from : point;
  2. dest : point;
}

A move takes a knight from one point on the board to another.

Sourceval moveIsValid : move -> bool

Checks whether this move represents a valid 'L-shaped' knight move.

Sourceval move_to_string : move -> string

Converts move to user-friendly string. This string is meant to be shown to a user in a list of valid moves, they can choose from.

Sourceval moves_to_string : move list -> string

Like move_to_string, but operates on a list of moves.

Sourcemodule Board : sig ... end
Sourcemodule GameState : sig ... end
Sourceval solve : ?report_backtracking:(GameState.t -> unit) -> GameState.t -> Board.t option

Searches for a single solution to the game. You can pass in a optional report_backtracking callback. This is called every time when the search process reaches a 'dead-end' and has to backtrack. This is useful to monitor progress of the search when it is taking a long time. This can be used, for example to periodically draw the best solution found so far on the screen.

Sourceval make_search_space : ?report_backtracking:(GameState.t -> unit) -> int -> Board.t Searchspace.t

Create a Board.t Searchspace.t representing all solutions to the knights tour.

OCaml

Innovation. Community. Security.