Game design

What Makes Good AI?

A piece about readable, fair, predictable, and interesting game AI.

There must be more to good AI

Whenever people talk about "good AI", the conversation usually comes back to the same three examples: the replica soldiers in the original FEAR, the aliens in the Halo series, and the marines in the first Half Life. These games do have clever behaviours, and Halo 2 and FEAR pioneered AI techniques that are still used today. But they also have something else in common: aggressive enemies that actively hunt the player and have enough health to stay in the fight.

That pressure can make enemies feel much smarter. Bungie understood this during development of the first Halo. The studio ran a playtest with two versions of the game using the exact same enemy AI. On one machine, the aliens dealt less damage and died quickly. On the other, they dealt more damage and had more hit points. The number of players who described the enemies as "very intelligent" jumped from 8 percent to 43 percent when the enemies were tougher and more resilient.

Aggressive enemies do not work for every kind of game, though. id Software found this during development of Doom 2016. It began with enemies that chased the player down, but that made players act defensively. "We'd end up in these situations where you would instantly start backing up," said director Marty Stratton. The studio changed course and told enemies to hold their ground more often, letting the player be the one who pushes forward. Like everything else in game design, AI has to fit the intended experience.

Aggressive AI fits the Xenomorph in Alien: Isolation, but it would be wildly out of place in Batman: Arkham Asylum. No one gets the drop on Batman, after all. So there must be more to "good AI" than enemies who can kill the player. The question is what else makes AI readable, fair, surprising, and useful to the game around it.

Good AI lets the player cheat

Good AI lets the player cheat, but not in obvious ways like putting a bucket on a shopkeeper's head in Skyrim and robbing them blind. The best version is much subtler. In the Uncharted games, when you pop out of cover, enemies begin with a zero percent chance to hit Drake. That gives the player a brief opening to take a few shots.

Far Cry does something similar by allowing only a few enemies to shoot at you at once, which improves your odds of surviving the fight. In the Arkham games, enemies are told not to turn around during predator sections, so Batman can sneak up behind them.

The player should not notice these tricks directly, but they would definitely feel their absence. They make the game feel fair, even when the rules are quietly biased in the player's favour.

Good AI tells you what it is thinking

Good AI tells you what it is thinking. The most common tool is the bark: a short vocal clip where a patrolling guard says something like "Sounds like someone's over there..." or "Must be nothing". The same idea can also come through animation, body language, vision cones, light and noise sensors, or ghostly markers that show where an enemy last saw you. The exact amount of information depends on the game, but the player needs some way to read the AI's state.

Another approach is to give AI characters distinct personalities, like the coloured ghosts in Pac-Man or the leaders in Civilization's single-player modes. Each has its own quirks, and developers have found that this can make AI seem smarter to players. If a guard has complex decision making and perception skills, such as noticing that a door along their patrol path has been opened, the player may never know unless the guard says, "Did I leave that door open?"

Those signals are not just flavour. They are critical feedback the player can use to understand what the AI is doing, what it might do next, and how to plan around it.

Good AI is predictable

Good AI is predictable. That may sound odd, but in 2004 Halo tech lead Chris Butcher put it clearly: "The goal is not to create something that is unpredictable. What you want is an artificial intelligence that is consistent so that the player can do things and expect the AI will react in a certain way". This lets players act with intentionality, which Far Cry 2 designer Clint Hocking defined as "the ability for the player to devise his own meaningful goals through his understanding of the game dynamics".

Think about a red barrel. You shoot it, it explodes, and from then on you understand a useful rule. Every time you see a red barrel, you know you can shoot it to create an explosion and use that explosion to your advantage.

AI behaviour needs that same kind of reliability. If guards always return dropped guns to crates, or turning off a generator always makes an enemy investigate, the player can use that knowledge to create plans, diversions, and traps. Without predictable behaviour, the player cannot create satisfying plans.

Butcher gave the example of sneaking up behind a Grunt and seeing it run away. "It would be bad if they only ran away half of the time, because then the player can build a plan that will only work half of the time". Instead, Bungie aimed for predictable actions with unpredictable consequences. "The Grunt will always run away," said Butcher, "but you don't necessarily know where he'll run away to".

Predictability does not mean easy. In Spelunky, every enemy acts in an almost completely scripted way. That could make them effortless to avoid or kill, until they appear in big groups, navigate different environments, and start interacting with other characters. Then it becomes Spelunky.

Good AI can interact with the game's systems

Good AI can interact with the game's systems. In Breath of the Wild, an enemy does not just walk up to Link and start attacking. It can run off to pick up dropped weapons, set a wooden club alight, kick away bombs, or even throw another monster at you.

This makes the AI seem smarter because it appears aware of the world around it. A Bioshock enemy who runs to a health dispenser midway through a fight looks like it understands self-preservation and has access to some of the same tools as the player. It also gives the player a chance to turn the system against them by placing a trap on the dispenser.

