0

i have a game use A*, this algorithm find path is good in many case.

But if I could not find the way to the destination, it would have to go through many nodes (my map is in gird format). I am looking for an algorithm to know that if I cannot find the way to the destination, A * algorithm will not work to avoid wasting CPU or then my object will only go straight to the target, when it collision with an object, it will stop. I saw a game like Age of Empires, when the farmer was locked in between the 4 walls, which meant he couldn't go out. If I want him to go to a point outside those four walls, he just goes straight to that point and stops when he hits a wall. If the 4 walls have a hole, he will go there and get there![enter image description here]1 [enter image description here]2

Thanks everyone !

Traistorm
  • 39
  • 6
  • 1
    https://gamedev.stackexchange.com/questions/47042/how-to-determine-that-nodes-in-grid-graph-are-unreachable-before-applying-pathfi/47043 Take your starting map. Pick a node. Fill out from this node. All filled nodes are reachable from this first node (and vice versa, assuming you can't jump down ledges and things like that). Pick a new node not in the set of reachable nodes you just found. Repeat. At the end you have M buckets, each with the set of co-reachable nodes. Update this whenever the map updates. – JohnFilleau Feb 28 '20 at 19:22
  • 1
    In order to find that closest point inside the reachable space, it's still running an A* query within that reachable space. You just accept the node with the best heuristic result you've seen if you've exhausted the reachable nodes to check. – DMGregory Feb 29 '20 at 13:14
  • Oh, thanks DMGregory, i think it is good idea ! – Traistorm Mar 03 '20 at 11:28

0 Answers0