Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/awoimbee-42/n-puzzle
clone of https://github.com/igorgarbuz/n-puzzle
https://github.com/awoimbee-42/n-puzzle
Last synced: 4 days ago
JSON representation
clone of https://github.com/igorgarbuz/n-puzzle
- Host: GitHub
- URL: https://github.com/awoimbee-42/n-puzzle
- Owner: awoimbee-42
- License: mit
- Created: 2020-09-21T12:43:22.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2020-09-23T11:02:22.000Z (about 4 years ago)
- Last Synced: 2024-08-01T20:51:52.084Z (3 months ago)
- Language: TypeScript
- Size: 107 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# n-puzzle
Welcome to the n-puzzle playground!
Current is an implementation of [15 puzzle](https://en.wikipedia.org/wiki/15_puzzle) game with an algorithmic solver and complexity analysis.
We built it because of a deep interest in pathfinding algorithms and its applications. TypeScript was choosen for this project due of its versatility (e.g. data structures) and the execution speed, but mostly because we wanted to bring the visualization at people's fingertips.> Play around < — UI fits for both mobile and desktop. Start with a guided tour by clicking the red help button on the top.
## Description of used algorithms:
|Algorithm|Cost_function|Description|
|---------|:-------------:|-----------|
|A* (A-star)|g(x) + h(x)|A* is a popular algorithm for finding the shortest path in a graph. A* is an informed version of Dijkstra's algorithm as it uses an additional heuristic. At each step it takes the best shortest path based on the cost function `f(x) = g(x) + h(x)`, where `x` is the graph distance metric, `g(x)` is the exact traveled distance and `h(x)` is the remaining distance estimated by the heuristic function. A* guarantees the shortest path if an admissible heuristic is used.|
|Best-1st|h(x)|Best-1st is the greedy version of A*: it selects the next node to explore based exclusively on the heuristic's estimation of remaining path. Unlike A*, Best-1st doesn't guarantee the shortest path, but it converges much faster. |## Description of used heuristics:
|Heuristic|Admissibility|Description|
|---------|:-----------:|-----------|
|Hamming|Yes|Simple heuristic that represents the number of misplaced tiles.|
|Euclidean|Yes|Estimates distances between current and solved board states if tiles were moved in straight lines.|
|Manhattan|Yes|Estimates distances between current and solved board states according to taxicab geometry (a.k.a L1 norm).|
|Linear conflict|No|Based on manhattan distance, with an additional amendment on tiles that are in the same line or column and must be moved behind each other. It's described in the original article.|
|Permutation number|No|Primitive heuristic computes the number of tiles out of increasing order. It skips tiles that are both ordered and misplaced.|
## How to use locally
```bash
# Clone the repository
git clone https://github.com/awoimbee-42/n-puzzle
cd n-puzzle# To launch it locally you need to either node.js or docker
# A) You have node.js
make setup
make build# B) You have docker running
make docker
make setup
make build# Run the cli for command-line interface
./solver-cli# Use the web UI at http://127.0.0.1:8080/
make serve
```