A* is typically used to calculate the best way to move towards something, and it's quite flexible when it comes to threats, extra movement costs, and 'refuelling' on the way to something.

However, if you designate only threats, perhaps with a main threat first and foremost, can you use it for "finding somewhere to go"? What about adding both threats, safety, resources and other such heuristic influencers to determine what a unit does when idle?

  • I don't understand the question. "Can pathfinding be used for <list of extremely vague things>?" Sure, I suppose, under the right conditions. – BlueRaja - Danny Pflughoeft Jul 22 at 20:02
  • 4
    A* is not a way to make a unit move. It's a way to plan a sequence of actions to reach a goal. If you want your unit to move "non-specifically" ie. not following a planned route to a goal, then A* might not be the right tool for the job. Try describing an example scenario that shows the kind of behaviour you want, and we can suggest methods to achieve it. – DMGregory Jul 22 at 20:58
  • I think from what you are describing is an "Itinerary". A* will help you plan the route and some items along the route may directly affect the route you take. You really need to split this in to 2 buckets, places you must visit (Itinerary) and hazards that you must avoid (your route planning). If you order your Itinerary in some sort of priority order than that is simplest, if you try to also optimise this then you enter the world of the travelling salesmen problem and you will be lost for years in there... – ErnieDingo Jul 22 at 22:16
  • Possible duplicate of Pathfinding for fleeing – Philipp Jul 23 at 19:38

Sort of.

"Finding somewhere to go" is not, on the surface, what A* is about. A* is about finding how to get there, once you know where you want to go; A* is just an algorithm for finding a traversal of some graph.

While it is widely used in games to find a traversal of a graph that represents navigable space (such as a grid), it can be used to find such traversals of graphs representing whatever you want, as long as you can express the concept as a graph with associated costs.

It's certainly possible to represent the decision space of an AI as a graph and use A* to find paths through that graph. How you'd make that usefully work in a video game is not immediately clear and might require some experimentation.

For example if you construct a graph representing primary driving goals of an AI (flight aggressively, fight defensively, flee outright) arranged as spokes with interim nodes representing tailored, blended behavior options, you might be able to use A* to find a path between two nodes that represents how the AI will change it's overall bearing over time. I'm not sure this is a practical approach (you could accomplish a very similar thing in a much simpler fashion), but it's something you could technically make work.

It's easier to see how it could work with a more concrete and defined scenario; for a more concrete example of path-finding in "decision space," take a look at this question and the answer by DMGregory.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.