Taroimo Science Lab日本語

All simulationsMenu

← All simulations

Search Algorithms with the 8-Puzzle

Exaggerated displayPlay

Watch a computer solve the 8-puzzle by searching, examining one board at a time. Compare breadth-first search and A* on the same board and see, in numbers, how a better estimate, called a heuristic, means fewer boards to examine.

  • Press "Start search" to run the chosen method one node at a time. Set the speed with the slider; pause and step with the toolbar above.
  • Press "Expand one" to expand a single node, or "Solve at once" to finish the search. When a solution is found, its moves are shown one by one.
  • Tap a tile to slide it toward the blank. Tiles in the same row or column as the blank slide together. Solve it yourself and compare your moves with the shortest solution.
  • "Scramble" makes a board that is always solvable; "Shuffle tiles" makes one that may not be. "Swap two tiles" swaps just two tiles of the current board, which flips whether it can be solved. The inversion count and whether the board is solvable appear under the board.
  • Press "Compare five methods" to solve the same board with BFS, two kinds of A*, greedy search and A* without a closed set, and line up the nodes expanded, solution length, comparisons and computing time.