AI for a com puter game must not appear overly stu pid. Players love laugh ing at AI when it does some thing com pletely fool hardy. Noth ing breaks a player’s sus pen sion of dis be lief more than when an AI agent fails to nav i gate around a small obsta cle such as a fire hydrant or a tree, or when an agent charges right off a cliff to its doom like a lem ming. To the player, it is com pletely obvi ous what the AI should do in each sit u a tion. But what may look obvi ous to the player can actu ally be a fairly com plex action for the agent to per form or under stand. None the less, for the game to avoid becom ing a laugh ing stock, the game’s AI must have a solid mas tery of what seems obvi ous to human play ers.
Developing a chal leng ing AI for a turn-based strat egy game such as Alpha Centauri can be quite dif fi cult since the player is sup posed to be fight ing oppo nents with roughly the same strengths and weak nesses as him self.
The num ber of dumb things the AI will be able to get away with has a direct rela tion ship to what sort of intel li gence the AI is sup posed to rep re sent. For instance, in my first-person shooter Dam age Incor po rated, the player is sup posed to be almost exclu sively bat tling human oppo nents. In Mar a thon 2, how ever, the player is bat tling a vari ety of alien spe cies mixed with some robots. The ene mies in Mar a thon 2 are able to get away with appear ing stu pid since they are non-human crea tures. In Dam age Incor po rated, con versely, since the ene mies are all humans they must look much smarter. For another exam ple, in Dam age Incor po rated, accord ing to the game’s story and the appear ance of the lev els in the game, the action is sup posed to be tran spir ing in a real-world envi ron ment. On the other hand, Cen ti pede 3D takes place in a whim si cal fan tasy world that bears only a tan gen tial rela tion ship to the real-world. There fore, while the guards in Dam age Incor po rated need to appear to be track ing the player like real human sol diers would, in Cen ti -pede 3D it is less absurd that the cen ti -pedes are unable to make a beeline for the player and instead have to wind back and forth between mush rooms. AI stu pid ity is accept able rel a tive to the type of world the com puter game is sup posed to rep re sent.
Be Unpredictable
Humans are unpre dict able. That is part of what makes them good oppo nents in a game. This is one of the pri mary rea sons that peo ple enjoy play ing multi-player games; a skilled per son will be chal leng ing to fight in a way a com puter never will.
A large part of that is the unpre dict abil ity of a human oppo nent. The same should be true of the AI oppo nents in a com puter game. When the game gets to the point
When fight ing aliens in a game such as
Mar a thon 2, the player has low ered expec ta tions of how smart these ene mies will be.
where the player feels with cer tainty that she knows exactly what the enemy forces are going to do at any given sec ond, the fun of play ing the game quickly wanes.
Players want the AI to sur prise them, to try to defeat them in ways they had not antic i pated. Cer tainly multi-player games still have the advan tage of includ ing a social com po nent, which is a major fac tor in their suc cess, and the AI in your game will never be able to be a friend to the player in the same way another human can.
But if you can not pro vide the social com po nent of multi-player games, you can at least strive to make the AI agents pro vide much of the same chal lenge and unpre -dict abil ity that a human oppo nent can.
In all art, the viewer wants to see some thing she had not been able to antic i pate, some thing that chal lenges her expec ta tions. When, within the first ten min utes, you know the exact end ing of a movie, book, or play, a big part of the thrill of expe ri -enc ing that work is removed. The same is true for com puter games. Of course, games can sur prise play ers with their pre de ter mined story, or what sort of envi ron -ment the next level will take place in, or what the big boss robot will look like. But if the AI can also con trib ute to this unpre dict ably, the game gains some thing that no other com po nent of the game can pro vide: replayability. Players will keep play ing a game until it no lon ger pro vides them with a chal lenge, until they no lon ger expe ri -ence any thing new from play ing the game. And an AI that can keep sur pris ing them, and thereby chal leng ing them, will help keep their inter est high.
Suc cess ful unpre dict abil ity can take many dif fer ent forms in games. It can be as sim ple as the ran dom num ber that deter mines what piece will drop next in Tetris.
Surely this is a very sim ple case, and opti mally we would hope many games could
The only AI Tetris needs is a ran dom num ber gen er a tor.
Pic tured here:
clas sic mode in The Next Tetris.
pro vide deeper unpre dict abil ity than that. But at the same time, one must real ize that for Tetris, it is the per fect amount of unpre dict abil ity. If play ers knew what piece was com ing next, the game would lose a lot of its chal lenge. Indeed, with the
“next” fea ture on (which dis plays the next piece to drop on the side of the screen) the game becomes sig nif i cantly eas ier. Pure ran dom ness is often a really good way to keep the player inter ested in the AI, to make them won der, “What’s it try ing to do?” when in fact it is just being ran dom. The ran dom ness in Tetris pro vides the unpre dict abil ity required to keep the player chal lenged for hours.
Some times the goals of com puter game AI can get con fused, and in a quest for the holy grail of real ism a designer or an AI pro gram mer can end up mak ing a very dull oppo nent for a game. Sure, the agent always makes a deci sion which “makes sense” given its cur rent sit u a tion; it may even make the deci sion most likely to win the cur rent bat tle. But if that log i cal deci sion is com pletely obvi ous 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 swing ing wildly, the next time you play that room the sit u a tion will be much less chal leng ing. What if some times the Orc is star -tled by the player’s sud den arrival? Then the Orc might flee down the hall or go cower in a cor ner. What if some times the Orc decides to hurl his club at the player instead of try ing to use it as a melee weapon? That would cer tainly pro vide enough spice to keep the player on his toes. You must remem ber that each human being is dif fer ent and that many humans are known to act irra tio nally for any num ber of rea -sons. That irra tio nal ity keeps life inter est ing. If the player is bat tling humans or human-like mon sters/aliens in a com puter game, a lit tle irra tio nal ity will result in mak ing the oppo nents seem that much more real, believ able, and inter est ing to fight.
“Fuzzy logic” is one method AI design ers and pro gram mers may try to use to keep the AI agents unpre dict able and inter est ing. Essen tially, fuzzy logic takes a log i cal sys tem and inserts some ran dom ness into it. In fuzzy logic, when the AI is pre sented with a given sit u a tion, it has sev eral worth while courses of action to choose from instead of just one. Say the player is at a cer tain dis tance with a cer tain weapon while the AI agent is at a cer tain health level and is equipped with a cer tain amount of weap onry. There may be three rea son able things for the agent to do in this case, and they can each have dif fer ent numer i cal val ues or “weights” rep re sent -ing how good a choice each is. Say that run n-ing up and attack -ing the player makes a lot of sense, so it rates a five. Doing a threat dis play in order to frighten the player makes a bit of sense, so it rates a two. And maybe try ing to cir cle around the player in order to dis ori ent him is also plau si ble, so it rates a three. Using these dif fer ent weights, the agent can sim ply ran domly pick a num ber 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 dis ori ent the player. The weights rep re sent the chance that the AI will make a given deci sion. If the AI has enough dif fer ent plans at its dis posal, the player will never be able to know exactly what the AI will do, thereby mak ing the AI unpre -dict able. In the final anal y sis, bas ing AI deci sions on ran dom ness makes the agent look like it is per form ing com plex rea son ing when it is not. The player will never know that the AI in ques tion just picked its action ran domly. Instead, if the agent’s action does not look too stu pid, the player will try to imag ine why the AI might have cho sen to do what it did, and may end up think ing the agent is pretty sly when really it is just ran dom.
Of course, the unpre dict abil ity of an AI agent in a game must not con flict with the other AI goals I have listed here. If an agent is so busy being unpre dict able that it can not put together a solid plan of attack against the player, it is not going to be much of a threat to the player and he will not be chal lenged. Ideally, unpre dict abil -ity enhances the chal lenge the AI pres ents, instead of prov ing a det ri ment. If the AI ran domly chooses to do some thing com pletely fool ish when what it was doing was about to lead to vic tory, the player can not help but won der, “Why would the AI do such a stu pid thing?” When work ing on the behav iors of the crea tures in a game, it is always impor tant to keep an eye on the big ger pic ture of what that AI is try ing to accom plish.