Download the PHP package stratadox/puzzle-solver without Composer

On this page you can find all versions of the php package stratadox/puzzle-solver. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?
stratadox/puzzle-solver
Rate from 1 - 5
Rated 5.00 based on 1 reviews

Informations about the package puzzle-solver

Puzzle Solver

Github Action codecov Scrutinizer Code Quality Maintainability Latest Stable Version License

A generic puzzle solving package, capable of solving a wide variety of puzzles.

Examples

Some examples of puzzles it can solve:

Motivation

People kept asking me to implement a solver for this puzzle or that puzzle. This time, instead of just solving one puzzle, I figured I'd make a universal puzzle solver that would simply solve all of those puzzles and all puzzles to come, in one swift strike. Plus, this way, the algorithms can be re-used for different purposes, such as AI for video games or a solver for some real-life problem. Who knows what the future brings!

Basic usage

There are two "ways" to use this package: the Universal Solver, an informed "swiss army knife" approach, or the Brute Solver... what's in a name.

Universal Solver

The Universal Solver is like a swiss army knife for puzzle solvers.

Feed it with some information on what you're looking for, and receive a solver for your puzzle. All the puzzles that are implemented as examples, as well as many puzzles that don't have an example implementation, can be given efficient solvers using this approach.

5-queens problem with universal solver

Solving a 5-queens problem:

Sliding puzzle with universal solver

Solving a sliding puzzle:

Brute Solver

On the to-do list.

Available Algorithms

Rather than providing a set number of algorithms, this package provides a composable algorithm.

The solver itself can be of one of two flavours, with one of three basic search strategies which in turn can be refined with a number of decorators.

Flavours

The basic solver comes in two flavours: eager or lazy.

Eager

Eager puzzle solvers will search for the first valid solution. Eager solvers will stop after finding a single solution, making them neat for puzzles that can have only one possible solution, or require only a single solution.

Lazy

Lazy puzzle solvers will continue to look for solutions until they've found all valid solutions. Lazy solvers can be used for puzzles that require more than one solution.

Search Strategies

There are three main search strategies available: depth-first, breadth-first and best-first.

Depth-first

Depth-first searches continuously follow the first option, until it turns out the branch does not lead to a solution, at which point it tracks back to the first next available option.

Breadth-first

Breadth-first searches continuously explore all available options, before passing into the options available after those.

Best-first

Best-first searches enqueue newly encountered nodes by order of quality. The move that is most likely to lead to the desired outcome is considered first. In order to determine the quality of a move, the best-first strategy can be provisioned with a heuristic.

Decorators

In order to optimise the search, and/or to not get stuck in eternal loops, a search strategy will typically be wrapped in at least one decorator.

Visited Node Skipper

Visited Node Skipper keeps a list of puzzle states that have already been encountered during the search to skip candidates when they are about to be considered for a second time.

Visited Node Cost Checker

Visited Node Cost Checker keeps a record of the cost of reaching each considered candidate. When a candidate is encountered that already has a recorded cost, the cost of the newly discovered path to reach the same state as before is compared with the previously recorded cost. If the cost is lower than before, the record gets updated and the new candidate is considered. In case the cost is equal or higher than previous paths to the same goal, the candidate is discarded.

Worse-Than-Best Solution Skipper

The Worse-Than-Best Solution Skipper keeps track of the lowest cost of the solutions that have been found during the search. Each time a node is encountered of which the path cost is more than the cost of the cheapest solution that has already been found, the node is skipped.

Duplicate Node Skipper

Duplicate Node Skipper prevents paths from getting into loops. Before considering a new candidate, all previous puzzle states are compared with the new state. If the new puzzle state was already reached on this very path, the candidate is considered a loop and gets rejected.

Iteration Limiter

Iteration Limiter aborts the search when the amount of considered candidates exceeds a set limit.

Debug Logger

Debug Logger is a visualiser for the puzzle solver. Each time a new candidate is taken under consideration, the debug logger logs it to the output stream.

To-do


All versions of puzzle-solver with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2
stratadox/immutable-collection Version ^1.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package stratadox/puzzle-solver contains the following files

Loading the files please wait ....