This is a project from 42 whose aim is to solve an n-puzzle.
You compile it with make
then you run ./solver
.
In n-puzzle.conf you can choose between several options.
badPlacedTiles
manhattanDistance
manhattanDistance+linearConflict
- See here for more information.
uniformCost
: uses the heuristic added to the number of moves made so far (depth).greedy
: uses only the heuristic.
- keeping it below 1,000,000 is a good idea.
- The greater the weight, the more important the heuristic will be with respect to depth. Only useful with
uniformCost
.
./file.location
: with the size of the puzzle first, then each line separated by a new line and each column by a space. Example:3 4 3 2 1 8 6 5 0 7
random:size
: a random position (the existence of a solution is not guaranteed).suffle:size
: a position obtained by mixing the ending position (solution guaranteed)
snail
std
random
My program can solve up to a size 6 puzzle easily. Beyond that, you'll need to increase the maximum number of iterations, which may cause performance problems on your computer. If you don't have enough RAM, my program will probably crash.