A Knight's Tour

Another interesting problem relating to classical search in AI is the Knight's Tour.

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. - Wikipedia

I implemented a solution that tries to perform a open path tour and returns a list of squares the knight has to travel to from begin to end. I found no need to use the simpleai library this time. Instead used a greedy search that will always take the action that results in a state with the fewest actions possible, otherwise known as the Warnsdorf's rule. If it doesn't find a path in the first case it will simply return an error for the given N and start point.