Behavior tree (artificial intelligence, robotics and control)

Last updated

A behavior tree is a mathematical model of plan execution used in computer science, robotics, control systems and video games. They describe switchings between a finite set of tasks in a modular fashion. Their strength comes from their ability to create very complex tasks composed of simple tasks, without worrying how the simple tasks are implemented. Behavior trees present some similarities to hierarchical state machines with the key difference that the main building block of a behavior is a task rather than a state. Its ease of human understanding make behavior trees less error prone and very popular in the game developer community. Behavior trees have been shown to generalize several other control architectures. [1] [2]

Contents

Behavior tree modelling the search and grasp plan of a two-armed robot BT search and grasp.svg
Behavior tree modelling the search and grasp plan of a two-armed robot

Background

A behavior based control structure has been initially proposed by Rodney Brooks in his paper titled 'A robust layered control system for a mobile robot'. In the initial proposal a list of behaviors could work as alternative one another, later the approach has been extended and generalized in a tree-like organization of behaviors, with extensive application in the game industry[ citation needed ] as a powerful tool to model the behavior of non-player characters (NPCs). [3] [4] [5] [6] They have been extensively used in high-profile video games such as Halo, Bioshock, and Spore. Recent works propose behavior trees as a multi-mission control framework for UAV, complex robots, robotic manipulation, and multi-robot systems. [7] [8] [9] [10] [11] [12] Behavior trees have now reached the maturity to be treated in Game AI textbooks, [13] [14] as well as generic game environments such as Unity (game engine) and Unreal Engine (see links below).

Behavior trees became popular for their development paradigm: being able to create a complex behavior by only programming the NPC's actions and then designing a tree structure (usually through drag and drop) whose leaf nodes are actions and whose inner nodes determine the NPC's decision making. Behavior trees are visually intuitive and easy to design, test, and debug, and provide more modularity, scalability, and reusability than other behavior creation methods.

Over the years, the diverse implementations of behavior trees kept improving both in efficiency and capabilities to satisfy the demands of the industry, until they evolved into event-driven behavior trees. [15] [5] Event-driven behavior trees solved some scalability issues of classical behavior trees by changing how the tree internally handles its execution, and by introducing a new type of node that can react to events and abort running nodes. Nowadays, the concept of event-driven behavior tree is a standard and used in most of the implementations, even though they are still called "behavior trees" for simplicity.

Key concepts

A behavior tree is graphically represented as a directed tree in which the nodes are classified as root, control flow nodes, or execution nodes (tasks). For each pair of connected nodes the outgoing node is called parent and the incoming node is called child. The root has no parents and exactly one child, the control flow nodes have one parent and at least one child, and the execution nodes have one parent and no children. Graphically, the children of a control flow node are placed below it, ordered from left to right. [16]

The execution of a behavior tree starts from the root which sends ticks with a certain frequency to its child. A tick is an enabling signal that allows the execution of a child. When the execution of a node in the behavior tree is allowed, it returns to the parent a status running if its execution has not finished yet, success if it has achieved its goal, or failure otherwise.

Control flow node

A control flow node is used to control the subtasks of which it is composed. A control flow node may be either a selector (fallback) node or a sequence node. They run each of their subtasks in turn. When a subtask is completed and returns its status (success or failure), the control flow node decides whether to execute the next subtask or not.

Selector (fallback) node

Figure I. Graphical representation of a fallback composition of N tasks. Fallback in Behavior tree.png
Figure I. Graphical representation of a fallback composition of N tasks.

Fallback nodes are used to find and execute the first child that does not fail. A fallback node will return with a status code of success or running immediately when one of its children returns success or running (see Figure I and the pseudocode below). The children are ticked in order of importance, from left to right.

In pseudocode, the algorithm for a fallback composition is:

1 for i from 1 to n do 2     childstatus ← Tick(child(i)) 3     if childstatus = running 4         return running 5     else if childstatus = success 6         return success 7 end 8 return failure

Sequence node

Figure II. Graphical representation of a sequence composition of N tasks. Sequence composition in behaviour trees.png
Figure II. Graphical representation of a sequence composition of N tasks.

