Tower of Hanoi solver

CSC.T272 Artificial Intelligence

Mikihito Matsuura

Game specification

  • There are 3 piles.
  • At first, 3 disks with different sizes are put in the first pile.
  • You can move only one disk at a time.
  • You can move a disk on the top of piles to the top of other piles.
  • You cannot put a larger disk on a smaller disk.
  • Can you move all disks into the third pile?

Solver configuration

Higher number may result in hanging up.

Optimal solution

Computed with BFS + Dynamic Programming

Moves

7 moves

Time to search

0.20 ms

Steps to search

27 steps
1
2
3
Pile number 1
1
2
3
Pile number 2
1
2
3
Pile number 3

ASearch Demo

Computed with ASearch with h2

Moves

7 moves

Time to search

0.90 ms

Steps to search

107 steps
1
2
3
Pile number 1
1
2
3
Pile number 2
1
2
3
Pile number 3

A*Search Demo

Computed with ASearch with h'(x)=0

Moves

7 moves

Time to search

1.70 ms

Steps to search

1489 steps
1
2
3
Pile number 1
1
2
3
Pile number 2
1
2
3
Pile number 3