What is the knight's tour puzzle?
The knight's tour is a puzzle where a single chess knight must land on every square of the board exactly once. It is one of the oldest chess puzzles and a classic example in mathematics.
The knight is the only chess piece that jumps over others. Each move goes two squares horizontally or vertically and then one square to the side, landing in an L shape. In this game you choose a starting square and then tap the squares that glow with a green ring. Each square you leave keeps a small brass button with its move number, and a golden line links the squares in order. When every square is visited, the crossing lines form a star or flower pattern.
What are the exact rules?
There are only two rules. Move only like a knight, and never land on the same square twice. The tour is complete when you have visited as many squares as the board has.
| Board | Squares | Possible starts | Closed tours |
|---|---|---|---|
| 5×5 | 25 | 13 squares the colour of the corners | None |
| 6×6 | 36 | Every square | Yes |
| 7×7 | 49 | 25 squares the colour of the corners | None |
| 8×8 | 64 | Every square | Yes |
A knight always alternates between light and dark squares. On the odd 5×5 and 7×7 boards one colour has one extra square, so a tour must start on that colour, the colour of the four corners. The game only marks squares where a tour is possible, and our solver confirmed that a full tour exists from all 13 such squares on 5×5 and all 25 on 7×7.
What is Warnsdorff's rule?
Warnsdorff's rule says: of all the squares you can jump to, go to the one that has the fewest onward moves. H. C. von Warnsdorff published it in Germany in 1823.
Squares with few exits are the ones that get stranded if you leave them for later, corners and edges above all. Dealing with them first and saving the roomy centre for the end greatly cuts the chance of running into a dead end. For example, if you can reach three squares that would leave 2, 5 and 3 onward moves, you pick the one with 2. Following this rule alone completes most 8×8 tours on the first try.
The hint in this game tries Warnsdorff's order first and backtracks through other branches when it gets stuck, so it only suggests a square that really leads to a full tour. If your path can no longer be finished, it works out how many moves back you need to go, makes that square sparkle blue, and one tap on it rewinds the board to that point.
What is a closed tour?
A closed tour is a complete tour whose last square is one knight's jump away from the first, so the path joins up into a loop. It is also called a re-entrant tour.
When you finish a closed tour, a glowing dashed line links the last square back to the first, a ring of stars circles the starting square, and the result card counts your closed tours. Closed tours only exist on boards with an even number of squares, because a loop needs the same number of light and dark squares. In this game you can aim for one on the 6×6 and 8×8 boards.
How old is the knight's tour?
The knight's tour is more than a thousand years old. The earliest known example appears in the Kavyalankara, a 9th century work on poetics by the Indian poet Rudrata, where the syllables of a verse are laid out on half a board in the order of a knight's moves.
Knight's tour problems later appear in chess writings of the Islamic world, and in 1759 the mathematician Leonhard Euler studied the puzzle in depth, publishing ways to build closed tours and several symmetric ones. In 1823 Warnsdorff offered a rule simple enough to use by hand. Today the knight's tour is a standard example of a Hamiltonian path in graph theory, and in 1997 Brendan McKay counted 13,267,364,410,532 undirected closed tours on the 8×8 board.
How do I finish a tour?
- Clear corners and edges first. A corner has only two ways in and out, so it is easily stranded if you leave it for later.
- Go where the fewest moves remain. That is Warnsdorff's rule. When two squares tie, pick the one nearer the edge.
- Watch for squares flashing red. A square that no longer has any way in turns red. Unless it can be your very last square, the path is already lost, so rewind early.
- Undo freely. Besides the one move and five move buttons, tapping a visited square twice rewinds straight back to it.
- Start small. 6×6 works from any start and is great for practice, while 5×5 and 7×7 are trickier than they look because of their start limits.
Controls
- Phone and mouse: First tap a square with a green dot, or press Random start. Then tap a square with a green ring, or drag the knight onto it, and the knight leaps there in an arc.
- Undo: Undo goes back one square and Undo 5 goes back five. Tap a visited square once to see how many moves would be undone, and again to rewind to it. New start lets you choose the starting square again.
- Keyboard: Use the arrow keys to choose a square and Enter or Space to jump. Z or Backspace undo, X undo five, H hint, and R picks a random start while you are choosing one.
- Daily tour: Everyone gets the same board size and starting square for the day, and your time goes into the daily check in record when you finish.
Your game in progress, best time for each board and closed tour count are stored only in this browser and never sent to a server. Anyone who opens a link from Share result can try the same board size and starting square.