Hello guys. I'm trying to write a simple 2D strategy game. However it has some specific features to consider while programming collision avoidance system. And I'm a bit stuck choosing appropriate algorithms. I was thinking that Warcraft 3 style collision avoidance could work but I'm not sure what are they using there.
So here are some special features that need to be considered:
- The map is just flat and doesn't have static obstacles, so no pathfinding is required (or is it?)
- The map will normally have 2 armies consisting of up to 300 units in total.
- All units are controlled by AI (not the player). Which means that all 300 will normally have different goals (attacking or avoiding different enemy units)
- Most of the time the order of each unit will be either to attack (follow) or to flee from another moving unit (not just to go to a specific point). So coordinates of the unit's goal will change constantly, as well as it's speed vector.
My explanation might sound a bit blurry, but I will be glad to provide a better explanation if needed.
As for Warcraft 3, I found that the way units avoid each other there would perfectly suit my needs.
While trying to figure out what approach they use in Warcraft 3, I found many answers that refer to pathfinding (it is typically said that clearance based pathfinding HAA* is used) but none of those referring to collision avoidance.
While trying to figure out what do they use in Warcraft 3, I found that units that are not moving at the moment are treated as normal obstacles, so when calculating a path, the area where they stand is marked as impassable. (I thought so because when there were some units standing in a line and I sent a unit right behind them, the unit was not walking just straight into this formation and then trying to find the way around, but from first chose it's pass in a way that went around these units even if sent from far away).
But what about moving units?
My guess is that the path is recalculated each time a collision occurs with all the nearby units (in some range of collision interest) are treated as obstacles as well. But that sounds a bit naive..
Anyway, with the features my game has, such approach is not feasible.