package knights_tour

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
type point = {
  1. x : int;
  2. y : int;
}

A coordinate of a square on the board.

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

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

val moveIsValid : move -> bool

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

val 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.

val moves_to_string : move list -> string

Like move_to_string, but operates on a list of moves.

module Board : sig ... end
module GameState : sig ... end
val 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.

val 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.