Halo AI – Exploring the Behavior of the Convenant NPCs

The Halo trilogy was a pioneer of development in the game industry in many ways. From the visually stunning maps and characters to the combat elements which are now taken for granted in many shooters to the way the cut scenes flowed in and out of the gameplay, Bungie paved the way for shooters to become a staple of console games. Of the many admirable elements of the series, the combat behavior of the enemy characters in the campaign modes accomplished significant gains in artificial intelligence techniques of the time. In fact, the approach Halo took to building its AI is still relevant and utilized to this day. This page will examine the method used by the Bungie team to build such a believable opponent on the battlefield.

Behavior Trees

The method for building the enemy AI in Halo pioneered behavior trees. Behavior trees consist of hierarchical sets of nodes, that control decisions the AI will make at a given moment. A node in this case refers to a defined set of criteria that needs to be met, or if statements.

There are two node types that make up a behavior tree:

Selector Nodes – make decisions about which child node to execute. Must have more than one child node to perform.

Leaf Nodes – has no children. Used to perform a specific action.

Essentially, selector nodes work together in order to achieve a final decision, or a leaf node. For a visual explanation, check out this graph representing a section of the behavior tree from Halo 2:

In this case, the 1st column (Root) is a selector node. Every tick of the game, it will fire in order to see which of the selector nodes within its scope is the best decision. (I’ll mention optimization that works around this farther down) Whichever child selector node (Vehicle, Retreat, etc.) is chosen by the parent selector node will then make a decision about which of its child nodes are the best choice. This continues until a leaf node is selected and an action performed. The above diagram is just a small portion of what the entire itinerary of a character would look like.

Once a parent node has executed a child (leaf) node, the program must decide how to proceed. It might make sense to simply run through the behavior tree again, but this can result in little change to the behavior. There are a few ways to treat the selection of child leaf nodes:

Priority-list – child nodes are given a priority number for which to select. The higher priority nodes are usually selector nodes, that are given favor if their conditions are met (more often not the case).

Sequential – these parent nodes execute their child nodes in order, skipping ones that don’t qualify. Once all have been executed, the parent node is finished.

Probability – parent node will randomly select a child node.

One-off – parent node will pick a child node randomly or with prioritization, but will not repeat its previous choice.

This means that most often, a selector node will run through every option with its child nodes before returning to its own parent node, which may select that very same node once again to run through the same tasks. It is for this reason that behavior trees need to encompass a wide array of possibilities for the AI to choose from.

There are other factors that influence the behavior of the characters as well. These include impulse triggers, style commands, and order commands.

Impulse Triggers

This mechanism exists to give fairness to the distribution of priority actions. The impulse trigger functions as a child node in a given set. When chosen, it simply redirects the execution to a completely different area of the behavior tree, functioning as a portal to easily maneuver between behavior types. For example, if the AI has a choice between getting into the vehicle or firing upon the player, shooting at the player has priority in Halo. If the player enters the vehicle, the condition of whether or not the player is in a vehicle comes into play, and entering a vehicle gains priority for the AI. Once the AI enters the vehicle the behavior will jump over to a separate set of conditions, where it is in the vehicle.

Stimulus Behavior

In the event of specific circumstances, it is important for certain nodes to be able to “interrupt” their peers. This is referred to as a stimulus behavior. These nodes exist as impulse triggers, except that when activated they only point to nodes at their level. This allows them to override the AI behavior only after they have completed a certain set of nodes. For example, if the AI was running a “throw grenade command” and the stimulus behavior node was a Root child, then the program wouldn’t allow the override until it returned to the root level, which might take place after it completed multiple nodes at a deeper level.

Style Commands

Creating style commands for a group of characters is a way to fine-tune the behavior of the AI in a given situation. These commands limit the behavior of the program for a group in certain ways, creating a smaller tree for the enemy to choose from. This is helpful when you want enemy behavior to vary throughout the game.

Behavior trees at a complete level are quite extensive. Style commands allow designers to pick and choose the behaviors they want displayed at any moment. The Bungie team in this case had a small library of styles to choose from. “Aggressive styles” disallow self-preservation. “Defensive styles prevent search and charge type behaviors. These can be bestowed and removed from the AI at any time, in a way that sculpts their behavior more well-suited to the game’s needs.

Style commands can be problematic, however. When they are too limiting, the AI may not be able to run any behavior in a certain situation. It may also react in unexpected and random ways. Style commands therefore need to be considered when creating the original behavior tree programming.

Order Commands

Similar to style commands, these commands affect the movement of the AI across the map more than anything else. Order commands will tell the AI whether to push forward, fall back, divide and conquer, etc. When used in unison with style commands, they demonstrate a truly battalion style of behavior. Order commands tell the AI where to go, while style commands tell them how to get there (stealth mode, charge, etc.).

Personalization of Behavior

On a more individual level, the behavior of certain characters can be limited and expanded upon. Personalization of behavior is crucial for creating unique character types that display individual behavior types based on their role in the game. For example, while Grunts may retreat if their leader is killed it would be a shame if all enemies did this!

