F.E.A.R. Designer Diary #2 - A Study of Smart AI, Part II
The Monolith staff further explains just how it is that the soldiers in F.E.A.R. are so darn good.
We'll begin emailing you updates about %gameName%.
Gamers are still buzzing about the incredible artificial intelligence demonstrated by the enemy soldiers in the recent demo of F.E.A.R., the upcoming first-person shooter that's also one of the most anticipated games of the year. By now you've probably come to expect that the enemies in most first-person shooters are there to serve as cannon fodder. However, the elite soldiers in F.E.A.R. actually play like human beings who want to win and survive. Soldiers will literally jump over barriers, flip tables over for cover, crawl beneath obstacles to get to you, and scream commands to one another as they hunt you down. It's a pretty amazing technical achievement. Thankfully, the team at Monolith was kind enough to give us a glimpse into how the AI in F.E.A.R. is so lifelike.
F.E.A.R. the AI, Part IIBy Monolith Staff
The goal of artificial intelligence in video games is to create opponents that challenge you with realistic competence and provide you with a rich and varied game experience. Recent games have employed scripted behaviors with a certain degree of success, but a careful scrutiny of enemy behavior quickly exposes the limitations of that technology. Scripted behavior leads to repetitive and often inappropriate reactions that break the immersive feel of a game. As the game experience of F.E.A.R. is based on confronting a highly intelligent, highly trained combat force that quickly adapts its tactics in response to the player's actions, a new AI paradigm had to be created. Fortunately, the F.E.A.R. development team possessed the unique combination of proven experience and a thirst for applying the latest academic advances in AI research.
The results of the team's hard work are some of the most startlingly intelligent enemies you have ever seen. Gone are the days of replaying a segment of a level with the confidence of knowing your enemies' paths and reactions. In F.E.A.R., your enemies formulate real-time plans based on environmental circumstances and your actions within that environment. Your opponents will move and react to you with the familiarity and tactical awareness of a seasoned multiplayer veteran. You will witness AI opponents change their courses to avoid danger, manipulate the environment to create cover, flank you, and dynamically support squadmates with cover fire and verbal warnings. Your opponents in F.E.A.R. work together in such a realistic way that you may compare the single-player combat to the tactics and strategy of a quality multiplayer match.
Recent advances in AI have allowed game designers to give their non-player characters basic decision-making capabilities with predefined finite state machines (aka FSM). This standard FSM technology allows for goal-directed characters that are able to activate a goal in response to a situation. However, as Jeff Orkin, the game's AI architect, notes, "Once a goal is activated, the character runs through a predetermined sequence of steps, hard-coded into the goal. The embedded plan can contain conditional branches, but these branches are predetermined at the time the goal is authored." While this can sometimes give the impression of a "thinking" NPC, this is essentially a mildly more versatile form of scripting. The characters have limited and predetermined behavior patterns, and the rigidity of the "sequence of steps" often forces recognizable "dumb" behavior that breaks the immersion of the game.
The AI takes the next leap in the evolution of AI decision making with goal-oriented action planning (aka GOAP). In addition to deciding to activate goals, the AI also plans how to accomplish these goals in real time. "A character that formulates his own plan to satisfy his goals exhibits less repetitive, predictable behavior and can adapt his actions to custom-fit his current situation," says Jeff. Goals in GOAP are not created with a hard-coded plan. Instead, GOAP simply defines the conditions necessary to satisfy a goal, and the character determines the steps to satisfy this goal in real time. With this structure, the AI is able to dynamically replan to react to environmental factors. If a situation changes, the NPC recognizes this because the steps planned to accomplish his goal are no longer valid. When a plan becomes invalid, the NPC reassesses the situation and either finds alternate means for accomplishing the goal or activates a different goal. For example, if the player slams the door on a pursuing NPC, the NPC replans and decides to kick the door in. If the player physically blocks the door with his body, the NPC replans again and decides to dive through the window. Creating individuals that act intelligently is only half the battle. The next step was to make them act as an intelligent team.
There's No "I" in F.E.A.R.F.E.A.R.'s enemies predominantly patrol and defend locations as a group. The difficulty in creating a believably intelligent squad was to get each NPC to have good reaction times as an individual, within the context of the squad. In some games, all squad behavior means is that there are multiple individual NPCs in an area. But this is not the case in F.E.A.R. The squad mechanics in F.E.A.R. enable the NPCs to work in a sophisticated and coordinated effort to take you down. Squad behavior supersedes and directs the individual's movement to improve the tactical advantage of the group as a whole. Your opponents in F.E.A.R. will use verbal communication, squad maneuvers, and situational awareness to exploit the advantages of numerical superiority.
The most immediately apparent manifestation of F.E.A.R.'s squad intelligence is in communication. NPCs will scream warnings of your actions and location as you engage them. The verbal feedback from enemy NPCs is extremely accurate. If you rush a squad, you will hear, "He's rushing!" And if you are caught trying to flank a squad, an NPC will yell, "He's trying to flank!" The NPCs' awareness of one another also takes verbal form, as they account for squadmates down. "We've got two men down!" for example. The AI communication is impressive and enriches the gaming experience, but F.E.A.R.'s AI does not simply talk the talk.
Groups of enemy soldiers in F.E.A.R. behave like the highly trained military collectives that they are. When NPCs patrol as squads, they will cover one another and move logically through the spaces they are patrolling. If you run from an engagement, the AI will form two-person search teams from the fragmented group to systematically move throughout the area.
If you plan to charge into a room full of NPCs, you should think again. Your opponents will not stand around and get shot; they will move into covered firing positions, and you will quickly find yourself taking fire from several directions. The AI will maneuver to the most strategic positions to cover their squadmates and will lay down suppression fire for teammates moving into position to flank or charge you. Enemy soldiers will even advance and flip a table to create more cover for a squadmate to advance. They are not unbeatable, but squads of enemies demand a great deal of respect and will surprise you with their intelligence--and will perhaps educate you about the effectiveness of your decision making.
One of the coolest behaviors of the enemy soldiers is that they recognize dangerous areas. If a squadmate is killed in a position, an NPC will flag it as unsafe and avoid taking cover there. If you pin an opponent down behind his cover, he will not continually stick his head out in the same place for you to shoot at. Once pinned, he will either call for backup, blind fire over or around their cover, retreat, or attempt to move to different cover. NPCs will even wildly fire their guns with one hand in desperate attempts to cover themselves as they retreat. This dynamic reaction to adverse situations will keep you on your toes and make you constantly reassess your battle strategy on the fly.
The ability of the AI to dynamically react to you as a group and as an individual creates a rewarding atmosphere of tense uncertainty, and it keeps enemy engagements fresh and exciting throughout the game. You will never take the enemy for granted. The incredible immersiveness of this AI system is aptly demonstrated by a final quote from Jeff Orkin. "They take me by surprise... I can lose myself in the game and forget that it is my code working here."