Sequence nodes are used to find and execute the first child that has not yet succeeded. A sequence node will return with a status code of failure or running immediately when one of its children returns failure or running (see Figure II and the pseudocode below). The children are ticked in order, from left to right.

In pseudocode, the algorithm for a sequence composition is:

1 for i from 1 to n do 2     childstatus ← Tick(child(i)) 3     if childstatus = running 4         return running 5     else if childstatus = failure 6         return failure 7 end 8 return success

Mathematical state space definition

In order to apply control theory tools to the analysis of behavior trees, they can be defined as three-tuple. [17]

where is the index of the tree, is a vector field representing the right hand side of an ordinary difference equation, is a time step and is the return status, that can be equal to either Running , Success , or Failure .

Note: A task is a degenerate behavior tree with no parent and no child.

Behavior tree execution

The execution of a behavior tree is described by the following standard ordinary difference equations:

where represent the discrete time, and is the state space of the system modelled by the behavior tree.

Sequence composition

Two behavior trees and can be composed into a more complex behavior tree using a Sequence operator.

Then return status and the vector field associated with are defined (for [ definition needed ]) as follows:

See also

Related Research Articles

<span class="mw-page-title-main">Binary search tree</span> Rooted binary tree data structure

In computer science, a binary search tree (BST), also called an ordered or sorted binary tree, is a rooted binary tree data structure with the key of each internal node being greater than all the keys in the respective node's left subtree and less than the ones in its right subtree. The time complexity of operations on the binary search tree is linear with respect to the height of the tree.

In computer science, a red–black tree is a specialised binary search tree data structure noted for fast storage and retrieval of ordered information, and a guarantee that operations will complete within a known time. Compared to other self-balancing binary search trees, the nodes in a red-black tree hold an extra bit called "color" representing "red" and "black" which is used when re-organising the tree to ensure that it is always approximately balanced.

In computer science, a Fibonacci heap is a data structure for priority queue operations, consisting of a collection of heap-ordered trees. It has a better amortized running time than many other priority queue data structures including the binary heap and binomial heap. Michael L. Fredman and Robert E. Tarjan developed Fibonacci heaps in 1984 and published them in a scientific journal in 1987. Fibonacci heaps are named after the Fibonacci numbers, which are used in their running time analysis.

<span class="mw-page-title-main">Maximum flow problem</span> Computational problem in graph theory

In optimization theory, maximum flow problems involve finding a feasible flow through a flow network that obtains the maximum possible flow rate.

In computer science, iterative deepening search or more specifically iterative deepening depth-first search is a state space/graph search strategy in which a depth-limited version of depth-first search is run repeatedly with increasing depth limits until the goal is found. IDDFS is optimal, meaning that it finds the shallowest goal. Since it visits all the nodes in the search tree down to depth before visiting any nodes at depth , the cumulative order in which nodes are first visited is effectively the same as in breadth-first search. However, IDDFS uses much less memory.

Branch and bound is a method for solving optimization problems by breaking them down into smaller sub-problems and using a bounding function to eliminate sub-problems that cannot contain the optimal solution. It is an algorithm design paradigm for discrete and combinatorial optimization problems, as well as mathematical optimization. A branch-and-bound algorithm consists of a systematic enumeration of candidate solutions by means of state space search: the set of candidate solutions is thought of as forming a rooted tree with the full set at the root. The algorithm explores branches of this tree, which represent subsets of the solution set. Before enumerating the candidate solutions of a branch, the branch is checked against upper and lower estimated bounds on the optimal solution, and is discarded if it cannot produce a better solution than the best one found so far by the algorithm.

Belief propagation, also known as sum–product message passing, is a message-passing algorithm for performing inference on graphical models, such as Bayesian networks and Markov random fields. It calculates the marginal distribution for each unobserved node, conditional on any observed nodes. Belief propagation is commonly used in artificial intelligence and information theory, and has demonstrated empirical success in numerous applications, including low-density parity-check codes, turbo codes, free energy approximation, and satisfiability.

Observability is a measure of how well internal states of a system can be inferred from knowledge of its external outputs.

