Академический Документы
Профессиональный Документы
Культура Документы
REVIEW
Share This!
32 Tweet
Assaulting F.E.A.R.’s AI: 29 Tricks to Like
Arm Your Game
Alex J. Champandard on October 22, 2007
UPDATE 2015/01: Hello Reddit! The F.E.A.R. AI was a turning point in Game AI
Content Index
for its use of planning — but it's not "still current" in any way. Many games
Overall Approach
have taken planning further along with significantly improved underlying
1) AI Controls Only Movement and
systems for cover and pathfinding. Other games based on Halo's behavior tree Animation
approach have also shown that planning is rarely a sensible solution for 2) Annotate Animation for Other Behavior
Functionality
action/combat/shooters, and the industry has moved beyond those for a 3) Use Smart Objects
variety of reasons including design choices and production benefits. For games 4) Rely on Few Low-Level States
5) Understand Sources of Complexity in the
with amazing bots or enemies, see KILLZONE 2+, RAGE, SECTION 8: AI
PREJUDICE, TOMB RAIDER, THE LAST OF US, etc. 6) Reduce Complexity with a Planner
Team & Workflow
While the majority of first-person shooters are mere clones, every once in a 7) Have Only One AI Programmer!
8) Don’t Let Level Designers Script the
while one of them advances the state-of-the-art. F.E.A.R. is one of those Gameplay
games; not only is it highly entertaining, but it has been praised for its 9) Understand Academic Algorithms
Implementation
innovations in artificial intelligence. It ranked very highly on the Top 10 Most
10) Express World State as a Vector
Influential AI Games because of it. 11) Think Wisely about Variables and
Actions
This technical review from AiGameDev.com looks into the technology behind the 12) Use ActionSets as Configuration Tables
13) Employ Procedural Logic
game: things to equip your game with and what to stay away from. See Jeff 14) Design the System for Planning in One
Orkin’s page, or the references at the bottom of the article for more details. Frame
Memory and Knowledge
15) Design the Architecture around a
Blackboard
Overall Approach 16) Assign a Confidence to All Facts
17) Share Information Between Behaviors
At the core, F.E.A.R.’s AI engine is quite different from the traditional 18) Centralize Knowledge for Efficiency
and Convenience
hierarchical finite state machines.
19) Maintain World Knowledge from
Previous Actions
AI Design
20) Use Voice Communications to Create
Illusions
21) Keep Inter-Actor Communications
Realistic
22) Set-up Fallbacks for Most Behaviors
23) Use Costs Per Action to Help Designers
Fine-Tune Behaviors
24) Drive Different Behaviors with the
Same Technology
25) Employ Multiple Collaborating Goals
26) Add Actions and Goals Modularly as
Necessary
Group Behaviors
27) Squad Coordinators
28) Keep Squad Behaviors Simple
29) Use Emergent Squad Behaviors
References
Animation — Play a full body motion clip that may move the character
as a side effect.
These two tasks are all that’s required to implement behaviors involving the
characters, which simplifies things greatly.
“We assume the animation system has key frames which may have
embedded messages that tell the audio system to play a footstep
sound, or the weapon system to start and stop firing.”
Using this approach, the AI is greatly simplified, but of course it relies on the
animations being annotated correctly. Like any data-driven solution, changes
to the animations or annotations must be done in a mindful way.
1. Edit and store the animations along with the object itself.
As discussed in more detail during the technical review of The Sims, this helps
reduce the complexity of the development process.
F.E.A.R. is different from most games based on finite state machines (FSM) in
that it uses only two low-level states. This is possible because only because of
the simplification of animation and movement discussed above. As a result:
The two states have many parameters that cover all options.
Even if you have more behaviors than just animation and movement, keeping
these generic reduces the workload on the programmer.
“In F.E.A.R., A.I. use cover more tactically, coordinating with squad
members to lay suppression fire while others advance. A.I. only leave
cover when threatened, and blind fire if they have no better position.”
Since the states in F.E.A.R. have so many parameters, and the editing process
is becoming increasingly more difficult, a planner is used to automate the
solution. A planner works by analysing dependencies of each action, and
figuring out how to realize them:
“We can satisfy the goal of eliminating a threat by firing a gun at the
threat, but the gun needs to be loaded, or we can use a melee attack,
but we have to move close enough.”
One thing that distinguishes F.E.A.R. from other AAA titles is that there was
only one AI programmer. This was accepted, and used as the motivation to
develop better technology.
Thanks to that focus and serious prototyping, the development team managed
to build technology that reduced the effort required to build the many different
AI characters and squad behaviors.
The various studios have different perspectives on the roles of level designers.
At Monolith, they maintain the following philosophy:
This attitude puts more emphasis on the autonomous behaviors of the AI, and
at the same time, emphasizes the planning technology used in F.E.A.R.
Implementation
As with most algorithms that push the limits of what’s possible, you have to
take special care to get it running efficiently.
Traditionally, STRIPS planners maintain a list of facts about the world. Instead,
F.E.A.R. expresses this as a fixed vector of variables which are known at
compile time. This increases efficiency at the cost of flexibility. As Jeff Orkin
mentions:
“The fixed sized array does limit us though. While an A.I. may have
multiple weapons, and multiple targets, he can only reason about one
of each during planning, because the world state array has only one
slot for each.”
The best solution is to start with the minimal possible description of a state,
and only make additions carefully while monitoring performance. For F.E.A.R.,
the limits and necessary representations were determined this during
prototypes in pre-production.
“The soldier’s Action Set includes actions for firing weapons, while the
assassin’s Action Set has lunges and melee attacks.”
You can implement a lookup table and get the same benefits without using a
planner. All that’s required are fallbacks for behaviors that are not found in the
lookup table, and check that the AI still works if certain behaviors are not
present.
This provides the planner with a way to perform checks on-demand while
planning if it’s necessary to do so. This is done by calling a C++ function that’s
part of the Action class.
Because it’s critical for the AI to make decisions in a short and predictable
amount of time, the planner in F.E.A.R. is designed to complete by the time
the next frame is starting. To do this, a few tricks are employed:
Procedural checks allow the planner to check for information lazily only
when necessary.
Facts in the blackboard are made up of many attributes, including position with
direction, the type of fact, and the weight of the desire, etc. Each of these
attributes is given a confidence value normalized to fall in the range [0,1].
“For example someone could sit down at a desk and do some work.
The problem was that only the Work goal knew that the A.I. was in a
sitting posture, interacting wit the desk. When we shot the A.I., we
wanted him to slump naturally over the desk. Instead, he would finish
his work, stand up, push in his chair, and then fall to the floor. This
was because there was no information sharing between goals, so each
goal had to exit cleanly, and get the A.I. back into some default state
where he could cleanly enter the next goal.”
To handle this with a planner, the current animation state of the actor can be
used as input to the planner so it can figure out the best way to portray
“death” based on the situation.
AI Design
This trick relies on the players’ assumptions to enhance their experience. It’s a
human tendency to extrapolate and find patterns even if they are not explicitly
designed that way.
Thief in many ways pioneered the use of voice to help explain the AI
behaviors. But F.E.A.R. takes this further by designing it in a much more
“post-modern” fashion! Specifically:
One example Jeff uses from F.E.A.R. is reacting to grenade explosions. Only AI
actors that are near the explosion can ReactToDanger because the distance
precondition is satisfied, however, the AI actors that are further away instead
use LookAtDisturbance as the response to deal with the reaction since it has no
distance preconditions.
That said, it’s hard to control the outcome of the planner explicitly. Tweaking
weights is a fine art, and it’s hard to guarantee context-specific behaviors or
even ordering of actions.
What we are seeing is that these characters have the same goals, but different
Action Sets, used to satisfy the goals.
“If we place an assassin in the exact same level, with the same GDC06
Goal Set, we get markedly different behavior. The assassin satisfies the
Patrol and KillEnemy goals in a very different manner from the soldier.
The assassin runs cloaked through the warehouse, jumps up and sticks
to the wall, and only comes down when he spots the player. He then
jumps down from the wall, and lunges at player, swinging his fists.”
In F.E.A.R., the behaviors of the actors arise from having multiple goals
competing for activation. Specifically, these goals are KillEnemy, Dodge, Cover, and
Ambush. Each of these has built-in logic for determining when their priority based
on changes in the world.
“When the sensors detect significant changes in the state of the world,
the agent re-evaluates the relevance of his goals. Only one goal may
be active at a time. When the most relevant goal changes, the agent
uses the planner to search for the sequence of actions that will satisfy
the goal.”
Effectively, F.E.A.R.’s AI is a very modular system. The benefit here is that you
can easily add new actions and goals into the mix, and see what comes out.
“The primary point we are trying to get across here is that with a
planning system, we can just toss in goals and actions. We never have
to manually specify the transitions between these behaviors. The A.I.
figure out the dependencies themselves at run-time based on the goal
state and the preconditions and effects of actions.”
Group Behaviors
This approach with a central coordinator is easier to implement and debut than
just having the solders try to collaborate with each other locally.
The more complex squad behaviors in F.E.A.R. are entirely due to the
separation between individuals planning, and the squad logic. Again, in Jeff’s
words:
“The truth is, we actually did not have any complex squad behaviors at
all in F.E.A.R. Dynamic situations emerge out of the interplay between
the squad level decision making, and the individual A.I.’s decision Related Articles
making, and often create the illusion of more complex squad behavior
than what actually exists!” Teaming Up with Halo’s
AI: 42 Tricks to Assist
Your Game
References
[1] 3 States & a Plan: The AI of F.E.A.R. Sneaking Behind Thief’s
Orkin, J. AI: 14 Tricks to Steal for
Your Game
Game Developer's Conference Proceedings, 2006
(Download DOC, 704Kb)
Living with The Sims’ AI:
[2] Agent Architecture Considerations for Real-Time Planning in Games 21 Tricks to Adopt for
Your Game
Orkin, J.
AIIDE Proceedings, 2005
(Download PDF, 151Kb)
Discussion 7 Comments
If you'd like to add a comment or question on this page, simply log-in to the
site. You can create an account from the sign-up page if necessary... It takes
less than a minute!