Unique penalties for each agent

Hi! I’m using the pathfinding project in a game where each enemy maintains its own idea of where the player is, based on where they were last seen. They should then do pathfinding avoiding direct line-of-sight to the player (or the position where they assume the player is) to avoid getting shot. I’m doing this by adding a penalty to those nodes. Could you give me pointers on how to go about making the penalties agent-specific? I could create a unique map instance per agent, but that seems wasteful. Perhaps a better way would be to override a penalty-calculation method to use an agent-specific value per node? Can I keep using Seeker or does that need to be overridden as well?

While the above is my primary concern, I’m also wondering if it’s possible to do a similar thing with agent-specific representation of the map traversability. The scenario is where the player busts through a wall, and enemies shouldn’t use the new path until they see the broken wall and become aware of the new route. Could this maybe be done by making all nodes traversable at all times, but assigning an infinite penalty to nodes the agent thinks are blocked? Would there be a performance implication?

Thanks for the great project!

Hi

Take a look at the ITraversalProvider.
There’s an example of it at the bottom of this page: https://arongranberg.com/astar/docs/turnbased.html#ITraversalProvider

Note that you cannot make existing unwalkable nodes walkable using it, but you can make existing walkable nodes unwalkable.

That works, thank you!

1 Like