Knight's Tour

"Can the knight chess piece move around an empty chessboard and touch each of the 64 squares once and only once?"

Click here to check out the project!


For my .NET & C# course, we were given a project to tackle the "Knight’s Tour" problem using the C# and Windows Forms. Using an 8-by-8 chessboard, I created a program that prompted the user for 2 methods of handling this problem.


The "Non-Intelligent" method made the knight randomly select any available position on the chessboard. From my code, it allowed the knight to move up to 50 squares and sometimes only till 10 squares. This method was a quick way to find available positions, since it did not calculate which of the possible moves was the better choice. For this reason, the results of this method can cause discrepancy from one run to another.

The "Heuristics" method allowed the knight to choose the best available square to move to. The outer squares on the chessboard is more troublesome than the squares in the centre of the board, but corner squares are even more problematic. In this method, the knight chooses the most troublesome squares first. This will allow the knight to tackle the difficult squares first, then handle the easiest ones to reach last.

When the “Play!” button is pressed, it will show the knight’s locations on the chessboard. However, it will only show only 1 run of program. For this reason, the program will output to a file showing the results of each run. The properties and methods of each class in this application is seen on the right.


Knight's Tour