AStar icon indicating copy to clipboard operation
AStar copied to clipboard

(Maybe?) Some issues with the search

Open unlut opened this issue 2 years ago • 1 comments

Hello, I don't know if you are still working on this. I was looking for A* implementations for comparison and after reading your code I think it has a few slight issues (or they might be my misunderstanding of c#).

1- You are always increasing g value by 1, however it should be sqrt(2) for diagonal moves. 2- If any of the cardinal moves are blocked, you are preventing all diagonal moves. Moving in SW direction should not be affected by whether east is blocked or not, only south and west 3- At this part you are checking if you reached a node that is in already open set with a lower f value:

else if (g + neighbour.H < neighbour.F) {

                        neighbour.G = g;
                        neighbour.F = neighbour.G + neighbour.H;
                        neighbour.Parent = node;

But you are not repushing the node to the queue or updating priority of the node in the queue via UpdatePriority. Lowering f value of a node may cause it to expand earlier than some other nodes. Although I can not think of a situation where would this be a problem in uniform-cost grids, it seems incomplete when you look at it.

unlut avatar Sep 11 '21 12:09 unlut