An open API service indexing awesome lists of open source software.

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

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 ```