"If I'm an AI, fighting with enemies around me, one of the decisions I have to make is where is the most advantageous position for me to be standing? In each environment, there are hundreds of points specified by the level designer -- these are possible places an AI might like to be. That is how they control the flow of the game. They take AI and move them from one point to another, based on what's occurring. You feed all that into the really low-level intelligence. Like, if I am here and I want to get there, how do I get there? That's called pathfinding and really, I like to say that almost all AI is about pathfinding.
In encounters, there are rules. The Covenant will be here on top of the building. If the player kills three of them, then the Covenant goes to a set of points that are inside the building. What's really happening is the Covenant is following quite simple rules that the player perceives ... as the flow of battle. It seems like the Covenant thinks they have been weakened, so they retreat to a more defensive position. In fact, they are actually just following quite specific rules that have been laid out for them in that space."
Chris works with the level designers to analyze each point in the allowable area for the AI. In a way, the thinking is done for them. Each point is assigned a value, based on its characteristics in the space. For instance, a high spot may be a good location if you are on the offensive but not so good if you are being attacked. A spot behind a wall may be a good place to hide, but not to shoot. The AI knows these values and picks the location that offers the value it needs for the current situation.
The real challenge of pathfinding is getting to that point in a way that makes sense. Chris elaborates:
"If you have a character that can't navigate in an environment, that character will do things that are perceived by the player as stupid, like running into a wall or standing still and being dumb. That's because they want to go somewhere, but they don't know how to do it. We invested a lot of time in pathfinding in our game. Our AI knows that there are objects in the world that we have tagged with properties; this is a small object or a large object or a huge object. The AI will know, 'I can run through small objects' when pathfinding. They will kick them aside. But they have to run around larger objects. Certain larger characters know they can barge through objects that small characters will avoid or run around. "
In order to create even more realism in how AI interacts with objects in the world, the team uses animation to smooth out the look of the pathfinding. "We also tag objects with animation points," Chris explains. "A crate may have a tag that tells the AI, 'You can jump on top of this if you want to.' So when pathfinding the AI can decide to make a path over tagged objects. In combat, if the AI knows an enemy is hiding behind that tagged object, they may choose to jump on top of it and say something scary, or if they have lost sight of the enemy they may decide to jump up on an object to get a better look."
Object tags are also used to keep the AI aware of changes in their environments and indicate places that an AI can use as cover. But if these cover objects are destroyed or moved, the tag changes. This is how the AI knows they can no longer seek cover at that point in space. The cover tag is attached to the object, not the space.