Knights Tour Problem

The puzzle is to try to move a Knight on a chess board using its normal moves (one or two rows and two or one columns) so that each square is visited once only. If the last square is a knight's move from the first, the tour is closed.

You select various board size and the start square as row,col.

Backtracking is used to try to find a solution, though this is aborted if it is taking too long.

You may need to change the start square to find a solution.

If Closed is ticked then the program keeps looking for a closed tour. Note there is no closed tour if the board size is odd.

Check for Impossible can speed the search - it identifies there is no solution with the current search if it finds an empty square which cannot be reached from any other empty square or, if Closed, if cannot return to the start square.

Warnsdorff's heuristic is much better. It looks at the possible moves and ranks them according to the fewest number of moves from each next position.

Searching a board larger than 6*6 is likely to abort with no solution if neither speed up option is chosen.

Press ShowMoves to see how it does it - using backtracking - where each move is shown - note this takes a long time! Use the slider to adjust the animation speed.

Board size

Start at (r,c) Closed

Check for Impossible Warnsdorff Heuristic