I'm doing an assignment where I have to use a-star to solve a 15-puzzle (in C).
The heuristic function is Manhattan distance (aka taxicab distance).
We are given a sample input/output where the board is solved in 22 moves and after expanding 395 nodes (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?
Terminology:
PS: I'm using a binary heap for the open list if that matters
Thanks
Mmmh... In ideal case the A* does not depend on the order you generate the children. Unfortunately if you have in "queue" two or more nodes with the same distance-plus-cost heuristic value, the algorithm may chose "randomly" one of these nodes and find different solution (and explore different search path).
I think that you can try:
This is the only thing that I can tell you with this information. :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With