Here is the 4th part of my Win That War’s IA series. Today, I’ll write about flocking behavior.

Let’s start with a video. A tanks army is riding through a canyon. If you give a look to the left side of the video you can see that the units are lining up, which put them at the mercy of an ambush. It also takes a while before they finally cross the mountain. Now, the right side of the video. As you can see, the units take the canyon’s entire width, and quickly arrive to the other side.

This noticeable improvement is simply due to the use of a flocking algorithm.

Because of my early affection for the flowfield technique, which is notably used in Planetary Annihilation and Supreme Commander 2, until now I neglected this type of algorithm.  Actually, a well settled flowfield allows to go without using flocking: the units have a natural behavior, then the congestion and collision issues are efficiently solved.

But here is the thing: I figured that using the  flowfield generates two problems. First one is that it’s hard to optimize, and that Win That War! maps vastness involves a huge memory consumption. The second one is that the paths computed by the flowfield solver are approximative, and it’s a real issue when a robot has to go through a dense base, slaloming between hard-to-cross buildings.

So… I just threw  everything to get back to a more simple but efficient “Weighted A*” algorithm. IA code just got more “thin”, and the performances got better. But, you know, nothing is that easy, and with that kind of algorithm, we fall right back into congestion issues. That may be why you had a bad time crossing mountains with a big army in the Alpha 0.2 version.


That’s why I decided to add a flocking stage.

Your fingers are getting itchy and you want to try this by yourself? You’ll find a nice introducing method here.

In the end, the choice of a pathfinding algorithm really has a strong impact on the game, not only on  the bugs… Flocking makes the game a little more “nervous”, and units behavior seems different.

The future will tell us if we made a good choice.