Skip to content

Latest commit

 

History

History
51 lines (36 loc) · 1.43 KB

README.md

File metadata and controls

51 lines (36 loc) · 1.43 KB

N Puzzle

An implementation of A* algorithm to solve the N Puzzle problem. N Puzzle is a generalization of the famous 15 Puzzle problem. Both Python and C++ implementations are provided.

Please note that the puzzle is solved when a "snail" state is achieved, which is different from the goal state in the original statement of the problem. Here are examples

You can choose one of the following admissible heuristic functions (in order of increasing efficiency)

  1. Hamming
  2. Euclidian
  3. Manhattan
  4. Manhattan with linear conflicts

In addition, the Python implementation can accept multiple search modes:

  1. A* (optimal)
  2. greedy (fast when N is large)
  3. uniform

Executing

To generate puzzles,

python3 npuzzle_gen.py --help

To run Python version,

python3 -m pip install -r requirements.txt
python3 solver.py --help
python3 solver.py < "your-puzzle-file"

To run C++ version,

make
./solver --help
./solver < "your-puzzle-file"

References