I'm doing an assignment where I have to use a-star to solve a 15-puzzle (in C).
The heuristic function is the Manhattan distance (aka taxicab distance).
We are given a sample input/output where the board is solved in 22 moves and after expanding 395nodes (board states) (i.e we had to look at the children of 395 nodes)
By 'correct' heuristic I mean my function is the same as the one used to produce the sample outputs and produces the correct distance.
The problem is my solution expands more than 400 nodes to find the solution (it is optimal 22 moves but a different one).
I noticed the number changes depending on the order I generate the children nodes (move the space tile up, left, down, right or other directions).
There are 24 ways you can move the space tile up, down, left and right to generate the children and I tried all of them but none of them expanded 395 nodes.
Why is this happening?
node: each node is a configuration of the 15-puzzle board
children: the configurations that you can achieve by moving the space tile up, down, left or right from the current node
PS: I'm using a binary heap for the open list if that matters