A large part of making immersive game worlds is replicating the natural phenomena that we see outside regularly. Since one-to-one simulations are currently impossible and always impractical, most of the challenge is trying to get as close to real as possible without needing to waste processing time on imperceptible details. Boids algorithms are an example of a way that we can create seemingly natural behaviors through relatively simple computation.

This project, made using Unity, simulates combat between two groups by calculating the individual combatants’ movement using a set of forces with varying degrees of intensity. Depending on which side the combatant comes from, they will have a different set of forces that correspond with their group’s set of objectives. These forces are then made to fluctuate depending on the circumstances to allow for organic reactions to environmental stimuli.


A view of the military formation aiming to capture an insurgent. The general is seen at the front of the group, and his soldiers follow behind in a pack. Green lines show the direction each participant is looking, and the black lines indicate that the first two military members have locked onto their target.

The combatants on the “military” side are led by a general and have been instructed to stay near him during the operation. The general just needs to focus on scanning the area so that his side can leave with a victory. Combining these two objectives, we get this emergent behavior of an army marching together towards their targets.

The overarching objectives are not the only components needed to give a natural feel to this simulation. The military’s soldiers also need to pay attention to their movement during the march to avoid bumping into each other. If they don’t pay attention to this, they could mistakenly follow orders so strictly that they all try to occupy the same position. Movement becomes a little less restrictive when a target is near because at that point they prioritize executing the mission before realigning. This process repeats until there are no targets remaining. Our boids ultimately end up executing a clean, methodical takeover of the enemy territory.


The military also employs the use of vehicles, so there are tanks and helicopters grouping together as they path through the streets and skies along their planned routes. These boids just focus on staying on the path without crashing one another to not risk costing the military losses. They don’t directly target insurgents, but occasionally the military chases down an enemy who unsuspectingly ends up in front of a tank at exactly the wrong moment.


The general capturing a wandering insurgent on the street while his soldiers follow closely behind.

The combatants on the “insurgent” side are being surprise attacked at one of their bases. Due to a lack of organization and preparation, they desperately wander around to avoid being captured. When they notice that the military is on to them, they need to flee quickly, but the city contains many obstacles that can mean the end of the road.

I also included different tools in the program that allow more control over the simulation. A live count of the participants per team is always kept. There are various camera views that can be used to track any of the groups such as the military, tanks, helicopters, or even a first-person controller that allows the user to join the military operation. Spawners and nukes are available as well for instances in which things get messy, or we want to test different team sizes.

Check out the repository here!

Back to view posts →

Leave a comment