When AI can use the game's systems, the player gets more interesting ways to deal with foes indirectly. You might make an enemy fight for you in Prey, or trick an enemy into attacking a Cucco. If that needs a name, "chicken-boning an enemy" works well enough.

Good AI reacts to the player

Good AI reacts to the player. That can be as simple as guards becoming more frightened as you take out their buddies in the Batman games, or as elaborate as Shadow of Mordor. In that game, special Orc captains are randomly created with names, abilities, and relationships, and then remember their interactions with the hero. If you run away from a battle, the Orc might bring it up the next time they see you: "Hey! Not letting you run this time! I's gonna finish it!" That creates memorable, personal stories for the player.

Tracking the player can also change how the AI behaves. It does not need to be as complex as the Shadow Fighters in the newer Killer Instinct, or the Drivatar system in the Forza games, where Microsoft tracks how you play and creates AI doppelgangers to race or fight for you.

It can be as straightforward as Metal Gear Solid V, where enemies track how often you perform headshots, clear bases without being seen, or infiltrate at night. They then respond with different behaviours, such as wearing helmets, laying traps, or using night-vision goggles.

Those enemies are not truly "learning". They have been told what to do, but they only switch tactics after the player hits a certain threshold. The intended effect is to stop the player from using the same boring strategy for every base in Afghanistan.

Alien: Isolation uses a similar idea, with the Alien unlocking new abilities as the game goes on. It makes the Xenomorph look like it is learning from the player, and it keeps the game interesting as the hours pass.

AI can also adapt to shape mood and pacing. The most famous example is probably the AI director in Left 4 Dead. This system tracks each player's wellbeing, based on health and run-ins with special infected. If the team is cruising along, the intensity of the zombie horde increases. Then the AI director eases off and gives the team a chance to relax.

That idea is older than it may seem. Pac-Man used something similar. Designer Toru Iwatani said, "I felt it would be too stressful for Pac Man to be continually surrounded and hunted down. So I created the monsters' invasions to come in waves". In the game, the ghosts swap between chasing the player and wandering off toward the four corners of the maze.

Good AI has its own goals

Good AI has its own goals beyond "kill the player". In Rain World, other animals hunt for food and get into territorial scraps with rivals. Sometimes the best move is to let them get on with it.

That is also how STALKER: Shadow of Chernobyl works, or is supposed to work. Bandits make plans, then wander through the wasteland alone or in groups to carry them out. That means you can stumble into a raging battle that happened only because two rival factions accidentally crossed paths.

The AI is a bit buggy, and players need mods if they want AI characters to keep doing things outside their immediate location. But STALKER's A-Life system sure was ambitious, and games could use more systems with that kind of intent.

Or maybe games need more ideas like Waking Mars, a captivating sci-fi indie about increasing biodiversity inside the red planet. Once you understand how different plants and animals react to one another, you can build self-sufficient ecosystems where AI critters live and breed while you explore a completely different part of Mars.

Good AI isn't just about enemies

Finally, good AI is not just about enemies. Games need better friendlies too, because even games with excellent combat encounters can have allies who are dumb as dirt. Some developers solve this by cheating and making companions invincible, like Elizabeth in Bioshock Infinite, who cannot be hurt during combat. Given the long history of painful escort missions, that is probably a wise decision.

Friendly characters can do more than trail behind the hero, though. In The Last Guardian, you work with a giant beast called Trico who can take care of enemies. Trico is also nervous around stained glass windows, which the player can smash. That means the player and the AI must work together. It can be frustrating, especially because Trico has been told to ignore the player's instructions about half the time, but that also helps sell the idea that Trico is an animal.

In Event[0], developer Ocelot Society was inspired by internet chatbots to make a game where you can talk with an artificial intelligence and work with it to solve puzzles on a derelict space ship.

Then there is Final Fantasy XV, where one of your road trip buddies, Prompto, can snap Instagram-style shots during the adventure. At specific triggers, or just when Prompto feels like it, he automatically takes a picture and later presents you with an album of snaps to sift through. This has almost no gameplay value, but it is a lovely way to preserve your personal experience with the game, and it adds a lot to Prompto's character.

AI isn't just a technical problem

None of this means games should stop chasing "better AI". Stupid enemy decisions can pull players straight out of the experience, and there is not much satisfaction in beating an opponent who is obviously unintelligent. Okay, maybe there is some satisfaction. But developers should keep pushing AI technology forward and keep creating more nuanced enemy behaviours.

The important thing is that AI is not just a technical problem. It is also a design problem, and every game needs to approach it in a slightly different way.

We do need more games about fighting tactical squads of aggressive enemies, because something is clearly wrong when many modern shooters still lag behind a campy 13-year-old game. But that should not distract from the real goal.

In Uncharted 4, Naughty Dog experimented with complex AI behaviours before settling on enemies who were, according to designer Matthew Gallant, "spread out in a layout, looking human and smart, and moving in ways that are mildly predictable so the player has some ability to sneak up behind them". Because the AI's goal "isn't to find the player. It's to present interesting gameplay".