Skip to content

codegym-vn/game_tower_hanoi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tower of Hanoi

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.

Features

  • 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.

Getting Started

Prerequisites

To run this project, you need a web browser that supports HTML5 and JavaScript.

Installation

  1. Clone this repository to your local machine.
  2. Open the index.html file in your web browser.

Usage

  • 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.

Game Rules

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:

  1. Only one disk can be moved at a time.
  2. Each move consists of taking the upper disk from one of the stacks and placing it on top of another stack.
  3. No disk may be placed on top of a smaller disk.

Files

  • 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.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License.

Acknowledgments

Inspired by the classic Tower of Hanoi puzzle.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published