Making the Rules: Great Enemies

complicated_flowchartPreviously 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.

Wolf3dNow 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

Soldier of Fortune 2-1Of 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.

Half Life 1Contrast 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

mgs2iceSo 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.

10 thoughts on “Making the Rules: Great Enemies”

  1. To be honest, I feel like this piece catalogs all of the most annoying design techniques in game AI. I always find it ridiculous when a stealth game like MGS or even a more serious one like Splinter Cell features enemies that talk to themselves like Elmer Fudd… or when I painstakingly cover all the entrance points as I move through an FPS, only to be hit in the back by an enemy that obviously just spawned at a dead end as I arrived. Then, practically every game has taken the “feedback” idea to the extreme, where enemies are constantly shouting about “covering fire” or “flanking” in an effort to appear intelligent, even when it is not appropriate to the situation at all.

    “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.”

    I completely disagree. Having the opportunity to predict and outwit an intelligent enemy is one of the highest aspirations gamers have for AI. It’s also one of the primary elements in multiplayer shooter’s, a good team will always have someone covering the back entrance to their sniper position, and when a player knows that an enemy is trying to flank him or sneak behind him, a good player will devise a way to turn the situation around and have death waiting for the enemy when he arrives expecting to shoot you in the back. This is what makes multiplayer games so compelling, and could potentially become a fun factor for single-player games as well.

    The problem is this whole mentality among designers that games should not actually challenge players or directly try to thwart them, but instead just “act smart” or “act deadly” then roll over and let the player kill them so they can “feel cool”. Sure, the average unquestioning, casual gamer may be fooled by these techniques, but they are horribly transparent to veteran gamers and it pulls them out of the experience in a big way. This is the same mentality that essentially bans stealth from being used against you by AI in games, because from the player’s standpoint all he would perceive is that he died suddenly for no apparent reason. Thus the paradox that creatures in Doom 3 will never sneak up behind you, despite all the fun and immersive psychological effects that having to constantly check your six for silent creeping enemies would bring.

    This whole “leave no player behind” approach to game design might make sense from a commercial standpoint, but it screws over seasoned gamers seeking a dynamic challenge (not just some “give the enemies double overshields” half-assed nonsense) and insults their intelligence. I understand why this approach works sales-wise, but I don’t have to like it.

  2. Patrick: “There is no satisfaction to be gained by guessing the enemy’s next action and planning accordingly.”

    GnaM: “I completely disagree. Having the opportunity to predict and outwit an intelligent enemy is one of the highest aspirations gamers have for AI.”
    ————————
    You misinterpret what I am saying there. Note the context.

    “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.”

    What I mean here is that if the player has no method of understanding the enemies’ intent or tactics, he is likely to interpret that there are no tactics going on. Indeed, the player needs to understand what’s going on in an enemy’s head in order to form counter strategies and live up to those aspirations. This is why purely random (or even semi-random) AI decision-making can be extremely frustrating on the part of the player. In a Raph Koster sorta-way, he or she is dutifully trying to discern a pattern when there is none.

    But yeah, I think we also disagree here. As much as it may sound like a bland least-common denominator approach, I feel that the best approach to challenging players is to make the feel cool first and face realistic challenge second.

    In the case against stealthy enemies, I stand by that if the enemy manages to achieve perfect stealth and sneak attack you from behind, the game experience for all but the hardest of the hardcore will be a negative one. However, applying the values I express in this article, the solution would be to provide the player with a method, perhaps unreliable or requiring continuous vigilance, of detecting them. This way he can be scared of every shadow yet feel as though he himself failed in some way when he gets a knife between the shoulder blades. But you have to be careful to walk that line between “challenging” and “punishing”.

    You are our first guest to disagree with something that was said… I love the debate… welcome!

  3. I guess where we really disagree here is how much a game should use “kiddy gloves” in the way it treats the player. Certainly there are many unobservant gamers who wouldn’t notice the AI’s application of tactics unless it was plainly pointed out to them, but I think anyone who’s interested enough in the game to pay close attention will watch the tactics going on or guess why the enemy is doing what it’s doing. The AI shouldn’t have to constantly announce “I’m attacking you now!” “I’m flanking you!” “I’m sneaking up on you!”, “I’m retreating!”, “I’m reloading, come kill me!” to understand that these things are going on…that’s just treating the player like they’re stupid.

    I guess a good example here would be the bots in Quake 3 or the Unreal Tournament series. The bots in these games do have taunts, but otherwise they don’t announce their intentions at all unless you’re on their team. Thus, particularly in a 1-on-1 match, it’s up to the player to deduce what they’re planning based on the layout of the map, principals of resource control, etc. These are the same skills you would use to predict the opponent in a multiplayer match. Thus, if you’re in a firefight and the enemy suddenly disappears down a certain path, it’s up to you to figure out “are they retreating because they’re low on health?”, “are they going for the rocket launcher?”, “are they going for the armor that just spawned?” or “are they trying to sneak around behind me?”

    Of course this IS overwhelming to the average, casual, new player. They have no idea about any of these factors, and most likely in the subject situation, they will just camp there by the sniper rifle or rocket launcher until the enemy comes up behind them and instantly blows them to smithereens, or goes around the map collecting all the power ups till they’re nigh-invincible and secure an upper-hand for the rest of the match.

    In this situation the new player most likely WILL feel like the AI is being cheap and may end up frustrated…but that’s not the end of the world. If the player is smart, he’ll try to learn and figure out why he died or do better. Otherwise he’ll just keep on dieing till he quits the game and does something else. Yeah, it’s harsh, but that’s the way challenging games go, and have gone since the days of Castlevania and Contra.

    Of course, that method is not the most commercially viable and there’s a reason why Konami’s number one seller today is Metal Gear Solid and not Contra. I just wish developers could find a way to open up a game to both the casual and hardcore audiences without excluding one or the other through the design of the game. I think there are ways to ease newcomers into a game without excessive hand-holding and cutting out the hardcore…

    Given that UT3 is looking to be a major player on PS3, bringing thousands of new players to the franchise, I wonder how they will handle this. If they don’t make any effort to lighten up the learning curve a bit, UT3 will prove a big turn off to a LOT of console gamers that can’t handle such a fast paced game. I think in the case of the bots, they could easily implement a sort of “feedback” system as you describe where the bot voice overs actually announce its combat strategy, rather than just hurling stupid “your momma” taunts. By hinting towards things like the items they’re going for or ambushes they’re setting up, it could actually help the player pick up on game strategy pretty quick.

    Anyway, now I’m getting carried away…glad I could contribute to some debate on the site!

  4. Just a quick idea : why not actually have very smart AI that doesn’t announce its tactics… but when the player dies, show how it happened with some sort of overview, and maybe then show the AI “thoughts”.
    Sure, it would be omniscient knowledge, but it would allow a new player to witness the AI intelligence, learning what it can do, and hopefully having him keep that in mind for future battles.

  5. I am working my way through a game that’s incredibly difficult. It’s not particularly forgiving, as basically if either the player or the enemies get hit once, they die, and the player is consistently outnumbered and not as nimble as many of the enemies. However, the game takes incredible pains to lay out the game mechanics – each new enemy is introduced with an event that highlights their AI, and most of the potentially deadly or frustrating objects are similarly marked so that it’s obvious, for instance, what the radius of a bomb blast is, or what switches trigger what doors. It’s fun, because there’s an implicit assumption that every scenario is beatable with the right tactics, and because there’s no unknowns the brutal difficulty level becomes an exercise in trying different approaches. You know, in every case, why you died.

    Half-Life, I suspect, would have worked just as well had the soldiers stopped transmitting over the radio later on in the game, as they discover that the player has a window into their tactics. Once the players have learnt about each level of the AI, it can scale back the tells it gives the player and begin to allow the player to make their own calls.

  6. Just a quick idea : why not actually have very smart AI that doesn’t announce its tactics… but when the player dies, show how it happened with some sort of overview, and maybe then show the AI “thoughts”.

    Not a bad thought… This is the sort of information that lets players learn from their mistakes. However, it does have one problem (which might not bother some), which is it only teaches through death. This is not the end of the world, it just means that people would learn over a large number of sessions, like they do against a deathmatch opponent (or, appropriately, an FPS bot).

    Plus, I wonder, if the enemies are incredibly smart and unpredictable, would they still be impossible to predict? I suppose it would be like a game of chess or poker, where your opponent’s strategy is generally only uncovered after it’s too late to react. With such a situation, a player can ultimately learn the right things to do.

    I certainly am not out to predict doom-and-gloom and cite that all enemies should wear their intents on their sleeves. Perhaps the question here is whether anyone would have <i>appreciated</i> the Half-Life AI without being reminded of its cleverness. Is that the gateway from a hardcore game to a massively-appealing title?

  7. When people ask for better AI, they generally seem to mean two things in combination. First, they want something more challenging. Second, they want something that (visibly) cheats less.

    The moment a player catches the computer spawning an enemy in an impossible area (like a cleared dead end alley,) the player knows the game is cheating. That knowledge will affect how they perceive the rest of the game, because they know the designers and programmers took shortcuts in creating challenge. All future challenges offered by the game will be tainted by the knowledge that the game cheats.

    Racing games have something called rubber-band AI. When a player gets too far ahead of the competition, someone is boosted or teleported close to again offer challenge. This is most obvious near the end of the race, where an AI opponent will appear around the same spot each time to offer a last-minute challenge for first place. Designers seem to love rubber-band AI because it guarantees a challenge regardless of player skill, allowing the game to appeal to a larger base, and perhaps because it means less work is needed on designing the CPU AI. Players tend to dislike it though, as blatent CPU cheating renders a large section of the game and player skill meaningless.

    2D fighters have “reading the controller inputs,” where AI uses game state data directly to determine how to react the moment a player commits to an action. Such systems generally cheat further by ignoring the need for controller inputs for the CPU character. Such systems are popular on the designer side because they are easy to implement and offer a quarter-sucking challenge. (Later, one could argue that designers just assume players are going to hate any AI, so why bother with more than a minimal effort.) Players see such AI as some of the worst possible. They see the designers put no effort into it, relying on cheating rather than attempting a real challenge. The difficulty itself is often fake, as the rigid reaction system often fails to account for some (often basic) action that can be repeated until defeat. Worse, tactics learned facing such AI can be detrimental to versus play against other humans, so the single player fails even as a training mode.

    Which does touch upon a third measure of “better AI”… In games where facing computer opponents is similar to multiplayer where you face human opponents, facing the computer AI should at least help new players learn the game. The more facing the AI can teach, the “better” it is.

  8. Hi Pat!

    I’d agree with everything you said, except for one thing. 🙂

    The ammo sharing thing was something we only talked about doing in SOF2, not something we actually put in the game. We ended up deciding not to do it exactly because the player would never see it.

    Chris

  9. Hey Chris! Glad to hear from you… Hope all is well.

    Of course you and Ben Geisler were the AI masters of SOF2, so I stand corrected… The guys told that story so many times that I assumed it had made it in.

    The sentiment doesn’t change… Awesome AI is nothing more than a bag of raw potential until you figure out a way to sell it.

  10. The main problem about creating realistic AI is that video games aren’t realistic in the first place.

    If you happened to be engaged in a real firefight against several other people, you have the ability to pinpoint exactly where a noise is coming from, to see out of the corner of your eye, and, in general, to have a good sense of what is going on around you.

    This isn’t possible in a video game. Walking into an area, hearing a few gunshots, and then dying is frustrating only because you cannot tell the direction and the distance it is coming from. Having enemies sneaking up behind you is annoying only because you lack the ability of glancing over your shoulder quickly, and instead have to turn the camera completely to check out your six. (Being able to see behind you instantly with a click of a button like in many racing games should be placed in every FPS)

    Some games try to make up for this lack of awareness by placing a radar or map on the corner of the screen to let you know where all the enemies are and where they are going. The problem with this is that it takes away a lot of the surprise.

    So, how can AI be challenging without being cheap? Well, simply give the enemy some disadvantages that the player has to deal with. Force the AI to reload after firing a certain number of shots. When he goes behind cover, give him a couple a seconds to get his bearings and find the player when he moves out of cover. It’s really that simple.

Leave a Reply

Your email address will not be published. Required fields are marked *