https://github.com/ollevche/n-puzzle
:1234: N-Puzzle solver built up on A* (with modifications), Greedy and Uniform Cost search algorithms. Available Heuristics are one of Manhattan, Hamming and Euclidean
https://github.com/ollevche/n-puzzle
astar astar-algorithm euclidian greedy hamming heuristics manhattan npuzzle-solver uniform-cost-search
Last synced: about 1 year ago
JSON representation
:1234: N-Puzzle solver built up on A* (with modifications), Greedy and Uniform Cost search algorithms. Available Heuristics are one of Manhattan, Hamming and Euclidean
- Host: GitHub
- URL: https://github.com/ollevche/n-puzzle
- Owner: ollevche
- Created: 2019-10-12T18:42:15.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2021-01-31T21:12:37.000Z (over 5 years ago)
- Last Synced: 2025-02-08T22:12:06.016Z (over 1 year ago)
- Topics: astar, astar-algorithm, euclidian, greedy, hamming, heuristics, manhattan, npuzzle-solver, uniform-cost-search
- Language: Java
- Homepage:
- Size: 1.47 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# :1234: N-puzzle
Solver of an N-Puzzle that uses a modified version of A*, Greedy and Uniform Cost search algorithms.
You can choose between Manhattan, Hamming or Euclidean admissable heuristics.
## How to use
Run using the gradle wrapper
```./gradlew run```
This will build the app; generate a random 3x3 puzzle (8-puzzle) and solve it using A* and Manhattan heuristic.
Program args can be modified in the build.gradle:
* -a \ - one of the three algorithms
* -h \ - required for astar and greedy; forbidden for uniform
* -r \ - optional; will genereate a N*N solvable puzzle
* -f \ - optional; will read the input from file
* | - optional; repeatable; gives the possibility to enter args again; will run another solver in a separate thread;
* so ```['-a astar -h manhattan -r 3 | -a astar -h euclidean -r 4']``` will solve two puzzles in parallel
#### If no argument for the input source is provided, you will be promted to manually enter input in the following format:
```
3
1 2 3
4 5 6
7 8 0
```
#### Some puzzles may be unsolvable. The solution is in snail format:
```
1 2 3
8 0 4
7 6 5
```
## How to test
You can run all the tests using ``` ./gradlew test ``` or individual tests using ```./gradlew test --tests ```