I'm back on the job and I have a few questions.

@Damocles: I understand what you're saying. A floodfill approach would work well in theory, but in my thinking I discovered a few problems with it that you could perhaps shed some light on.

1. Since I'm building an RTS, each unit needs to conduct itself independently and simultaneously of all the other units on the battlefield. However, this would require all of the units to have its own pathfinding graph, otherwise ordering one unit to move somewhere will cause all of the units on the field to move to that destination. But wouldn't this solution cause memory problems with big levels and lots of units?

2. Suppose I order a unit to attack another unit. The unit I ordered should intelligently follow the unit it is attacking until its victim is dead. But wouldn't this require me to constantly recalculate my pathfinding graph so that the unit can avoid obstacles intelligently?

EDIT: I've further contemplated these problems and come up with some other solutions. I would be happy if you could tell me whether they are worth my time, of tell me of something better.

1. To avoid the memory problems, I could keep a "queue" of orders in a linked list. When a player orders a unit, to say, move to a certain location, it adds this order to the "queue" and assigns a pointer to the unit ordered that points to his order on the queue. When the unit(s) have finished executing the order, the order is removed from the queue. This method will allow multiple units to share the same pathfinding information, while simultaneously making sure that only the units that are moving are provided graphs. I believe this would effectively defeat the memory problems, but do you think it would work?

2. I know no real solution for this problem, but I figure I can help defeat part of the problem by only recalculating the unit's graph every few seconds. He won't be moving fast anyway, and I doubt the enemy unit will be either... But in my mind, such a solution seems like it would be prone to failure. What do you think?

Last edited by Redeemer; 12/30/10 14:44. Reason: Clarification and further questioning

Eats commas for breakfast.

Play Barony: Cursed Edition!