Knight's Tour
A knight must visit every square on the chessboard exactly once. Watch the algorithm solve it in real-time using Warnsdorff's heuristic.
Tour Type
Knight can end anywhere on the board
Progress
Options
Full Project Stats
The Problem
The Knight's Tour is a classic chess puzzle: move a knight across an entire chessboard, visiting each square exactly once. On a standard 8×8 board, that's 64 squares to visit in a specific sequence.
There are two variants: Open tours where the knight can end anywhere, and Closed tours where the knight must end one move away from its starting position, forming a loop.
The Approach
Naive Backtracking
Try every possible move. When stuck, backtrack and try a different path. Works, but requires 10,000,000+ iterations for larger boards.
Warnsdorff's Heuristic
Always move to the square with the fewest onward moves. This simple rule dramatically reduces iterations needed, finding solutions almost instantly.
Results
| Board | Variant | Tours Found | Time |
|---|---|---|---|
| 8×8 | Open | 431,513 | 315.92s |
| 8×8 | Closed | 68,993 | 405.73s |
| 5×5 | Open | 1,728 | 162.10s |