Tuesday, November 20, 2018

path finding - Tweaking AStar to find closest location to unreachable destination



I've implemented AStar in Java and it works ok for an area with obstacles where the chosen destination is reachable.


However, when the destination is unreachable, the calculated "path" is in no way to the closest location (to the unreachable location) but is instead some random path.


Is there a feasible way to tweak AStar into finding the path to the closest location to an unreachable destination?



Answer



Keep track of the node with the lowest EstimatedDistanceToEnd (ie. the lowest h(x)), and if no end-node is reachable to backtrack from, backtrack from that node instead.


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...