INSTRUCTIONS:
-
- Only one disk can be moved at a time.
-
- Each move consists of taking the upper disk from one of the stacks and placing it on top of another stack.
-
- No disk may be placed on top of a smaller disk.
LINKS:
- https://js-tower-of-hanoi.netlify.app/
- https://javascript-tower-of-hanoi.netlify.app/
- https://kjwilliamson.github.io/towerOfHanoi/
-
Provide a way to select a disc from the top of a tower
- click handler on each tower
tower.addEventListener("click", ___)
- "pick up" the topmost disc on the tower?? how do we pick up the topmost disc?
-
Provide a way to "drop" the disk on top of another tower, if the rules allow
-
click handler on each tower
-
see if the disc to drop is smaller than the topmost disc on the tower ?? how do we get the top disc? ?? how do we compare the widths of two discs??
disc1.dataset.width < disc3.dataset.width
-
if so, add the disc to the tower
tower.appendChild(disc)
-
-
check to see if the game is over--"winning condition"
- if all four discs are in the third tower, game over