Page 1 of 1

Knight's Tour in GP

Posted: Jul 7th, '19, 05:49
by manyone
From wikipedia: A knight's tour is a sequence of moves of a knight on a chessboard such that the knight visits every square only once. If the knight ends on a square that is one knight's move from the beginning square (so that it could tour the board again immediately, following the same path), the tour is closed, otherwise it is open.
my program does not attempt to solve a closed path. It stops at every solution found and asks for an OK to continue. I added an option at the start for selecting the size of the chessboard from 5 x 5, 6 x 6, 7 x 7, or 8 x 8. On my desktop windows 10 pc, the 5 x 5 finds a solution almost instantaneously, the 6 x 6 takes about 1 minute to arrive at the first solution, the 7 x 7 takes 8 minutes, and the 8 x 8 takes about 15 minutes!
knights_tour.gpp
(27.13 KiB) Downloaded 9 times
knights_tour.JPG