For the final project for my Digital Media course, I conducted an experiment in developing a battle simulation system. The inspiration for this project came from reading and learning about software such as MASSIVE, an incredible scalable system for crowd simulation which is used to generate large crowd and battle scenes in movies such as Lord of the Rings, Inception, and Avatar. As movies and games continue to create scenes and environments with larger numbers of characters, it is increasingly more difficult to animate and control all of them by hand. Because of this, using a system that can dynamically control the units through algorithms and still produce realistic behavior is necessary, and is rapidly becoming a popular technique. In my project, I wanted to try and recreate such a system on a smaller scale, and experiment with how many units I could simulate.
For my project, I modified an existing framework for behavior animations to simulate basic behaviors from a battle environment. The characters are split into two groups, and each individual unit contains an algorithm that specifies certain features. Each unit will exhibit behavior similar to those seen in a battle. For example, if a unit is being attacked and is not currently attacking another unit, it will turn to attack its opponent. Also, if a unit is low on health, it will run away from its attacker and the battle in an escape attempt, returning momentarily in pursuit of a different opponent. In many instances where there are a large number of units present in the simulation, a unit may not be able to physically reach its target in order to attack. Therefore, it will choose another target closer to its location to begin attacking and not remain idle.
All of these behaviors combine to give some emergent patterns that are also realistic. One behavior I noticed was the tendency for units to gang up when attacking an opponent. Another was units flanking around the sides of a group in order to attack enemies in the back of the group. The initial charge and attack also simulates reality, where the front line takes the most damage and casualties. As the battle continues, the groups slowly disperse and integrate.
I conducted multiple different tests with different units to see how large of a simulation I could run. I initially expected to run a simulation with a few hundred units, because the code is not incredibly complicated. However, when I had more than 50 units on screen at once the simulation began to visibly lag. I expect this could be from the complexity of the character models and their associated animations. Although this limitation was a slight disappointment, I am still relatively pleased with the results.
I have compiled a video showing a battle between two, 18, and 50 units, which can be found here. Note that when a unit’s health reaches zero, it freezes and can no longer take action. The animation also immediately pauses, hence the units scattered all over the field in various state of attack when the battle ends.
The behavior code was written in C++, the character scripts in C#, and the environment constructed and simulated using the Unity game engine.