A Good A.I. Trick

Video game artificial intelligence is a fascinating merger between programming and artistic deception. Richard Bull, lead AI programmer for Empire: Total War explains in an interview, “the AI academics are your wizards and we’re your stage magicians — it’s all smoke and mirrors with game AI” (Ben Hardwidge, “How AI in Games Works”, bit-tech, 5 March 2009). An academic trying to simulate a human brain has a massive super computer devoted to the task of thinking, while an AI programmer for a video game is instead working with a small percentage of processor power. The majority of the computing power in games is instead going towards depicting graphics, sound, physics, and cow bell type things. For example, technically the AI in Halo 3 is less sophisticated than in Halo 2 because most of the processor has to be devoted to graphics. A giant, open world game will inherently have stupider AI because there just isn’t enough power to go around. So the art of video game AI is in making a player think that they’re interacting with something more sophisticated than it really is.

The first and most obvious technique for making an AI look smart is just keeping it alive long enough for the player to even notice it. An in depth discussion of the AI in Halo points out that the main difference between playing the game on Easy versus Legendary is that everything has more health and the player has far less (Alex J. Champanard, “Teaming Up With Halo’s AI: 42 Tricks To Assist Your Game”, AIGameDev.com, 29 October 2007). Play testers were more complimentary of an AI when they were able to observe it perform various tasks as opposed to just killing it on sight. Consistency is also an important factor, it’s important to not curve difficulty by dumbing down the machine or reducing its abilities. Once you see an AI behaving stupidly, the impression is permanent. Once a person is observing the AI, it’s also important to make sure that it’s broadcasting its conduct back to the player as much as possible. The Brutes seem smart in Halo 3 because we hear them shouting, “Flank him”, before they execute an otherwise simple AI command. Grunts seem like they’re responding to us because they shout “Run away”. Getting the player to even notice that the AI is doing something besides shoot is the first step to making it look good.

So once the player is watching the AI and you have a basic framework for broadcasting conduct, what are the real nuts and bolts of making it look smart? A difficult to spot deception, or lie really, needs three basic components. First, it needs to have enough of the truth mixed into it that a person can never absolutely prove the entire statement to be wrong. Second, it needs to require a significant amount of research to disprove the statement. Third, the person hearing the statement has to want it to be true. Cynicism aside, when applied to the creative arts deception is important for the suspension of disbelief. A good theater production doesn’t have an actor turn to the audience and remind the audience that it’s all a play any more than a game needs to stop and remind us that that these aren’t real people that we’re shooting. The art of crafting a strong deceptive element into a game is essential to the experience. The longer that an AI can appear autonomous while being scrutinized the better. Since players like to think they’re good at a game, having a fulfilling AI is intrinsic to that experience.

I’m not a computer programmer by any means, so my breakdown of complex processing is going to be very simplistic. It’s still relevant to consider because like getting the player to notice the AI, it’s important that the player be able to grasp what the system is thinking. An AI is basically a tree of tasks that combine together to create certain behaviors. As the AI is picking different ways to behave, the options become progressively more complex so that the tree is called a hierarchal finite state machine. A state would be something like “shooting” or “guarding”. Certain states take priority over others depending on what the player is up to. In the excellent bit-tech post cited above, Matthew Jack, the AI programmer for Crysis, explains that the average soldier in the game has about 25 states. However, “perhaps 90 per cent of their time is spent in only five states”, while the other states “handle specific circumstances such as using or reacting to vehicles, using special weapons and so on”. So the first rule of thumb for a good video game AI is that it be predictable. The player should get to know it first from a narrow perspective. The reason for this is that my perception of how intelligent the enemy unit is behaving is mostly a contextual issue. Their reaction to my conduct the first time is what I will expect the second or third time. It’s only when I do something weird like drive a Jeep into them that they need to have a sophisticated response.

This bleeds into the research resistant aspect of video game AI. If someone decides to do something bizarre, it needs to be capable of mixing things up. A lot of games will use a level specific series of reactions that mark spots on the map for the AI to perform various acts depending on their circumstances. Animators create specific actions for this spot like diving or jumping through glass and the designer just makes them into options for the AI. It’s not the same as scripting because the AI can choose not to use the animation. It’s important because once the AI has trained us to expect certain behaviors, it then needs to be able to surprise us anytime we poke around. So, as with the state machine, the majority of the time the enemies come in and things go as expected. But if you break out an odd weapon or kill everybody except the last enemy, there ought to be a potentially unique reaction to it. Naturally there are still a finite number of these in the program, but the player isn’t going to pick up on that unless they really start poking at the design. Not even the most sophisticated AI is going to survive intense scrutiny, so you’re just assuming the player isn’t going to dig too deep.

The last part of the deception, having the player want to believe the AI is very smart, is probably the easiest. It feels good to think that you just took down a sophisticated machine, so people are inclined to believe that’s what happened. Making the player aware that there is some kind of decision making process going on, familiarizing them with it, and then surprising them occasionally feeds into that rewarding feeling. I can still remember to this day the first time that I was genuinely impressed with a game’s AI. In the opening hours of Half-Life, most of what you fight are zombies or wild head crabs. It all plays very similarly to Doom in those moments and instills a lot of sloppy habits. When the marines finally arrived to “fix” Black Mesa, I ran into a squad and just started shooting. I killed one but got confused when his friends suddenly vanished. A weird clinking noise followed while I tried to figure out where they had run off to. Looking down, I realized I was standing on top of a live grenade. I think the shock of something so different and unexpected was what really made the moment convincing.