flareteam / flare-engine

Free/Libre Action Roleplaying Engine (engine only)
http://flarerpg.org/
GNU General Public License v3.0
1.11k stars 187 forks source link

Pathfinding algorithm for many entities pursuing one target #471

Open clintbellanger opened 11 years ago

clintbellanger commented 11 years ago

When there are a lot of entities pathfinding towards the same target (as in our case with all enemies pursuing the hero), it may actually be better to calculate Djikstra's once radiating outward from the player and have all enemies follow that same calculation.

There's going to be some point in active enemy count where calculating Djikstra once is more efficient than calculating A* for each enemy. If any of you algorithm lovers out there want to experiment with this in a branch, I'd be curious to see some numbers.

I don't think we need to change our pathfinding algorithm, but I just read this somewhere and I thought I should mention it. Or if someone wants to turn Flare into some kind of swarm-survival action game (e.g. like Crimsonland or Gauntlet) they may want to consider this.

RyanDansie commented 11 years ago

if the summons are pulled, enemies will potentially have multiple targets and this probably becomes less efficient - unless its done conditionally, or as an engine setting in the case where summons are not used in a mod.

I think that the efficiency of the current pathfinding can be improved a lot (and without playing with the algorithm) by maintaining the pathfinding results, rather than recalculating them on each frame. In fact I also believe that this would result in more natural looking ai. I was planning to raise an issue about this soon with a proposed solution.