Behavior Trees For Computer Games
Behavior Trees For Computer Games
net/publication/312869797
CITATIONS READS
32 9,444
1 author:
Yoones A. Sekhavat
Tabriz Islamic Arts University
65 PUBLICATIONS 700 CITATIONS
SEE PROFILE
All content following this page was uploaded by Yoones A. Sekhavat on 28 June 2021.
Yoones A. sekhavat∗
Faculty of Multimedia, Tabriz Islamic Art University, Hakim Nezami Square, Azadi Blvd,
Tabriz, 51647-36931, Iran
[email protected]
Although a Finite State Machine (FSM) is easy to implement the behaviors of None-
Player Characters (NPC) in computer games, it is difficult to maintain and control the
behaviors with increasing the number of states. Alternatively, Behavior Tree (BT), which
is a tree of hierarchical nodes to control the flow of decision making, is widely used in
computer games to address the scalability issues. This paper reviews the structure and
semantics of BTs in computer games. Different techniques to automatically learn and
build BTs as well as strengths and weaknesses of these techniques are discussed. This
paper provides a taxonomy of BT features and shows to what extent these features are
taken into account in computer games. Finally, the paper shows how BTs are used in
practice in the gaming industry.
1. Introduction
Activities associated with Artificial Intelligence (AI) in computer games are de-
signed for behaviors of Non-Player Characters (NPC). Defining a logic for various
entity characters in computer games is an important issue in the design of a game
that specifies how these characters behave and react against different conditions.
Providing an easy to use AI component that is general enough to provide a game
designer the ability to specify complex behaviors is crucial.
Rule-based systems are the simplest and fairly limited to control the behavior, in
which the behavior of a NPC is a simple function of present conditions. Generally, a
rule-based system consists of a knowledge-base and a set of if-then rules available to
an AI agent. Rules are examined against knowledge-base to check if conditions are
met. Rules are triggered and executed when the conditions are met.1 For example,
∗ Yoones A. Sekhavat is an assistant professor in faculty of Multimedia, Tabriz Islamic Art Univer-
sity. He holds a PhD in Computer Science from Memorial University of Newfoundland, Canada. He
also holds a post-doc from University of Alberta in Canada. He is the head of cognitive augmented
reality lab (www.carlab.ir).
1
October 31, 2016 13:46 WSPC/INSTRUCTION FILE IJAIT-D-16-00092
2 Yoones A. Sekhavat
a http://pacman.com
October 31, 2016 13:46 WSPC/INSTRUCTION FILE IJAIT-D-16-00092
Second, unlike FSM that requires considering all states and transitions to make a
change in the state of an agent, in a BT, this is performed just by modifying the
tasks around or adding a new parent. Moreover, BT is more flexible than FSM.
The only way to run two different states with FSM is creating two separate FSMs.
However, simultaneous execution of two behaviors can be easily handled in behav-
ior trees using parallel nodes. An AI designer may also want to prevent to run two
tasks at the same time. For example, suppose you have two different tasks that
play a sound effect and they could potentially play the sound effect at the same
time. There is no way in FSM to prevent the simultaneous running of these two
sound effects. However, adding guard nodes to behavior trees (a semaphore task
that allows only one active instance) makes it possible to play only one sound effect
at a time.
This paper reviews various issues regarding BTs in computer games. As shown
in Table 1, this paper classifies the study of BTs in four basics categories includ-
ing Basics of BTs, Forming BTs, BT Extension and BT Application. In the basics
of BTs, formal definitions and semantics of behavior trees in computer games from
different perspectives are discussed. In the context of forming behavior trees, auto-
matic and manual techniques to facilitate the forming of behavior trees are reviewed
for NPCs in computer games. In terms of BT extension, techniques to modify the
structure of behavior trees as well as methods to augment behavior trees with ad-
ditional knowledge to increase the expressiveness of behavior trees are discussed. A
list of features are proposed by which the strengths and weaknesses of these tech-
niques are compared. Finally, This paper shows show how BTs are used in practice
to implement decision making in research prototypes and commercial games.
Algorithms designed for sequential decision making problems with multiple goals
are discussed in several surveys4 including probabilistic inference techniques for
scalable multi-agent decision making,5 and decision making with dynamic uncertain
events6 . However, none of these techniques takes into account the specific aspects
of decision making for NPCs in computer games.
4 Yoones A. Sekhavat
Table 1: Classification of research issues for behavior trees in computer games in-
cluding supporting papers in each category.
Basics of BTs Formal Representation Behavior Tree Semantics
of BTs
[1], [2], [3], [4], [7], [8], [9], [13], [14], [15], [16], [17], [18],
[10], [11] [19]
Forming BTs Automatic Techniques Manual Techniques
Machine Learning: [20], [21], Facilitating tools: [36], [37]
[22], [23], [24], [25], [26]
Case-Based Reasoning: [27],
[28], [29]
BT Extension Modification in the Augmenting BTs with
structure of BTs Additional Knowledge
[38], [39], [40], [41], [42], [43], [47], [48], [49], [58], [51], [57],
[54], [55], [56], [44], [45], [50], [59], [60], [61], [28], [78], [79]
[52], [53], [80], [3], [46]
BT Application [29], [62, [63], [3], [64], [65], [66], [68], [69], [21], [70], [59],
[71], [10], [72], [73], [74], [75], [14], [76], [77]
and execute the first possible child that can run without failure. A selector node
succeeds once any child is performed successfully. In a sequence node, all nodes are
evaluated sequentially. A sequence node succeeds only if all children are performed
successfully. On the other hand, a leaf node can be an action or a condition. Action
nodes include playing an animation, changing the state of a character, or any activity
that changes the state of the game. On the other hand, a condition node is generally
used to test some values. Tests for proximity, testing the state of a character and
testing the line of sight are examples of condition nodes. A condition returns success
if the condition is met; otherwise, returns failure.
An example of a behavior tree including a selector node (i.e., root represented by
?), two sequence node (i.e., two children of the root represented by →), a condition
node (Is door open?) and 4 action nodes (move into room, move to the door, open
door and move into room) are shown in Fig. 1. Using the depth-first search to run
the behavior tree in this figure, the first node selected to run is “is door open?” if
the door is open, it returns success. Then, the sequence task moves on to its next
child, which is “move into room”. If this action succeeds, the whole tree returns
a success and execution is done. In the case if the door is closed, or “move into
room” returns failure, the second sequence node is tried staring from the “move
into door”. The tree will return success if all children of the second sequence node
return success.
In addition to the core nodes, behavior trees are also extended with decorator
and parallel nodes. Adapted from the “Decorator” design pattern in software en-
gineering, a decorator node in behavior tree is a node that has a single child task.
A decorator node can be used for filtering which makes a decision to allow a child
behavior to run “until fail”. A decorator node may also be used to limit the number
of runs. On the other hand, parallel nodes provide some sort of concurrency in BTs.
October 31, 2016 13:46 WSPC/INSTRUCTION FILE IJAIT-D-16-00092
→ →
Is door Move into Move into Open Move into
Open? room door door room
Fig. 1. A behavior tree including selector, sequence, condition and action nodes
A parallel node is used when there are actions that must be run concurrently with
other actions (e.g., playing a move animation while actually moving from one place
to another). Some commercial products such as RAINb are also extended with Pri-
ority node (that allows setting priority both in run time and start time) and Custom
Action node (that allows defining a decision specific to a game).11 A node in a be-
havior tree can be as simple as checking the value of a variable, or as complex as
executing an animation. Arbitrary conditions and actions can be combined together
to form a behavior tree.
Sharing data between tree nodes is an important feature of BTs that makes
it possible to handle complex behaviors. In the case of the lack of data sharing
between nodes, we may form a big behavior tree with separate branches for each
option, which can be wasteful. The best approach to implement this option is by
decoupling the tasks from the data that behaviors need. This can be achieved by
employing an external repository to save all data that a behavior tree needs, which
is called “blackboard”. A blackboard can store any data that can be queried by any
task node.
Once a behavior tree is executed, the root of the tree is ticked in each time step of
the control that results in propagating down the tree. When this tick reaches a leaf
node, some states or variables of the BT are affected. Once a node representing a
task is executed, the return value is success, fail or running. The root node branches
down to some nodes until leaf nodes are reached.
b http://rivaltheory.com
October 31, 2016 13:46 WSPC/INSTRUCTION FILE IJAIT-D-16-00092
6 Yoones A. Sekhavat
child that has most recently returned running can be employed.12 Every time the
selector or sequence returns success or failure, this variable is initialized. Algorithm
5 and Algorithm 6 show different implementations of sequence and selector nodes,
respectively, using this modification.
8 Yoones A. Sekhavat
state that can be accessed by NPCs. Different actions of an agent can change these
variables, representing the need for having a separate context for each tree assigned
to an agent.
c http://nodecanvas.com/comparison
October 31, 2016 13:46 WSPC/INSTRUCTION FILE IJAIT-D-16-00092
10 Yoones A. Sekhavat
Table 3: A taxonomy of techniques to form behavior trees including the main fea-
tures, strengths (+) and the weaknesses (-) of these techniques.
Genetic Algorithms + Automatically evolving BTs
+ Different genetic algorithm can be used to each part
- Initial set of BTs are required
- Genetic Algorithms does not necessarily result in better
behavior tree in all cases
CBR + Allows to extract behaviors from a knowledgebase
+ Nodes are enhanced with querying functionality
+ behaviors are considered as patterns that can be reused
- Performance of reasoning is the main problem of this tech-
nique
Q-Learning + Makes it possible to decide when is the right time to exe-
cute AI logic
+ allows debugging BTs
+ Allows to optimize behavior trees
+ This technique cannot be used to make plans
- This technique suffers from performance issues
Learning Examples + Quickly reacts to changes at runtime
+ The generated BT summarizes a large amount of expert
knowledge
+ Employs hierarchical Machin Learning to model player
behavior
+ The tree can make nondeterministic decisions based on
samples
- The initial set of behaviors significantly changes the final
tree
BT Generation - This is still the game programmer who should implement
programming classes
- The scalability as well as the complexity of communications
between the game world and the behavior tree authoring tool
are unanswered questions
12 Yoones A. Sekhavat
evolution since they provide a natural way of manipulating BTs and applying ge-
netic operators.25 They tested their technique on Mario AI benchmark to simulated
autonomous behavior of the characters. BT crafting algorithm can be initialized
with a BT that is created manually26 , where behaviors can be used to control flying
robots, while the BT is evolved in every experiment.
As an example of a mapping process given the grammar in Fig. 2, and the
string (4, 5, 3, 6, 8, 5, 9, 1), the final program will be moveRight; if (enemyAhead),
then shoot. More specifically, the first value (4) is used to select from the start
symbol hBT i based on the formula 4%2 = 0. Thus, the first expression, which is
hBT i hN odei is selected. Accordingly, using 5%2 = 1, hBT i is replaced by hN odei,
that consequently results in hN odeihN odei. In the same way, hActionihN odei is
generated from 3%2 = 1, and moveRight; hN odei is generated from 5%2 = 1.
Case Based Reasoning. In Case-Based Reasoning (CBR) technique,27 prior ex-
perience is employed to solve new problems. For example, CBR28 is used to extract
behaviors from a knowledge base. In this technique, behavior nodes are enhanced
with querying functionality. Being in a state allows the node to query the knowl-
edge base for cases of similar states that are visited in the past, and consequently,
selecting the best behavior. In the manual editing of behavior trees for Non-Player
Characters (NPCs)29 , the main idea is that behaviors typically occur in patterns
that can be reused in future designs. In this technique, CBR is used to retrieve and
reuse behaviors that are already represented as behavior trees. In this technique,
the behavior of a NPC is built at run time using CBR.
CBR can be used in BTs to extract behaviors from a knowledge base21 . In this
technique, CBR is known as solving new problems based on prior experience.27
In this method, an NPC in a particular state will cause the node to query the
knowledge base for similar states that are already processed in order to load an
appropriate behavior.
Q-learning. In Q-learning behavior trees2 , AI designer is guided by indicating
when is the right time to execute branches of AI logic. This technique also facil-
itates the AI design procedure by debugging, analyzing and optimizing behavior
trees. Originally, in the Q-Learning30 algorithm, a table of values are generated
and stored representing the utility of taking an action in a state. In this algorithm,
there are associations between different states and rewards. Rewards are feedback
October 31, 2016 13:46 WSPC/INSTRUCTION FILE IJAIT-D-16-00092
to state-action pairs, where utility estimates are improved. In the training phase,
this algorithm saves Q-values for visited states. Updates are conducted based on
this formula:
Q(s, a) = (1 − α)Q(s, a) + α(r + γ maxa (Q(s0 , a0 )))
where Q(s, a) and Q(s0 , a0 ) are the q value of the current state and the successor
state-action pairs, respectfully. α is the learning rate parameter representing how
much the new data affects the previous data in q value. r represents the rewards
for the successor state. In this formula, γ is the discount factor specifying the im-
portance of future rewards. Determining which action is selected for an agent is
performed using a greedy policy, in which the action which is estimated as the
best action is selected.2,31,32 Although learning probabilistic behavior models,31,32
require little domain knowledge, they cannot be used to build plans. Deepest se-
quence nodes from an initial behavior tree can be extracted, where such nodes are
employed in an off-line Q-learning phase to generate a Q-value table.31 Then, sub-
tables from this table are generated. The highest valued states for the action are
extracted into Q-Condition nodes. Then, condition nodes are replaced with the Q-
Condition nodes. The final step is reconstructing of the organization of BT through
sorting children nodes based on maximum Q-value.
Learning from Examples. Domain knowledge can be learned from examples of
behaviors,33 which can quickly react to changes at runtime. The knowledge learned
is shown in the form of a behavior tree. Formally, given a set of examples of a
high-level task, {E1 , E2 , . . . , En }, in which an example is a sequence of cases Ei =
(Ci1 , Ci2 , . . . , Cim ), where a case is an observation and action pair Cij = (Oij , Aij ),
a similarity metric between pairs of observations and pairs of actions, M (Oij , Okl ) ∈
[0, 1], and M (Aij , Akl ) ∈ [0, 1]. This technique aims to extract policies that predict
the next action given previous cases and the current observations. This way, the
behavior tree can show and summarize a large amount of expert knowledge from this
behavior. The procedure starts with identifying areas of commonality within action
sequences, as they show common sub-behaviors. To achieve this goal, a maximally
specific BT is generated using samples of case sequences. Then, the BT is pruned
and reduced by merging common patterns of actions. This continues until no new
pattern is found.
Automatically modifying behavior trees designed by AI designer can be taken
into account in order to display characteristics of human players.34 This starts
with a deterministic behavior tree in a multi-player online role-playing game. This
technique learns behavior trees that employ human player traces as well as a human-
designed tree to cover the variations. In particular, hierarchical machine learning
approaches are used to model the behaviors of player. In this technique, a given
deterministic behavior tree is adapted to cover a range of observed human behaviors.
To this end, an agent controlled by the behavior tree in the game is synchronized
with observations from a human player traces. The agent is continuously updated by
October 31, 2016 13:46 WSPC/INSTRUCTION FILE IJAIT-D-16-00092
14 Yoones A. Sekhavat
→
Generate At
Path
Loop Target
Set Learn on
wayPoint Success
Move
Fig. 3. Refining the behavior tree using the learning technique [35].
observations. The generated tree makes it possible to produce most of the observed
behaviors, while storing contextual observations representing the conditions for each
variation. This way, the tree can make non-deterministic decisions based on the
samples.
Machine learning can be used to refine a single behavior within the context
of other behaviors.35 This is implemented using a decorator node (a node used to
control and modify return values). Given the behavior tree in Fig. 3, when the Move
node returns Success (representing that the agent has traversed the wayPoint), a
learning routine is called on a modified Waypoint behavior. In the training phase,
an agent is initialized with this tree and data about traverses of players. Quadruple
(L, E, F, M ) shows the learning method, where L is the set of possible locations,
E is the error function (between current location set by the behavior l1 and the
current location actually traveled l2 ), F returns a set of environmental features and
M is a learning model. When the model is trained, the set of wayPoint behaviors
is perturbed based on the probabilities learned by M . This way, more human-like
behavior is created.
Multiple Goals
Probabilistic
‐ A tree is designed such that Behavior Tree
follows more than one goal ‐ Increase in the expressiveness of
simultaneously the behaviors
‐ Introduces meta behaviors are ‐ Transition form one node to
able to change the state of other another node is annotated with
Integrating BTs with behaviors at runtime probabilities
Utility‐based AI
‐ Utility Score indicates when to
move from one node to another
‐ Decisions are measured based Modification in the
on probabilities that are structure of behavior tree
calculated
‐ Among multiple choices, the one Augmenting BTs with
with highest utility is selected Additional Knowledge
Timed Behaviors ‐Multiple branches can integrate and run at
the same time
‐ Different clocks are added to the ‐ Makes it possible to follow conflicting goals
behavior tree ‐ Allows to assign different priorities to
‐ Delay time to each node can be nodes
assigned
BTs and utility-based AI. In a technique to combine behavior tree and utility-
based AI,38 an architecture is proposed to design realistic bots for military sim-
ulators. The most important requirement of a military simulator is designing an
October 31, 2016 13:46 WSPC/INSTRUCTION FILE IJAIT-D-16-00092
16 Yoones A. Sekhavat
enemy acting like a human enemy. In this framework, each level of a behavior tree
corresponds to a different state, where utility-based AI39,41,40 is used to decide how
the state goes in from one transition in a level to another. In addition to the selector
node in the original behavior tree that chooses one event at a time, reasoned nodes
are used to calculate the probability of many events at a time.38 Then, on the basis
of their values, one event is chosen. Reasoner is a complex composite that dynam-
ically calculates probabilities, which on this basis the choices are made.42 In this
setting, instead of a single correct choice, there may exist multiple choices, where
one of which is selected based on external factors. The probabilities of options are
given based on f (x) = e−x , where x = α ∗ threat + β ∗ health + γ ∗ ammo, and α,
β and γ are normalizing factors. The response is aggressive as this function is not
a linear function. In the case of having more health and ammunition, much more
aggressive actions are taken. As an example, suppose once an enemy is detected,
the AI goes into the attack mode including fire (f(x)) and go to cover (1-f(x)).
Increasing the threat results in increasing the probability of going to go to cover
option. Computing the probabilities of each option is based on computing utility
functions. Given ui denoting the option i, the probability of option i is calculated
Pn
as P = ui / i=1 (ui ).
Behavior trees are extended with utility-based AI,43 in which scores (ranging
from 0 to 100) are assigned to each action using utility-based AI. There is a threshold
that results in interrupting the current action execution when the score of an action
exceeds this threshold. This results in suspending an action to make it possible for
the execution of urgent actions.
Component Reasoner54 , which is a modular and hierarchical decision-making
technique, has some similarities with the structure of Behavior Tree (BT). In addi-
tion to supporting many decision-making approaches, Component Reasoner relies
primarily on Weight-Based Reasoners such as a utility-based technique. This tech-
nique is used in video games such as Zoo Tycoon 2 franchised , Iron Mane , and Red
Dead Redemptionf . Originally, behavior trees use boolean discriminators to run se-
lectors. Although this is simple to develop, examining a complex situation may not
be possible before making a decision.55 There are cases in which a more complex ap-
proach to decision-making is required, while making it possible to keep simplicity in
simple decision-making situations. This was a motivation for a technique54 to pro-
pose a framework that keeps the hierarchy and modularity of behaviors trees, where
it is possible to use complex decision makers when it is appropriate. Reasoners54
instead of selectors can be used to make such decisions.
While selectors employ simple logics such as following the first valid option
or fixed probabilities (that are computed at design time) for decision-making, a
reasoner allows using any arbitrarily complex logic. This way, highly deterministic
d https://www.bluefangsolutions.com/
e https://www.gameloft.com
f http://www.rockstargames.com
October 31, 2016 13:46 WSPC/INSTRUCTION FILE IJAIT-D-16-00092
behaviors can still use a BT-style selector, while in the cases it is required to compute
relative advantages of several possibilities, Component Reasoner is used. In the cases
when AI agents need to learn from past results, Genetics-Based Machine Learning56
techniques can be employed.
Timed Behaviors. BTs can be extended by a time notation44 (based on the
concepts used in timed automata45 ). This is conducted in a way that different clocks
are added to behavior trees such that they work simultaneously. The clocks include
a constraint indicating how long the process can delay after taking an action. The
authors also provided a formal semantics for timed behavior trees. In a timed BT,
standard BT nodes (e.g., selection and sequence) are augmented with clock reset
(for state realization), clock guard (that restricts the timing of a transition from
one location to the next), and invariant (a constraint on how long the process can
delay after taking an action).
Probabilistic Behavior Trees. Current syntaxes for behavior trees do not have
an option to represent probabilistic behaviors.50 . In a technique to extend BTs,50
probabilistic behavior is expressed, which results in increasing the expressiveness
of behaviors. This technique, which is called probabilistic timed Behavior Trees
(ptBTs), makes it possible for AI designers to model timed as well as probabilistic
behaviors. In this technique, transitions are annotated with a probability indicating
the probability of taking place of that transition. In particular, each node is associ-
ated with an optional probability (between 0 to 1). Probabilistic branching is used
in addition to concurrent branching. The sum of probabilities in the child nodes is
less than or equal to 1. In this setting, given p as the sum of probabilities of a node,
no transition is taken with the probability of 1 − P .
Multiple Goals. Because behavior trees are designed to control the behav-
iors of a single unit, using them to simultaneously processing of multiple goals is
complicated.52 In a game agent (EISBot)52 , ABL (A Behavior Language)53 is used
as a reactive planning language that includes a set of agents, where each agent must
deal with a set of goals to achieve (e.g., Fig. 5). In order to achieve goals, agents
choose and execute a behavior from behaviors collection, where a behavior is a set
of preconditions specifying if this behavior can be run in the current conditions.
This technique supports meta behaviors, which are known as behaviors that can
change the state of other behaviors at runtime. This makes it possible for an agent
to deal with multiple goals simultaneously, while allows communications between
behaviors. At runtime, all of the goals of an agent are stored in an active behav-
ior tree, where in each execution, one of the open leaf nodes (which is a behavior
that follows a goal and includes component steps) are executed (i.e., scripts to run
actions or to compute).
In an architecture to control the behaviors of AI agents80 , responsive, collabora-
tive, interruptible and resumable behaviors based on behavior queues are supported.
In this technique, behaviors are assigned to roles in order to encapsulate behaviors
October 31, 2016 13:46 WSPC/INSTRUCTION FILE IJAIT-D-16-00092
18 Yoones A. Sekhavat
Root
Goal 1 Goal 2
→→
→ →→
Fig. 5. A tree with multiple goals. Goal 1 and Goal 2 are continued with sequential and parallel
behaviors, respectively.
that integrates state machines within behavior trees. This technique is compatible
to existing behavior tree libraries48,49 . In this technique, state machines are inte-
grated into arbitrary behavior trees. This way, the full power of state machines are
available for AI designer in addition to standard features of BTs. In this technique,
state machine are clocked, where there are delays in the control flow. Time events
are used in this technique for long term mission statements.
Classic behavior trees suffer from the problem that all states in a behavior are
lost once the behavior is removed.58 One solution would be adding a separate per-
manent component to an NPC, where the behaviors can access to this component.
One alternative general solution is allowing to store persistent data class specific
to the behavior. However, the hard-coded structure of the behavior trees do not
provide modularity options such as programming. To address the problem of two
NPCs of the same type that behave differently, a parameter can be added to the
parent behavior to store the states of behaviors.58
Emotional Factor. Emotion is an important factor for human in decision-making,
that allows choosing among alternative solutions.51 Although emotions are integral
parts of decision-making, current behavior trees are not integrated with emotions.
Behaving in an emotional way is key to have a natural human behavior. In a tech-
nique to extend behavior trees with emotions,51 an AI designer indicates which
October 31, 2016 13:46 WSPC/INSTRUCTION FILE IJAIT-D-16-00092
20 Yoones A. Sekhavat
behaviors can be affected by emotional factors. They argue that time discounting,
risk perception, and planning are affected by emotions. They proposed a new selec-
tor composite called emotional selector, in which emotions are used to change the
priorities of child nodes at runtime. In the emotional selector, the values for time,
risk, and planning are computed and attached to each child of the emotional selec-
tor. The overall weight of the child node i of emotional selector node is computed
as: Wi = α.Wrisk,i + β.Wtime,i + γ.Wplan,i , where α, β and γ are importance factors
of the parameters. After sorting child nodes of the emotional selector node based
on increasing weights Wi , a probability probi to every child node i is assigned such
that: probi = a(1 − a)i − 1), where 0.5 ≤ a < 1.
Behavior Tagging. In order to handle complex variations of behaviors, a behav-
ior organizing structure similar to behavior trees is proposed.57 In this technique,
behavior tags and behavior messages are used to manage behaviors of virtual char-
acters. The idea for behavior tag is to maintain specific factors in the behavior in
terms of tags, which are ignored when a tree is customized. On the other hand,
behavior messages are used to inform the changes regarding the behaviors. Instead
of representing this in a static behavior tree structure, messages are dynamically
issued to a specific behavior node during the execution of the behavior tree.
Hinted Execution Behavior Trees. Hinted Execution Behavior Tree (HeBTs)59
is proposed as an extension to BT that provides more controls for developers to
create and test new features in a plug-in fashion. In this technique, a hint is a piece
of information tells the AI what to do. However, the AI itself decides if it should
accept the suggestion. HeBTs allow generating low-risk prototypes of behavior trees
in a way that allows teams to try new ideas at final stages of development without
hard changes in the code.
Dynamic Behavior Trees. A technique to extend behavior trees is proposed
called Dynamic Behavior Trees (DBT)28 , in which some nodes hold queries instead
of actual behaviors. A DBT is generated at runtime through substituting query
nodes with actual behaviors. This allows an AI designer to specify high level be-
haviors. This way, properties of the desired behavior for a given state is specified
without behavior implementation. In this technique, new basic behaviors are auto-
matically selected such that they best fit to designers specifications.
Self-Validating Behavior Trees. In an architecture for a BT that employs
modules with reflection capabilities,60 it is possible to detect faulty BTs during the
design of a behavior tree. This provides an extra check to design BTs. A similar
method is also used at runtime such that the reflective components is used before
BT execution. In the application of parameterization in behavior trees,61 , BT tasks
are functions with parameters in comparison to classic behavior trees, where tasks
are nonparametric. In this technique, a subtree is encapsulated with an exposed
parameter interface by a lookup node.
A model reducing technique for behavior trees78 can be applied before model
October 31, 2016 13:46 WSPC/INSTRUCTION FILE IJAIT-D-16-00092
checking for the purpose of reducing time and memory resources at runtime. This
model reducing technique is developed based on the slicing79 technique, which is
originally used to help understanding and debugging programs.
g http://angryant.com/behave/
h http://rivaltheory.com/wiki/behaviortrees/behaviortreeeditor
i https://www.unrealengine.com/
j http://cryengine.com/
October 31, 2016 13:46 WSPC/INSTRUCTION FILE IJAIT-D-16-00092
22 Yoones A. Sekhavat
havior tree (EvDBT). An EvDBT includes data regarding all the compared DBTs,
where the evolution information is represented.
BRAINSk is an open-source behavior tree component employed in different types
of games including action, tactical, and stealth games. This component exploits
UDK AI and Navigation, Unreal script for Behavior Tree Hierarchies, and Kismet
as a Visual Editor. This BT is currently used in SanctityLost. Think is an AI be-
havior tree editor that can be configured and used for different types of projects.
AI designers can create their own custom behavior tree nodes with custom proper-
ties. Such user defined nodes are integrated to create behavior trees. This makes it
possible to reuse tree nodes for future projects. The behavior tree can be exported
as XML, text, C++ code and Unreal Script code.
BSTl (Behavior Selection Tree) is a tool to create and manage behavior trees in
CryENGINE3. AI agents have their own BST, which is used to choose a behavior
based on game conditions. Brainiacm is a visual behavior tree design tool that
makes it possible to build behavior trees employing drag and drop of nodes. This
tool allows exporting the behavior trees in XML format. The game designer writes
her own code to generate logic for the trees.
ComBEn is a behavior tree editor that allows an AI designer to simultaneously
edit the trees using textual and graphical items. RAIN’s behavior treeo supports
simple to complex decision-making process. This component provides a graphical
editor to design behaviors and add different actions, animations, and sensing fea-
tures. This behavior tree component is widely used in Unity game engine.
The pervasiveness of mobile devices as well as the growth in the technologies of
application development is driving games market faster than before. Revenue from
games is now surpassing revenue from movie sales 81,82,83 . Entering to this market
requires employing powerful AI tools to make advanced games. Behavior trees by
providing facilities to define complex behaviors make it possible to design believable
non-player characters.
6. Conclusion
Behavior trees have become essential to design, control and monitor of NPCs in
computer games. The paper presents a survey of literature for techniques to au-
tomatically and manually generate behavior trees. This paper also reviews various
techniques to extend and enhance the structure of behavior trees with the aim of
increasing the modularity, reusability, dynamic control of trees, and flexibility in
the design of behaviors. This paper presents a list of features to compare BTs and
classifies BTs based on these features. This classification provides a benchmark to
k https://www.epicgames.com/
l http://www.cryengine.com
m http://www.brainiac.codeplex.com/
n http://www.oskarvanrest.github.io/ComBE/
o http://www.rivaltheory.com/
October 31, 2016 13:46 WSPC/INSTRUCTION FILE IJAIT-D-16-00092
24 Yoones A. Sekhavat
References
1. Millington, I. (2009). Artificial Intelligence for Games. J. Funge (Ed.). Elsevier Science
and Technology.
2. Dey, R., and Child, C. (2013, August). Ql-bt: Enhancing behaviour tree design and
implementation with q-learning. In Computational Intelligence in Games (CIG), 2013
IEEE Conference on (pp. 1-8). IEEE.
3. Colledanchise, M., and Ogren, P. (2014, September). How Behavior Trees modularize
robustness and safety in hybrid systems. In Intelligent Robots and Systems (IROS
2014), 2014 IEEE/RSJ International Conference on (pp. 1482-1488). IEEE.
4. Roijers, D. M., Vamplew, P., Whiteson, S., and Dazeley, R. (2013). A survey of multi-
objective sequential decision-making. Journal of Artificial Intelligence Research.
5. Kumar, A., Zilberstein, S., and Toussaint, M. (2015). Probabilistic inference techniques
for scalable multiagent decision making. Journal of Artificial Intelligence Research,
53(1), 223-270.
6. Kalech, M., and Reches, S. (2015). Decision making with dynamic uncertain events.
Journal of Artificial Intelligence Research, 54(1), 233-275.
7. Robertson, G., and Watson, I. (2014). A review of real-time strategy game AI. AI
Magazine, 35(4), 75-104.
8. Rizzo, P. (1999). Goal-based personalities and social behaviors in believable agents.
Applied artificial intelligence, 13(3), 239-271.
9. Rodrigues, R. A., de Lima Bicho, A., Paravisi, M., Jung, C. R., Magalhaes, L. P., and
Musse, S. R. (2010). An interactive model for steering behaviors of groups of characters.
Applied Artificial Intelligence, 24(6), 594-616.
10. Ogren, P. (2012, August). Increasing Modularity of UAV Control Systems using Com-
puter Game Behavior Trees. In AIAA Guidance, Navigation and Control Conference,
Minneapolis, MN.
11. Bennett, C., and Sagmiller, D. V. (2014). Unity AI Programming Essentials. Packt
Publishing Ltd.
12. Marzinotto, A., Colledanchise, M., Smith, C., and Ogren, P. (2014, May). Towards
a unified behavior trees framework for robot control. In Robotics and Automation
(ICRA), 2014 IEEE International Conference on (pp. 5420-5427). IEEE.
13. Winter, K. (2004, April). Formalising behaviour trees with CSP. In IFM (pp. 148-167).
14. Colvin, R. J., and Hayes, I. J. (2011). A semantics for Behavior Trees using CSP with
specification commands. Science of Computer Programming, 76(10), 891-914.
15. Hoare, C. A. R. (1978). Communicating sequential processes. Communications of the
ACM, 21(8), 666-677.
16. Roscoe, B. (1998). The theory and practice of concurrency.
17. Eugster, P. T., Felber, P. A., Guerraoui, R., Kermarrec, A. M. (2003). The many faces
of publish/subscribe. ACM Computing Surveys (CSUR), 35(2), 114-131.
18. Kim, S. K., Myers, T., Wendland, M. F., and Lindsay, P. A. (2012). Execution of
natural language requirements using State Machines synthesised from Behavior Trees.
Journal of Systems and Software, 85(11), 2652-2664.
19. Colvin, R., and Hayes, I. J. (2010). A semantics for Behavior Trees (No. SSE-2010-03,
pp. 1-26).
20. Lim, C. U., Baumgarten, R., and Colton, S. (2010). Evolving behaviour trees for the
October 31, 2016 13:46 WSPC/INSTRUCTION FILE IJAIT-D-16-00092
26 Yoones A. Sekhavat
41. Dill, K., and Mark, D. (2012). Embracing the Dark Art of Mathematical Modeling in
AI. In Game Developers Conference.
42. van Lent, M., and Laird, J. (1998). Developing an artificial intelligence engine. Ann
Arbor, 1001, 48109-2110.
43. Othman, M. N. M., and Haron, H. (2014, September). Implementing game artificial
intelligence to decision making of agents in emergency egress. In Software Engineering
Conference (MySEC), 2014 8th Malaysian (pp. 316-320). IEEE.
44. Colvin, R., Grunske, L., and Winter, K. (2008). Timed behavior trees for failure mode
and effects analysis of time-critical systems. Journal of Systems and Software, 81(12),
2163-2182.
45. Bengtsson, J., and Yi, W. (2004). Timed automata: Semantics, algorithms and tools.
In Lectures on Concurrency and Petri Nets (pp. 87-124). Springer Berlin Heidelberg.
46. Pedica, C., and Vilhjlmsson, H. H. (2012, August). Lifelike interactive characters with
behavior trees for social territorial intelligence. In ACM SIGGRAPH 2012 Posters (p.
32). ACM.
47. Klckner, A. (2015). Behavior Trees with Stateful Tasks. In Advances in Aerospace
Guidance, Navigation and Control (pp. 509-519). Springer International Publishing.
48. Elmqvist, H., Gaucher, F., Mattsson, S. E., and Dupont, F. (2012, September). State
machines in modelica. In Proceedings of 9th International Modelica Conference, Mu-
nich, Germany, September (pp. 3-5).
49. Klckner, A., van der Linden, F., and Zimmer, D. (2014). The Modelica BehaviorTrees
Library: Mission planning in continuous-time for unmanned aircraft. In Proceedings of
the 10th International Modelica Conference (No. 96, pp. 727-736).
50. Colvin, R., Grunske, L., and Winter, K. (2007, January). Probabilistic timed behavior
trees. In Integrated Formal Methods (pp. 156-175). Springer Berlin Heidelberg.
51. Johansson, A., and Dell’Acqua, P. (2012, September). Emotional behavior trees. In
Computational Intelligence and Games, 2012 IEEE Conference on (pp. 355-362). IEEE.
52. Weber, B. G., Mawhorter, P., Mateas, M., and Jhala, A. (2010, August). Reactive
planning idioms for multi-scale game AI. In Computational Intelligence and Games
(CIG), 2010 IEEE Symposium on (pp. 115-122). IEEE.
53. Mateas, M. (2002). Interactive drama, art and artificial intelligence.
54. Dill, K., and Martin, L. (2011). A game AI approach to autonomous control of virtual
characters. In Proceedings of the 2011 Interservice/Industry Training, Simulation, and
Education Conference.
55. Dill, K. (2008). Embracing declarative AI with a goal-based approach. AI Game Pro-
gramming Wisdom, 4, 229-238.
56. Harrison, G. A., and Worden, E. W. (2007, July). Genetically programmed learning
classifier system description and results. In Proceedings of the 9th annual conference
companion on Genetic and evolutionary computation (pp. 2729-2736). ACM.
57. Li, L., Liu, G., Zhang, M., Pan, Z., and Song, E. (2010). BAAP: a behavioral ani-
mation authoring platform for emotion driven 3D virtual characters. In Entertainment
Computing-ICEC 2010 (pp. 350-357). Springer Berlin Heidelberg.
58. Alt, G. (2004). The suffering: A game AI case study. In Challenges in Game AI
workshop, Nineteenth national conference on Artificial Intelligence (pp. 134-138).
59. Ocio, S. (2012). Adapting AI Behaviors To Players in Driver San Francisco Hinted.
60. Llans, D., Gmez-Martn, M. A., and Gonzlez-Calero, P. A. (2009). Self-Validated Be-
haviour Trees through Reflective Components. In AIIDE.
61. Shoulson, A., Garcia, F. M., Jones, M., Mead, R., and Badler, N. I. (2011). Parame-
terizing behavior trees. In Motion in Games (pp. 144-155). Springer Berlin Heidelberg.
62. Champandard, A. (2008). Getting started with decision making and control systems.
October 31, 2016 13:46 WSPC/INSTRUCTION FILE IJAIT-D-16-00092