knight's tour is when the knight, alone on the chessboard, makes 64 moves,
landing on each square once and only once. A "closed" tour is one
where the knight returns to the starting square. There are several approaches to solving
this problem, including Warnsdorff's rule (always moving to the square having
the fewest onward moves). You push attempts onto the stack, try, and upon failure, return to the next candidate path. This simple algorithm is quite fast and finds
different solutions depending on which square you start.
I have written millions of lines of code but have never sat through a class on computer programming. I had to pass the course to graduate so I made a proposition. The instructor would assign me a problem. If I could solve it, I would get an A and never have to take a test. The problem I was assigned: the knight's tour. Two days later I turned in the solution using FORTRAN. The year was 1974 and I had no idea he had been given the problem in graduate school but had never solved it. Years later I translated the algorithm into assembler, first for the HP-1000 minicomputer and then for Intel x86. The entire executable code is only 1665 bytes. It is 16-bit and will run on any 32-bit version of Windows, but will only run on a 64-bit O/S inside a virtual box.
The code is available here> knights_tour_16bit.zip The algorithm is also available in C. The core of which is listed below:
int Tour(int x1,int y1)
The complete code is available here> knights_tour_inC.zip
I also have a 3D version using OpenGL shown here:
The code is available here> knights_tour_in_3D.zip The animated result is shown below: