Players have different expectations of the AI they find in different types of games . Players do not expect much of the AI in an arcade game like Centipede or a puzzle game like Tetris . As I have discussed, these games provide plenty of challenge to players while using various simple-minded or outright stupid opponents. In a wargame like Close Combat , however, players expect a lot more from the intelligence of the opposing forces. In an RPG, players expect to move into a simulation of a living world, where characters move around in a town more or less realistically . In a game like The Sims , the AI more or less is the game; with weak AI the game would simply not be worth playing.
So different games provoke different expectations in players of how smart the AI agents in those games need to be. However, we can still construct a general list of goals for any computer game AI, goals that change in importance as the design goals for a given game vary.
Providing a reasonable challenge for players must be the primary goal for AI in any computer game. Without setting up a worthy adversary of some sort , a game becomes unchallenging and therefore too easy to defeat. Worse still, a game that provides no dynamic challenge stops being a game entirely and becomes more of a puzzle or an interactive movie.
In a classic arcade game like Robotron: 2084 or in a first-person shooter like Doom , the challenge mostly comes from players being overwhelmed by adversaries and by the powerful abilities those adversaries have. For instance, in my oft-used example of Centipede , the bugs can kill players by touching them, while players must shoot the creatures in order to kill them. This puts players at something of a disadvantage . The fact that there are multiple insects attacking players at once does not help matters. As a result, the AI for these creatures can be fairly simple and predictable, yet players are still challenged by them.
The same imbalance holds true in Doom , where players may run out of ammo but their enemies never do, where players are much more helpless in the dark while the enemies can detect players just as easily as in the light, and where often the enemies, such as flying creatures, can go where players cannot. The fact that the creatures far outnumber the player character also tends to compensate for the reality that none of the creatures is very smart. The AI in Doom has to appear more sophisticated than the Centipede insects because the Doom world seems more real than the Centipede world, as I will discuss in a bit. The fact remains that primarily the AI provides a challenge for players by being more powerful and numerous than the player character.
Creating a challenging AI for a real-time strategy game like StarCraft is an entirely more difficult proposition. The expectation in games of this sort is that players are competing with opponents equivalent to them in strength. In your average real-time strategy game, both sides have a large number of troops to manipulate and the ability to build more as needed. Both sides usually need to mine a resource of some kind and use that to build more structures or troops. Basically, the AI in an RTS has to do everything players do and seem smart while doing it. Often the AI is given an advantage by being able to see the entire level while the players cannot, and possibly having a larger number of starting units, an easier method for obtaining more, or a bigger pool of resources from which to draw. Nonetheless, creating a challenge for players in an RTS game is quite difficult since it requires the AI to coordinate the movement of the units beyond the individual unit level, making the units appear to work collaboratively, as players would use them.
The difficulties presented in creating a challenging AI for an RTS game are only magnified in a turn-based strategy game such as Alpha Centauri . Here the AI is supposed to operate just as players do. Of course turn-based strategy games are some of the most thought- intensive games available, so that only amplifies the problem of creating a compelling opponent AI. Furthermore, the computer does not get to benefit as much from its extremely fast processing power; since the game is turn-based, players have as long to think about a move as they like. The computer s analytical nature does give it a leg up on remembering the exact status of all the units it has at its command, an ability at which human minds are significantly less skilled. Often turn-based strategy AIs create a challenge for players by cheating in various subtle ways, though I would certainly be the last to accuse any particular game of doing so. In the end, I certainly have no problem with such a tactic, since the end goal is to challenge the player without appearing too unfair in the process.
Regardless of the game type, the AI must present players with an interesting challenge. Without good AI, a game may become similar to playing chess with your (much) younger brother: somewhat pointless. The difference is, when you play chess with your kid brother, you hope to teach him the nuances of the game so that one day he may become a good player. You may also enjoy socializing with him, making an otherwise pointless game of chess worth it. Sadly, the computer game AI you battle has no hope of improving and is woefully inadequate when it comes to providing companionship. In order for a game AI to justify its existence, it must provide players with a challenge. At the same time, it is important to keep in mind that you do not want to punish the player too severely with your game s AI. Getting into a It s me versus the player! mind-set when you, as the game designer or AI programmer, hold all the cards is similar to savagely trouncing your little brother at chess every time you challenge him to a match. It is not a fair fight, and pretty soon your brother or game players in general will not want to play with you anymore.
AI for a computer game must not appear overly stupid. Players love laughing at AI when it does something completely foolhardy. Nothing breaks a player s suspension of disbelief more than when an AI agent fails to navigate around a small obstacle such as a fire hydrant or a tree, or when an agent charges right off a cliff to its doom like a lemming. To the player, it is completely obvious what the AI should do in each situation. But what may look obvious to players can actually be a fairly complex action for the agent to perform or understand. Nonetheless, for the game to avoid becoming a laughingstock, the game s AI must have a solid mastery of what seems obvious to human players.
The number of dumb things the AI will be able to get away with has a direct relationship to what sort of intelligence the AI is supposed to represent. For instance, in my first-person shooter Damage Incorporated , players are supposed to be almost exclusively battling human opponents. In Marathon 2 , however, players are battling a variety of alien species mixed with some robots. The enemies in Marathon 2 are able to get away with appearing stupid since they are non-human creatures. In Damage Incorporated , conversely, since the enemies are all humans they must look much smarter . For another example, in Damage Incorporated , according to the game s story and the appearance of the levels in the game, the action is supposed to be transpiring in a real-world environment. On the other hand, Centipede 3D takes place in a whimsical fantasy world that bears only a tangential relationship to the real-world. Therefore, while the guards in Damage Incorporated need to appear to be tracking players like real human soldiers would, in Centipede 3D it is less absurd that the centipedes are unable to make a beeline for the player character and instead have to wind back and forth between mushrooms. AI stupidity is acceptable relative to the type of world the computer game is supposed to represent.
Humans are unpredictable. That is part of what makes them good opponents in a game and one of the primary reasons that people enjoy playing multi-player games; a skilled person will be challenging to fight in a way that a computer never will. A large part of that is the unpredictability of a human opponent. The same should be true of the AI opponents in a computer game. When the game gets to the point where players feel with certainty that they know exactly what the enemy forces are going to do at any given second, the fun of playing the game quickly wanes. Players want the AI to surprise them, to try to defeat them in ways they had not anticipated. Certainly multi-player games still have the advantage of including a social component, which is a major factor in their success, and the AI in your game will never be able to be a friend to players in the same way another human can. Since you cannot provide the social component of multi-player games, you can at least strive to make the AI agents provide much of the same challenge and unpredictability that is provided by a human opponent.
In all art, viewers want to see something they have not been able to anticipate, something that challenges their expectations. When, within the first ten minutes, you know the exact ending of a movie, book, or play, a big part of the thrill of experiencing that work is removed. The same is true for computer games. Of course, games can surprise players with their predetermined story, or what sort of environment the next level will take place in, or what the big boss robot will look like. But if the AI can also contribute to this unpredictably, the game gains replayability. Players will keep playing a game until it no longer provides them with a challenge, until they no longer experience anything new from playing the game. An AI that can keep surprising them, and thereby challenging them, will help keep their interest high.
Successful unpredictability can take many different forms in games. It can be as simple as the random number that determines what piece will drop next in Tetris . Surely this is a very simple case, and optimally we would hope many games could provide deeper unpredictability than that. But at the same time, one must realize that for Tetris , it is the perfect amount of unpredictability. If players knew what piece was coming next, the game would lose a lot of its challenge. Indeed, with the next feature on (which displays the next piece to drop on the side of the screen) the game becomes somewhat easier. Pure randomness is often a really good way to keep players interested in the AI, to make them wonder , What s it trying to do? when in fact it is just being random. The randomness in Tetris provides the unpredictability required to keep players challenged for hours.
Sometimes the goals of computer game AI can get confused , and in a quest for the holy grail of realism a designer or an AI programmer can end up making a very dull opponent for a game. Sure, the agent always makes a decision that makes sense given its current situation; it may even make the decision most likely to win the current battle. But if that logical decision is completely obvious to the player, how much fun is it going to be to fight that AI? If every time you run into a room in a first-person shooter, the orc you find there is going to spin around, heave its club above its head, and charge at you while swinging wildly, the next time you play that room the situation will be much less challenging and interesting. What if sometimes the orc is startled by the player s sudden arrival? Then the orc might flee down the hall or go cower in a corner. What if sometimes the orc decides to hurl his club at the player character instead of trying to use it as a melee weapon? That would certainly provide enough spice to keep players on their toes. You must remember that each human being is different and that many humans are known to act irrationally for any number of reasons. That irrationality keeps life interesting. If players are battling humans or human-like monsters/aliens in a computer game, a little irrationality will result in making the opponents seem that much more real, believable, and interesting to engage.
Fuzzy logic is one method AI designers and programmers may use to keep the AI agents unpredictable and interesting. Essentially, fuzzy logic takes a logical system and inserts some randomness into it. In fuzzy logic, when the AI is presented with a given situation, it has several worthwhile courses of action to choose from instead of just one. Say players are at a certain distance with a certain weapon while the AI agent is at a certain health level and is equipped with a certain type of weaponry. There may be three reasonable things for the agent to do in this case, and each can have different numerical values or weights representing their relative quality. Say that running up and attacking the player character makes a lot of sense, so it rates a 5. Doing a threat display in order to frighten the player makes a bit of sense, so it rates a 2. And maybe trying to circle around the player character in order to disorient him is also plausible, so it rates a 3. Using these different weights, the agent can simply randomly pick a number from 1 to 10 (the total of the weights). If less than or equal to 5, the agent will run up and attack. If 6 or 7, the agent will try to frighten the player, and if 8 through 10, the agent will do its best to disorient the player. The weights represent the chance that the AI will make a given decision. If the AI has enough different plans at its disposal, players will never be able to know exactly what the AI will do, thereby making the AI unpredictable. In the final analysis, basing AI decisions on randomness makes the agent look like it is performing complex reasoning when it is not. Players will never know that the AI in question just picked its action out of a hat. Instead, if the agent s action does not look too stupid, players will try to imagine why the AI might have chosen to do what it did, and may end up thinking the agent is pretty sly when really it is just random.
Of course, the unpredictability of an AI agent in a game must not conflict with the other AI goals I have listed here. If an agent is so busy being unpredictable that it cannot put together a solid plan of attack against the player, it is not going to be much of a threat to players and they will not be challenged. Ideally, unpredictability enhances the challenge the AI presents , instead of proving a detriment. If the AI randomly chooses to do something completely foolish when what it was doing was about to lead to victory, players cannot help but wonder, Why would the AI do such a stupid thing? When working on the behaviors of the creatures in a game, it is always important to keep an eye on the bigger picture of what that AI is trying to accomplish.
Game AI can be used to further a game s story. For example, in an RPG, players may travel to a certain town that is home to a number of fearful residents who dread the arrival of outsiders. If players only observe these people, they can be seen to be navigating the town, going to the stores, restaurants , and factories just as people in a real town would. This sets the scene for the town and makes it seem real to players. But whenever players approach these people, they turn away, fleeing to safe areas to avoid interacting with the players. Why is this? What does it say about the town and the people who live there? Why are they frightened? What can players do to make the townspeople trust them? Players want to know the answers to all of these questions, and will start exploring the game s story as a result. English teachers are notorious for telling their students that it is better to show than to tell. This is especially true in a visual medium such as computer games. Instead of just seeing that the town s inhabitants are frightened of strangers in a cut-scene, a properly designed AI can actually show players this interesting information during gameplay. And when players are able to interact with these characters, their involvement in the story goes beyond being shown to actually being active in it. Players are able to be part of the narrative in a way no other medium makes possible.
Even the adversaries that players might fight in a battle can be adjusted to aid in the storytelling process. Suppose that in a wargame players are supposed to be fighting a general who is known for being compassionate about the welfare of his troops, perhaps more than is logical in a combat situation. Players could send in a few snipers to pick off several of the opposing force s troops that are serving as guards along the border between two contested areas. If the AI for the enemy general was properly designed, the slow drain of troops in that manner would start to enrage him. Once infuriated, the general would try a foolhardy attack to get back at the enemy forces, thus putting him at the disadvantage. Here again, a bit of the game s story has been told through the AI.
In my game Damage Incorporated , the player is a U.S. Marine Corps sergeant in charge of a fire-team of four men. Together with their men, players storm through numerous missions against a variety of heavily armed opponents. The men each have different strengths and weaknesses. Some are headstrong and will charge bravely into a fight. Some of the squad members are more careful about firing their weapons than others, and as a result are less likely to hit the player character or the other teammates. These personality traits are all communicated through the AI that these teammates use. Before each mission, players get to choose their team from a selection of thirteen different soldiers, each with a dossier players can read. The dossiers provide a psychological profile of each of the teammates, which gives some insight into their personalities. Furthermore, when actually on a mission, the teammates are constantly speaking, either in response to the players orders or just to comment on a given situation. This gives further insight into their personalities and how they will behave on the battlefield. If players read the dossiers and pay attention to the squad members personalities carefully , they will notice warnings that some of the teammates may not be completely balanced psychologically. For some teammates, if they are taken on too many missions they will crack or become shell-shocked and attempt to run away from the battle. Other teammates, if taken on specific missions that they do not agree with ideologically, will turn against the sergeant and his men. The AI, of course, handles these shell-shocked situations, which thereby helps to tell the story of these characters.
One area where AI is often avoided entirely by designers but where it can be quite useful is in dynamic storytelling. All too often designers cobble a story around a game instead of integrating the story with the gameplay. Furthermore, often designers want to tell static stories in which how a given character will react to players is entirely predetermined, regardless of the game-world actions or how the players treat that particular character. While designers often strive to keep the battles and action sequences as dynamic and unpredictable as possible, they almost always want to keep the stories exactly the same every time the players experience them. Why not have players be able to affect the mood of the different NPCs they encounter? Maybe if players say all the right things and do not ask questions about sensitive subjects, the NPC becomes friendly toward the player character. Maybe players can only coax crucial information out of a character after first becoming his friend. Perhaps the players reputations precede them, where the actions players have performed elsewhere in the world directly impact how that NPC will treat the player character. If players have performed less-than -good actions earlier in the game, maybe the players have to redeem themselves in the eyes of a character before they can proceed in the game.
In my game The Suffering , players determine what ending they get based on how they treat the friendly human characters they meet in the game. Players have the option to help these AI-controlled humans, kill them, or ignore them completely. I deliberately made the characters a wide variety of personalities, and made their AI reflect these traits. One character is extremely frightened by the creatures in the game-world, and thus spends most of his time frantically fleeing from them. Later in the game, players meet a corrections officer named Ernesto who hates all inmates, including the player character, Torque. When they first meet in the game-world, Ernesto immediately threatens Torque, pointing his machine gun at him but not firing it. If players shoot Ernesto early in this encounter, Ernesto will immediately become hostile to Torque. If players wait, however, Ernesto realizes that he and Torque must work together to survive against the monsters. Now if Ernesto is shot by players, he does not immediately become hostile but instead warns Torque that he needs to watch what he is doing. Thus Ernesto s AI changes based on how he is feeling about Torque. Of course, if Torque shoots him two more times, Ernesto will still become hostile ; he s no fool. In the end it is to the players advantage to keep Ernesto around, as his AI is set up such that he is the most effective combat companion in the game, enabling him to help players dispatch the countless creatures that keep rearing their ugly heads.
Of course, there is a wide range of different effects that can be achieved using the game s AI to create interesting interpersonal relationships. Sadly, this is something that has been all but unexplored in commercial games to date. Instead of telling static stories, we could be telling ones that, though not entirely procedurally generated, were subtly different depending on how players played the game. Using AI to spice up and vary the story from game to game may make telling a story much more difficult, but what it can add to the game s non- linearity and replayability is enormous .
In many games, the AI does more than just provide a threat and a challenge to the player. A game may even include AI agents that players do not directly interact with at all. The AI can instead be used to inhabit the living world the game creates. A game-world may be infinitely detailed in terms of the objects it contains and how it looks and sounds, but players are used to a real-world that also contains living organisms that think for themselves and behave in interesting ways. Therefore, creating a sterile game-world filled with inanimate objects is not going to be a very believable space for the player. One does not need to go overboard in filling up the game-world with complex ambient AI agents; a little can go a long way. Whether this means a few birds that fly around in the sky, insects that crawl around on the ground, or humans that go about their daily business, adding ambient life to a world can do a lot to make the game-world seem more real to the player. The Grand Theft Auto games have featured cities full of humans going about their daily lives, most of whom are not directly needed for the main story. These pedestrians make the city seem more real, and the more real the game-world is the more likely that players will be able to immerse themselves in it.
There is a close connection between filling the game with ambient life and using the AI to tell the game s story. Creating these inhabitants does a lot to establish the setting for your game, and setting is a key part of telling any story. But ambient life in a game goes beyond just establishing that setting; it helps make players feel less lonely in the game-world. How many times have you played a game where you felt like you were walking around a sterile wasteland, as if an exterminator had come through previously to eliminate any signs of life? Players love to see that the world has ambient life in it, creatures they can just look at rather than kill, and the depth it adds to the world can be invaluable.