NetLogo User Community Models
WHAT IS IT?
The Tower of Hanoi or Towers of Hanoi is a mathematical game or puzzle. It consists of three poles, and a number of disks of different sizes which can slide onto any poles. The puzzle starts with the disks in a stack in ascending order of size on pole A, the smallest at the top, thus making a conical shape.
The objective of the puzzle is to move the entire stack to another pole according to the following rules:
1. Only one disk may be moved at a time.
HOW IT WORKS
In this program, set of turtles are used to represent a disk which are stored in a list. Once the disk number is called, the assiged set of turtles of that particular disk will be moved from one location to another. And to prevent overlapping of disks, a function will check if there are turtles on the desired region.
HOW TO USE IT
-Select the desired disk design in the drop-down box
-Click START button to load background and poles
THINGS TO NOTICE
Notice the turtles in each disks, these turtles will all move to the destination postion. Each of the turtles will move to their assigned locations in A, B and C.
Notice that all turtles in a disk have the same color, this is because color property of the leftmost turtle is copied.
THINGS TO TRY
Try to adjust disk size, the number of steps will also change, thus the amount of time to perform the animation will also increase.
EXTENDING THE MODEL
In the current implementation, all disks will move directly to the destination postion. Try enhancing the animation such that all disks must move up from the current pole, then left (or right) and then move down to the desired location. In this way, it will be more realistic.
Note the use of hatch and the positioning of turtles. These are used to create increasing disks.
CREDITS AND REFERENCES
This model was created by Shayryl Mae Ramos. For concerns, email at email@example.com
To refer to this model in publications, please use:
Tower of Hanoi. Ramos, S. L. (2010).
(back to the NetLogo User Community Models)