PHP Classes

How to Solve the Tower of Hanoi Puzzle Online Using the Package Tower of Hanoi: Implement the Tower of Hanoi game on the Web

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2024-10-22 (23 hours ago) RSS 2.0 feedNot enough user ratingsTotal: 2 This week: 2All time: 11,465 This week: 23Up
Version License PHP version Categories
tower_of_hanoi 1.0The PHP License7Games, Web services, PHP 7
Description 

Author

This package can implement the Tower of Hanoi game on the Web.

It implements an application that displays the Tower of Hanoi game screen on a Web page.

The package also implements an API that can take requests to process the play moves to update the game screen page.

Picture of Edward Paul
  Performance   Level  
Innovation award
Innovation award
Nominee: 11x

Winner: 1x

Example

<?php

use Illuminate\Http\Request;

define('LARAVEL_START', microtime(true));

// Determine if the application is in maintenance mode...
if (file_exists($maintenance = __DIR__.'/../storage/framework/maintenance.php')) {
    require
$maintenance;
}

// Register the Composer autoloader...
require __DIR__.'/../vendor/autoload.php';

// Bootstrap Laravel and handle the request...
(require_once __DIR__.'/../bootstrap/app.php')
    ->
handleRequest(Request::capture());


Details

<h1 align="center">Tower of Hanoi</h1> <p align="center"> A simple pyramid puzzle</p>

<p>&nbsp;</p>

Download Instruction

> Application Requirements * PHP >= 8.2 * A web server like Apache or Nginx * Composer for dependency management.

  1. Clone the project.
git clone https://github.com/infinitypaul/tower_of_hanoi.git projectname

  1. Install dependencies via composer.
composer install 

  1. Run php server.
php artisan serve

<p>&nbsp;</p>

Enjoy!

Api Usage

Notes: - http://localhost:8000/ is your base URL. Replace it with your server's base URL if necessary. - No persistence is needed across requests. The game resets if the server restarts.

GET http://localhost:8000/api/state

Description: Retrieves the current state of the Tower of Hanoi game, including the positions of the disks on the rods and whether the game is over.

POST http://localhost:8000/api/move/{from}/{to}

Description: Moves a disk from one rod (from) to another rod (to).

Where: * {from}: The rod from which you want to move a disk (1-based index). * {to}: The rod to which you want to move the disk (1-based index).

Testing

php artisan test

You should see the results of the tests, ensuring that the application works as expected.

Static Analysis

This project uses PHPStan for static code analysis to ensure code quality and prevent errors

vendor/bin/phpstan analyse

License

The Tower of Hanoi is open-sourced software licensed under the MIT license


  Files folder image Files (51)  
File Role Description
Files folder imageapp (4 directories)
Files folder imagebootstrap (2 files)
Files folder imageconfig (11 files)
Files folder imagedatabase (3 directories)
Files folder imagepublic (3 files)
Files folder imageresources (3 directories)
Files folder imageroutes (3 files)
Files folder imagetests (1 file, 2 directories)
Accessible without login Plain text file .editorconfig Data Auxiliary data
Accessible without login Plain text file .env.example Data Auxiliary data
Accessible without login Plain text file artisan Example Example script
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file composer.lock Data Auxiliary data
Accessible without login Plain text file package.json Data Auxiliary data
Accessible without login Plain text file phpstan.neon Data Auxiliary data
Accessible without login Plain text file phpunit.xml Data Auxiliary data
Accessible without login Plain text file postcss.config.js Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation
Accessible without login Plain text file tailwind.config.js Data Auxiliary data
Accessible without login Plain text file vite.config.js Data Auxiliary data

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:2
This week:2
All time:11,465
This week:23Up