0
\$\begingroup\$

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?

\$\endgroup\$
4
  • \$\begingroup\$ I don't understand the question. "Can pathfinding be used for <list of extremely vague things>?" Sure, I suppose, under the right conditions. \$\endgroup\$ Commented Jul 22, 2018 at 20:02
  • 4
    \$\begingroup\$ 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. \$\endgroup\$
    – DMGregory
    Commented Jul 22, 2018 at 20:58
  • \$\begingroup\$ 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... \$\endgroup\$
    – ErnieDingo
    Commented Jul 22, 2018 at 22:16
  • \$\begingroup\$ Possible duplicate of Pathfinding for fleeing \$\endgroup\$
    – Philipp
    Commented Jul 23, 2018 at 19:38

1 Answer 1

1
\$\begingroup\$

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.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .