Previously Iâ€™ve talked about how games adjust AI difficulty because of the need to fulfill the playerâ€™s fantasy, and provide them with success and positive feedback. This time Iâ€™d like to talk about perils and pointers for creating good combat AI. Now, while many articles that wish to address â€œgreat AIâ€ contain heavy jargon or equations and diagrams depicting line of sight, or reticular splines or some such, letâ€™s put that aside for now. It can be a great deal simpler than that (although in some ways more challenging).
Out of Sight, Out of Mind
Imagine dropping a player in a sprawling mazeâ€¦ hedgerow, factory, prison, whateverâ€¦ that is impossible to be known beforehand. Within there is one incredibly realistic, human-like AIâ€¦ It operates on its senses, with no unfair information about the maze or the player, but it executes on some crazy supercomputer with a million factors that it takes into account, from its knowledge of combat tactics to its own preferences and personality. Hell, letâ€™s even keep track of what it had for breakfast in case we want to simulate a chance of it having an upset stomach. This AIâ€™s job is to start searching for the player and make assaults as he moves through the maze. For a moment, as we watch the AI, we can see it moving through the maze, tracking the playerâ€™s scent, thinking about how to flank himâ€¦ when it hits a fork in the path, it decides to go left or right based on tactical decisions, or its own tendencies, or whatever a human-like AI should do. Perhaps it has a human-like idiosyncrasy like alternatingâ€¦ Whatever. The important thing is when it finds the player, whether by crafty wiles or just dumb luck, it switches to combat tactics and starts attacking the player without warning, pressing any advantage it can. When it is out of the playerâ€™s view, he is completely stealthy, undetectable until he encounters the player again.
Now imagine this experience from the playerâ€™s perspective. Heâ€™s moving through the maze, starting to get familiar with his surroundings. Assuming the brilliant AI is quiet like he is, the enemy could be around any corner. The first time he encounters him, the attack could be anywhere, behind, aheadâ€¦ who knows. If the AI is particularly crafty and sets up a sniper ambush, the player could die in a single shot to the head. To the player itâ€™s a chaotic, unpredictable experience… Perhaps a fun one for some, perhaps not.
Now letâ€™s replace the AI with a more rudimentary version, one that makes more random decisions about what path to take while moving through the maze. This is sporadically punctuated with the AI taking the best path to the player, using perfect information. The enemy will still use intelligent tactical decisions once the player has engaged it in combat, but when it is out of the playerâ€™s sight, the AI is entirely artificial. For the player, assuming the general frequency and predictability of the enemy appearance is similar, very few audience members will notice the difference.
Now letâ€™s go even further, and replace the AI with a spawning routine that creates an enemy at the edge of the playerâ€™s awareness at a similar frequency and predictability as either of the other approaches. Certainly there are a few cases where it would make a wrong choice, such as spawning the enemy from a dead-end, but how often would this become apparent to most players? .
Now what point am I making here? That â€œreal AIâ€ is worthless? Of course not! When the enemy is within the playerâ€™s view, it needs to act extremely effectively, to provide the player with sufficient combat challenge and to keep the illusion up that this is human-like behavior. However, once the player has lost all perception of the enemyâ€™s movements, there is a significant drop-off in the impact of sophisticated AI on the playerâ€™s game experienceâ€¦ That enemy could go off and play chess, consult his favorite trackerâ€™s handbook or compose humorous limericks about the death of the player, but none of it makes much of a difference if the player is not aware of these activities. And it doesnâ€™t advocate delivering â€œgood enoughâ€, itâ€™s just that we could be using that supercomputer for better things.
A Pinch of Player Feedback
Of course there are better ways of selling an interesting â€œhuntâ€ scenario between a player and an AI. The game might have remote cameras out in the world that allow you to sporadically see his activities. The enemy can leave a trail that you can pick up. He can make noises that might give away their position or distract you. These additions almost universally add additional player awareness of the AIâ€™s activities when he is out of sight.
Sure, you can add some clever AI tactics that go beyond spawningâ€¦ he might feint in one direction to lure you off, then work around and flank you. However, consider that we are adding to events in a chaotic, confusing combat situation to begin with. How would most players feel if they went towards an enemy who disappeared, appearing not much later to shoot him in the back? He might feel confused, or cheated, like the AI did something illegal. There is no satisfaction to be gained by guessing the enemyâ€™s next action and planning accordingly. There is no learning process to â€œoutwitâ€ the opponent, nor is there any way to increase oneâ€™s skill to defeat him, aside from simple reflex improvement such as firing a gun accurately.
The development of most game features require the creator to balance of the investment of time and computer performance, versus the gameplay value created. No feature is free, and in a shooter, if the AI programmer spent all their time creating AIâ€™s that can independently recreate all the works of Shakespeare, the time would generally be wastedâ€¦ such effort and horsepower doesnâ€™t help the playerâ€¦ this is a game about combating the enemy. Back when I was working on Soldier of Fortune 2, there were some enemies that had the ability of tossing clips to each other if one ran out of ammo. However, nobody knew that feature existed. Why? Well, the clips were never exchanged unless the two enemies were behind cover, completely out of sight. Also, the ammo level of any individual enemy was never a significant issue in the game, since fights tended to be very short and deadly. This was a time to invoke a cardinal rule of game development: Features that do not notably affect the player experience are usually not worth implementing.
Contrast that to the AI in the first Half-Life, which critics and consumers unanimously celebrated as one of the most significant contributors to their enjoyment of the game. In Half-Life the enemies did all sorts of things, from flanking you to spotting your thrown grenades and responding accordingly. However, combat against the deadly Black Mesa soldiers was a very hide-and-shoot affair, so there would have been little opportunity for the player to understand their tactics and smarts. However, some exceedingly smart individual at Valve decided to give the player a radio that intercepted the soldierâ€™s communications, which gave the player a window on their reactions and strategies. Sure, it would have been even more challenging for the player if he had absolutely no clue to what the enemies were going to do next, but it is far more impactful to the playerâ€™s experience to allow him to understand how smart the enemies are. Arguably, beyond every other feature the enemies in Half Life had, the radio was the single most significant invention of that game.
Enemy communication of their intent has been used in other games, such as Halo, where the slightly comical alien grunts would spout exclamations like â€œthere he is!â€ or â€œwhereâ€™d he go?â€ when they observed a specific situation. Metal Gear Solid soldiers talk to themselves, saying â€œwhat was that noise?â€ and so on. Of course itâ€™s not realistic, but it makes things more fun. Concealing those mechanisms actually creates a less compelling experience than when you lay out the rotating gears in front of a big window that the player can see.
Great AI lives in the player
So if a more human-like opponent leads to unpredictable, and often unsatisfying behavior, and realistic, limited information plunges the player into a chaotic, random-seeming experience, what is the player asking for when he or she is asking for â€œbetter AIâ€ or a â€œsmarterâ€ opponent? The answer to this harkens back to a previous point, that the player wishes to fulfill a specific fantasy that they have. They wish for their opponents to respond as they imagine they would in their fantasy. In the case of a super-spy fighting against armies of henchmen, itâ€™s a set of opponents that appear to fight against the player effectively, yet die or fail to kill the player at appropriate moments so that the player can feel powerful.
In a playerâ€™s fantasy, an enemy is still capable of many things. There is a great deal that a gamer can imagine his electronic opponents doing to try to outsmart him. This includes flanking the player, hearing noises and investigating, changing ammo types, and spotting and responding to thrown grenades. In fact, it could be said that a large variety of actions at the enemyâ€™s disposal is what might make him seem â€œsmartâ€. However, again, with limited information confounding the playerâ€™s ability to appreciate this rich palette of AI options, there is but one avenue to make a character seem intelligentâ€¦ we must inform the player of some of the choices that are being made while they are being made, so that the player can feel even cooler when taking them out.