justinhj/astar-algorithm-cpp

Allowing diagonal moves

JoePerkins opened this issue · 1 comments

Is there an example of how to allow diagonal moves?

No, but you need to modify the function: bool MapSearchNode::GetSuccessors( AStarSearch *astarsearch, MapSearchNode *parent_node )

You can see it investigates the four directions: up, down, left and right

By extending this you can check also diagonally up to the right (x + 1, y + 1) and so on.

Be aware that the distance to goal estimate will be affected by this change. However, I believe that the manhattan distance will still be admissible since it will not over-estimate the cost by ignoring diagonals.