In computer science, a disjoint-set data structure, also called a union–find data structure or merge–find set, is a data structure that stores a collection of disjoint (non-overlapping) sets. Equivalently, it stores a partition of a set into disjoint subsets. It provides operations for adding new sets, merging sets, and finding a representative member of a set. The last operation makes it possible to find out efficiently if any two elements are in the same or different sets.

Random forests or random decision forests is an ensemble learning method for classification, regression and other tasks that operates by constructing a multitude of decision trees at training time. For classification tasks, the output of the random forest is the class selected by most trees. For regression tasks, the mean or average prediction of the individual trees is returned. Random decision forests correct for decision trees' habit of overfitting to their training set.

In control theory, the linear–quadratic–Gaussian (LQG) control problem is one of the most fundamental optimal control problems, and it can also be operated repeatedly for model predictive control. It concerns linear systems driven by additive white Gaussian noise. The problem is to determine an output feedback law that is optimal in the sense of minimizing the expected value of a quadratic cost criterion. Output measurements are assumed to be corrupted by Gaussian noise and the initial state, likewise, is assumed to be a Gaussian random vector.

<span class="mw-page-title-main">Long short-term memory</span> Artificial recurrent neural network architecture used in deep learning

Long short-term memory (LSTM) network is a recurrent neural network (RNN), aimed at dealing with the vanishing gradient problem present in traditional RNNs. Its relative insensitivity to gap length is its advantage over other RNNs, hidden Markov models and other sequence learning methods. It aims to provide a short-term memory for RNN that can last thousands of timesteps, thus "long short-term memory". It is applicable to classification, processing and predicting data based on time series, such as in handwriting, speech recognition, machine translation, speech activity detection, robot control, video games, and healthcare.

<span class="mw-page-title-main">Network science</span> Academic field

Network science is an academic field which studies complex networks such as telecommunication networks, computer networks, biological networks, cognitive and semantic networks, and social networks, considering distinct elements or actors represented by nodes and the connections between the elements or actors as links. The field draws on theories and methods including graph theory from mathematics, statistical mechanics from physics, data mining and information visualization from computer science, inferential modeling from statistics, and social structure from sociology. The United States National Research Council defines network science as "the study of network representations of physical, biological, and social phenomena leading to predictive models of these phenomena."

<span class="mw-page-title-main">Fenwick tree</span> Data structure

A Fenwick tree or binary indexed tree(BIT) is a data structure that can efficiently update values and calculate prefix sums in an array of values.

<span class="mw-page-title-main">Growing self-organizing map</span> Growing variant of a self-organizing map

A growing self-organizing map (GSOM) is a growing variant of a self-organizing map (SOM). The GSOM was developed to address the issue of identifying a suitable map size in the SOM. It starts with a minimal number of nodes and grows new nodes on the boundary based on a heuristic. By using the value called Spread Factor (SF), the data analyst has the ability to control the growth of the GSOM.

Mean-field game theory is the study of strategic decision making by small interacting agents in very large populations. It lies at the intersection of game theory with stochastic analysis and control theory. The use of the term "mean field" is inspired by mean-field theory in physics, which considers the behavior of systems of large numbers of particles where individual particles have negligible impacts upon the system. In other words, each agent acts according to his minimization or maximization problem taking into account other agents’ decisions and because their population is large we can assume the number of agents goes to infinity and a representative agent exists.

Input-to-state stability (ISS) is a stability notion widely used to study stability of nonlinear control systems with external inputs. Roughly speaking, a control system is ISS if it is globally asymptotically stable in the absence of external inputs and if its trajectories are bounded by a function of the size of the input for all sufficiently large times. The importance of ISS is due to the fact that the concept has bridged the gap between input–output and state-space methods, widely used within the control systems community.

In computer science, Monte Carlo tree search (MCTS) is a heuristic search algorithm for some kinds of decision processes, most notably those employed in software that plays board games. In that context MCTS is used to solve the game tree.

In computational geometry, a well-separated pair decomposition (WSPD) of a set of points , is a sequence of pairs of sets , such that each pair is well-separated, and for each two distinct points , there exists precisely one pair which separates the two.

