Search code examples
algorithmsearcha-starsliding-tile-puzzle

Precalculate Result of A*


Currently learning about the A* search algorithm and using it to find the quickest solution to the N-Puzzle. For some random seed of the initial starting state, the puzzle may be unsolvable which would result in extremely long wait times until the algorithm has search the entire search-space and determined there is not solution to the give start state.

I was wondering if there is a method of precalculating whether the A* algorithm will fail to avoid such a scenario. I've read a bit about how it is possible but can't find a direct answer as to a method in which to do it.

Any guidance or options are appreciated.


Solution

  • I think A* does not offer you a mechanism to know whether or not a problem is solvable. Specifically for N-Puzzle, I think this could help you to check if it can be solved or not:

    http://www.geeksforgeeks.org/check-instance-8-puzzle-solvable/

    It seems that if you are in a state where you have an odd amount inversion, you know for sure the problem for that permutation is infeasible.