I am doing a job where I need to use a-star to solve a 15-puzzle (in C).
Heuristic function Manhattan distance (otherwise it is a taxi distance).
We are given an example of input / output, where the board is solved when moving 22 and after the expansion of nodes 395 (state of the board) (i.e. we had to look at children from 395 nodes)
By “correct” heuristic, I mean that my function is the same as that used to generate the sample output and gives the correct distance.
Problem my solution expands over 400 nodes to find a solution (this is an optimal 22 moves, but different).
I noticed that the number changes depending on the generation order of the child nodes (move space, up, left, down, right, or in the other direction).
There are 24 ways to move a piece of space up, down, left, and right to generate child elements, and I tried all of them, but none of them expanded 395 nodes.
Why is this happening?
Terminology:
- node: each node is a 15-voice card configuration
- children: configurations you can achieve by moving the tile space up, down, left, or right of the current node
PS: I use a binary heap for an open list, if that matters
thanks
Babak
source share