In mathematics, especially mathematical logic, graph theory and number theory, the Buchholz hydra game is a type of hydra game, which is a single-player game based on the idea of chopping pieces off a mathematical tree. The hydra game can be used to generate a rapidly growing function, , which eventually dominates all recursive functions that are provably total in "", and the termination of all hydra games is not provably total in .

References

  1. Colledanchise, Michele; Ögren, Petter (2017). "How Behavior Trees Modularize Hybrid Control Systems and Generalize Sequential Behavior Compositions, the Subsumption Architecture, and Decision Trees". IEEE Transactions on Robotics. 33 (2): 372–389. doi:10.1109/TRO.2016.2633567. S2CID   9518238.
  2. Colledanchise, Michele; Ögren, Petter (2018). Behavior Trees in Robotics and AI: An Introduction. CRC Press. arXiv: 1709.00084 . doi:10.1201/9780429489105. ISBN   978-1-138-59373-2. S2CID   27470659.
  3. Isla, D. (2005). "Handling complexity in the Halo 2 AI". Game Developers Conference (Vol. 12).
  4. Isla, D. (2008). Halo 3-building a better battle.{{cite book}}: |work= ignored (help)
  5. 1 2 Agis, Ramiro A.; Gottifredi, Sebastian; García, Alejandro J. (2020). "An event-driven behavior trees extension to facilitate non-player multi-agent coordination in video games" (PDF). Expert Systems with Applications. 155 (1): 113457. doi:10.1016/j.eswa.2020.113457. S2CID   218995637.
  6. Lim, C. U.; Baumgarten, R.; Colton, S. (2010). "Evolving Behaviour Trees for the Commercial Game DEFCON" (PDF). Applications of Evolutionary Computation. Lecture Notes in Computer Science. Vol. 6024. Berlin: Springer. pp. 100–110. doi:10.1007/978-3-642-12239-2_11. ISBN   978-3-642-12238-5.
  7. Ögren, Petter (2012). "Increasing Modularity of UAV Control Systems using Computer Game Behavior Trees" (PDF). AIAA Guidance, Navigation and Control Conference, Minneapolis, Minnesota. pp. 13–16.
  8. Colledanchise, Michele; Marzinotto, Alejandro; Ögren, Petter (2014). "Performance analysis of stochastic behavior trees" (PDF). 2014 IEEE International Conference on Robotics and Automation (ICRA). pp. 3265–3272. doi:10.1109/ICRA.2014.6907328. ISBN   978-1-4799-3685-4. S2CID   14719083.
  9. Marzinotto, Alejandro; Colledanchise, Michele; Smith, Christian; Ögren, Petter (2014). "Towards a Unified BTs Framework for Robot Control" (PDF). Robotics and Automation (ICRA), 2014 IEEE International Conference on.
  10. Klöckner, Andreas. "Interfacing BTs with the World Using Description Logic." In AIAA Guidance, Navigation and Control Conference, Boston, MA. 2013.
  11. Klöckner, Andreas (2013). "Behavior Trees for UAV Mission Management". GI-Jahrestagung. pp. 57–68.
  12. Bagnell, J. Andrew; Cavalcanti, Felipe; Cui, Lei; et al. (2012). "An integrated system for autonomous robotics manipulation" (PDF). Intelligent Robots and Systems (IROS), 2012 IEEE/RSJ International Conference on. IEEE. pp. 2955–2962. doi:10.1109/IROS.2012.6385888. hdl:20.500.11937/14608. ISBN   978-1-4673-1736-8. S2CID   419179.
  13. Millington; Funge (2009). Artificial Intelligence for Games. CRC Press. ISBN   978-0-12-374731-0.
  14. Rabin, S. (2014). Game AI Pro. CRC Press. ISBN   978-1-4665-6596-8.
  15. Champandard, Alex J.; Dunstan, Philip (2012). "The Behavior Tree Starter Kit" (PDF). Game AI Pro: Collected Wisdom of Game AI Professionals. pp. 72–92.
  16. craft ai (2015). "BT 101 – Behavior Trees grammar basics".
  17. Colledanchise, Michele; Ögren, Petter (2014). "How Behavior Trees Modularize Robustness and Safety in Hybrid Systems" (PDF). In Intelligent Robots and Systems (IROS), 2014 IEEE/RSJ International Conference on. IEEE.