1. Go to this page and download the library: Download stratadox/puzzle-solver library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
stratadox / puzzle-solver example snippets
use Stratadox\PuzzleSolver\Find;
use Stratadox\PuzzleSolver\Puzzle\NQueens\NQueensPuzzle;
use Stratadox\PuzzleSolver\UniversalSolver;
$solver = UniversalSolver::forAPuzzle()
->withGoalTo(Find::allBestSolutions())
->whereMovesEventuallyRunOut()
->select();
$solutions = $solver->solve(NQueensPuzzle::forQueens(5));
assert(count($solutions) === 10);
use Stratadox\PuzzleSolver\Find;
use Stratadox\PuzzleSolver\Puzzle\SlidingPuzzle\LevenshteinHeuristic;
use Stratadox\PuzzleSolver\Puzzle\SlidingPuzzle\SlidingPuzzle;
use Stratadox\PuzzleSolver\UniversalSolver;
$solver = UniversalSolver::aimingTo(Find::aBestSolution())
->withHeuristic(new LevenshteinHeuristic())
->select();
$puzzle = SlidingPuzzle::withPieces(
[2, 4, 1],
[8, 5, 7],
[3, 0, 6]
);
$solution = $solver->solve($puzzle)[0];
assert(count($solution->moves()) === 25);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.