fbpx

Liam explains a little about the swarming mechanics in the game.

You are looking at sped up game footage of two colonies of ants fighting each other. The player and AI are simply controlling whether or not ants leave the nest (like opening and closing the door). I wanted the ants to move around organically and swarm around each-other. As the game needs to be optimized to run on a mobile device as well as a PC, the algorithm had to be as light as possible. One of the biggest bottlenecks in the game engine is &quot;collision detection&quot;, i.e., finding if one object is touching another. An example would be an ant &#039;scanning&#039; for another enemy ant. It might try to detect collision between a large circular area, centred around itself with all other ants on the screen to find a viable target. Another computational intensive task is &quot;path-finding&quot;. That is, once an ant knows where it wants to go – how can it get there if there are objects (like loads of other ants) in the way? To try and reduce the computational load, the ants were given very small collision detection scan ranges – but with the added bonus that they can retrieve scan information from any ant within their radius. So if there is a chain of ants leading to a target, the ant at the far end, even though it can&#039;t see the target, will head towards it. Friendly ants also repel each other based both on how bunched together they are and how many enemies have been detected by their friends. This causes them to march fairly close together, but spreading out dramatically when they near a large number of enemy targets. This prepares the swarm to surround the enemy before most of them even have a target. Once the ants are in very close range of their target, if they can&#039;t push past friendly ants standing to reach it, they will nudge themselves in a random direction. They continue in the same direction, intermittently pushing back towards their target until they enter combat. This allows the swarms to naturally surround each other without the need for complex path-finding algorithms. By the way, if you want to know more about the game we are currently running a kickstarter: <a rel=”noreferrer nofollow” target=”_blank” href=”https://www.kickstarter.com/projects/eotu/empires-of-the-undergrowth”>https://www.kickstarter.com/projects/eotu/empires-of-the-undergrowth</a>(sorry for the self promotion, we need all the help we can get at the moment)