This is a JavaScript implementation of the classic Tower of Hanoi puzzle game. The game allows players to interact with the towers and disks using mouse drag-and-drop functionality. It also includes buttons to solve the puzzle automatically and to restart the game.
- Interactive Drag-and-Drop: Players can drag and drop disks between towers.
- Automatic Solver: A button to automatically solve the puzzle.
- Restart Button: Restart the game at any time.
- Win Check: Alerts the player when they have successfully solved the puzzle.
To run this project, you need a web browser that supports HTML5 and JavaScript.
- Clone this repository to your local machine.
- Open the
index.html
file in your web browser.
- Drag and Drop: Click and hold a disk to drag it to another tower. Release the mouse button to drop the disk.
- Solve Button: Click the "Solve" button to see the automatic solution of the puzzle.
- Restart Button: Click the "Restart" button to reset the game.
The Tower of Hanoi is a mathematical puzzle consisting of three towers and a number of disks of different sizes. The objective is to move all the disks from the first tower to the third tower under the following constraints:
- 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.
index.html
: The main HTML file that sets up the canvas and buttons.style.css
: The CSS file for styling the game interface.my.js
: The JavaScript file containing the game logic.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License.
Inspired by the classic Tower of Hanoi puzzle.