The N-Puzzle Solver is a versatile C++ application designed to solve N x N sliding tile puzzles. It provides an array of heuristic methods and search algorithms, allowing users to tailor the solver's strategy. Puzzles can be loaded from files or generated randomly by the program itself.
- Automatic puzzle generation for quick testing.
- User choice of heuristic methods and search algorithms.
- Supports puzzles of varying dimensions (N x N).
- Real-time performance metrics and solution statistics.
- Pre-checks for puzzle solvability.
- C++17 or higher
- Make
-
Clone the Repository
git clone https://github.com/username/N-Puzzle.git
-
Navigate to the Directory
cd N-Puzzle
-
Compile the Program
make
-
Run the Program
./n-puzzle
Or to load a specific puzzle:
./n-puzzle example/puzzle3.txt
Just run the program without any arguments to generate a random puzzle.
Puzzles can be loaded from text files. The first line specifies the puzzle's dimension N
, followed by N * N
integers forming the puzzle board.
Example:
3
1 2 3
4 5 6
7 8 0
Upon running, the program will prompt you to choose from available heuristics and algorithms.
Advanced users can add their own heuristic methods and search algorithms by extending the relevant classes.
- Elapsed time
- Solution moves
- Complexity in time
- Complexity in size
This project is open-source and free to use, modify, or distribute for any purpose. However, it was developed primarily for educational purposes at 42 Paris School and is not considered production-ready. Use at your own risk.