Knight's Tour
A "knight" in chess is able to move in an odd L-shaped pattern, 2
steps in one direction and 1 more step either to the left or right from
that direction. A "tour" of the knight is one in which is manages to
visit every single location in a square or rectangular range of
locations.
Write a program that prints out a series of Knight moves that will
accomplish a knight's tour.
Strategy
- Create a graph of legal knight moves on an 8x8 board.
- Perform a depth-first search (dfs) for a path with a length of
64.
- Print the path
Extensions
- Improve the performance of algorithm by modifying it to use the
orderByAvailable
heuristic described in the textbook.
- Modify your program so that it works with rectangular boards as
well. What mathematical constraints are there on the dimensions of a
rectangular board that will allow for a successful knight's tour? See Knight's tour
(Wikipedia) for further information.
- Create a graphics-based demonstration of the steps a night takes in
completing its tour.