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

  1. Create a graph of legal knight moves on an 8x8 board.
  2. Perform a depth-first search (dfs) for a path with a length of 64.
  3. Print the path

Extensions

  1. Improve the performance of algorithm by modifying it to use the orderByAvailable heuristic described in the textbook.
  2. 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.
  3. Create a graphics-based demonstration of the steps a night takes in completing its tour.