This customization is accomplished “parent” characters, which exhibit general AI behavior and “child” characters which display more specific behavior types. This can be accomplish through several levels of children (3 for Halo). When the behavior program for a character runs, it first seeks the highest level of child code. If it cannot find a behavior at this level, it searches at the next level up and so forth.

Optimization

The personalization of behavior using parental behaviors is a great strategy for optimizing the Halo series. The code for each characters behavior could have been duplicated and customized, but this would have been an extremely inefficient method comparatively. Creating only the necessary custom code for each unique character type allowed the program to use the minimum amount of scripts for the decision making process.

Another issue that the team ran into was the necessity for only one character to make a decision per tick of the game. This prevented the program from running every character at once, at is unnoticeable to the player because of the frequency of ticks per game.

Finally, the behavior trees had a mechanism that allowed them to remember their behavior history for each step of the game. This prevented the need to run through the entire tree at every tick of the game. This also prevented the behavior from duplicating the same actions over and over again, and generally improved the decision making process.

Visual Elements

One important aspect of artificial intelligence for games is the character design. The way these characters are designed says a lot about how they should behave to the player. The Covenant of the Halo trilogy was successful in this endeavor, as their characters appearance illuminates the role they have in the game. Here is a vague description of those characters, and the behaviors they exhibited:

Elites

One of the strongest enemies, and leaders of the pack. Elites are designed to seem more intelligent than their Brute counterparts, and this is displayed by the fact that they are more likely to retreat if low on health, rather than keep fighting.Elites are given shields just like the player, and are roughly the same size as the player, causing them to come off as peers despite being enemies.

Brutes

Less intelligent but more fierce than the elites, Brutes are more likely to go into “enrage/attack” mode if low on health, rather than self preservation. They became the main enemy of Halo 3, and were redeveloped as a result. For example, in Halo 3 Brutes were given shields, and became similar to the elites in the role they filled.

Grunts

The meekest of enemies, the appearance of grunts is adorable and miniscule. These lowly enemies truly demonstrated the hierarchy that was at play in Halo in a beautiful way. They are known for fleeing from the player when their commander was killed. They may not have been a formidable opponent, but they displayed AI through their dialogue about what was happening around them. In later Halo games, this dialogue becomes extremely intricate. Nonetheless, the dialogue and comments was a great strategy for making the characters feel real even though they weren’t an especially fierce opponent.



Another interesting dynamic was the “kamikaze” mode they also had. These grunts will run around and explode if they come into contact with the player. They mostly utilize the seek mechanism, and do not retreat as they are kamikaze type enemies. They usually show up through doorways or in places where the player can’t see them from a long distance. This behavior would occur when the group leader was down, as a sort of last resort effort. Interestingly, it seems to be a squad mentality even after the chief dies. Either a few of the grunts try to escape, or they try to kamikaze, but the ones in the same group usually make the same choice.

Jackal

These enemies had large round shields, and served mostly to defend their allies from the player. They will avoid becoming isolated, and tend to stay close to their group leader, often Brutes. They oftentimes flee if their shields are broken. They appear to be a sneaky opponent, which is reinforced by the fact that they are the snipers of the game.

Hunters

These massive enemies travel in pairs and are very difficult to kill. They do not have a retreat or idle mechanism present, and become enraged if their partner is killed. Usually show up in the middle or towards the end of a battle. Their massive size and thick appearance demonstrates that they are an enemy that can take some serious damage.

Flood Parasite

These unintelligent characters would lumber around, and explode into many different mini versions of themselves when shot at. Overall, they weren’t much of a threat but knowing they would multiple still forced the player to deliberate over attacking them. Their creepy appearance coincided with their role in the game through appearances underground and far from civilization.

Drones

These enemies walk, crawl, and fly. They are meant to seem a little more chaotic and less rational than the on-foot enemies, and are considered less intelligent generally. They have a pack mentality, and rarely will stray far from the group.



Conclusion

The enemies of Halo Covenant are one of the finest examples of implementing game design strategies to enhance the AI of the game. Unfortunately, the specifics of their coding and the exact decision making mechanics that were used are relatively unclear. Nonetheless, from a designers perspective these games can be used to work backwards and recognize that a dynamic cast of enemies is a great way to inspire quality AI in a video game.

Other Posts

AI and Character Design Seven artificial intelligence techniques that can be used to improve game character design and improve any video game.

Using AI For Stealth Games Stealth video games rely heavily upon the component of AI. This is a unique style of AI and should be approached as such.

Super Smash Bros AI A brief analysis of the enemy CPU modes used in SSB.

Resources

https://electronics.howstuffworks.com/halo2-ai3.htm

https://www.pcauthority.com.au/feature/building-believable-ai-in-games-halo-477480

http://www.northeastern.edu/gamedesignpatterns/halo-analysis/

https://www.gamasutra.com/view/feature/130663/gdc_2005_proceeding_handling_.php?page=2