8 Puzzle
The 8 Puzzle is the smaller sibling of the 15 Puzzle, played on a 3x3 grid with tiles numbered 1 through 8 and one empty space.
About 8 Puzzle
The 8 Puzzle is the smaller sibling of the 15 Puzzle, played on a 3x3 grid with tiles numbered 1 through 8 and one empty space. The objective is to slide tiles into the empty space to arrange them in numerical order. Despite its compact size, the 8 Puzzle offers a satisfying challenge, and it holds a special place in computer science as one of the most studied problems in artificial intelligence search algorithms.
How to play 8 Puzzle
Rules
- The board is a 3x3 grid with tiles numbered 1-8 and one empty space.
- Slide any tile adjacent to the empty space into the empty space.
- Only one tile moves at a time, horizontally or vertically.
- Arrange tiles in order: 1-3 in the top row, 4-6 in the middle row, 7-8 and the empty space in the bottom row (empty at bottom-right).
Strategies
- Top Row First: Place tiles 1, 2, and 3 in the top row. Once locked in, they should not need to move again.
- Left Column Next: Place tiles 4 and 7 in the left column (if not already done while solving the top row).
- Finish the Corner: The remaining tiles (5, 6, 8) and the empty space form a small 2x2 area that can be solved by cycling tiles around.
- Cycle Move: When the last few tiles need rearranging, rotate them around the empty space in a cycle until they reach the correct positions.
- Solvability Check: Exactly half of all possible configurations are solvable. Count the number of inversions (tiles that appear before their natural predecessor). If the count is even, the puzzle is solvable; if odd, it is not.
- Manhattan Distance: For each tile, calculate how many moves it is from its goal position (horizontally + vertically). The sum gives a lower bound on the number of moves needed. Use this to gauge how close you are to solving.
History of 8 Puzzle
The 8 Puzzle is a direct descendant of the 15 Puzzle, scaled down from a 4x4 to a 3x3 grid. While the 15 Puzzle dominated popular attention from 1880 onward, the smaller 8 Puzzle became the focus of academic study, particularly in the field of artificial intelligence.
In the 1960s and 1970s, AI researchers adopted the 8 Puzzle as a standard benchmark for testing search algorithms. Its state space is small enough to be fully explored (181,440 reachable states out of 362,880 possible permutations), yet complex enough to test the efficiency of different approaches. The puzzle was used to demonstrate and compare breadth-first search, depth-first search, iterative deepening, and the famous A* algorithm developed by Peter Hart, Nils Nilsson, and Bertram Raphael in 1968.
The A* algorithm, when combined with the Manhattan distance heuristic, can solve any solvable 8 Puzzle configuration optimally — finding the minimum number of moves. The maximum number of moves needed to solve any solvable configuration is 31, and the average is about 22 moves. These results were established through exhaustive computer searches.
The 8 Puzzle remains a staple of introductory AI and algorithms courses at universities worldwide. Students implement search algorithms using the puzzle to understand concepts like heuristics, optimal paths, and state-space exploration. It serves as a gateway to understanding more complex problems in planning, robotics, and optimization. Beyond academia, the 8 Puzzle is a popular casual puzzle found in toy stores, mobile apps, and as a mini-game within larger video games.