:orphan: .. **************************************************************************** .. CUI .. .. The Advanced Framework for Simulation, Integration, and Modeling (AFSIM) .. .. The use, dissemination or disclosure of data in this file is subject to .. limitation or restriction. See accompanying README and LICENSE for details. .. **************************************************************************** behavior_tree ------------- .. **Navigation:** :model:`WSF_SCRIPT_PROCESSOR` .. contents:: :local: :depth: 4 .. command:: behavior_tree ... end_behavior_tree :block: The Behavior Tree is an artificial intelligence technology that allows scenario developers to quickly create flexible agents with various tactical modules, called behaviors or behavior nodes. The nodes can be arranged together in interesting and interrelated ways with connector nodes. .. parsed-literal:: behavior_tree_ end_behavior_tree There are two basic node types: * :command:`Behavior Nodes ` - the leaf nodes of the tree, contain user defined script that performs a particular behavior or action. See the :command:`behavior` page for more info. * Connector Nodes - useful for building & organizing the tree. These nodes specify how behavior nodes are related to each other. Connector Nodes =============== *Connector Node Structure & Syntax* :: [run_selection ...] [make_selection ...] end_ Currently, there are five supported connector-node-types: sequence_, parallel_, selector_, priority_selector_, and weighted_random_ If it's not clear from the syntax definition above, any node on the behavior tree can have any number of child nodes (either connector or behavior type). These child nodes can subsequently have any number and type of children as well, and so on. Two of the connector node types perform a sequence of sorts and can not make use of any modifiers, however there are three connector nodes types that perform a single child selection (selector, priority_selector, and weighted_random) and these can be further specialized by using the sub-commands run_selection_ and make_selection_ . .. command:: sequence ... end_sequence Sequence nodes are the 2nd most common connector node used in behavior trees. When a sequence node is reached, it executes all of its children in order, until one of the children fails its precondition. If the first child fails, then none of the children are executed. If all children pass their preconditions, they are all executed. If the first half of the children pass and the next node fails, then the first half of the children are all executed, and the second half are not. .. command:: parallel ... end_parallel Parallel nodes are connector nodes used in the behavior tree in order to execute every one of their children that passes precondition, regardless of ordering. .. command:: selector ... end_selector Selector nodes are the most common connector node used in behavior trees. A selector node dictates the tree to choose only one of its children to execute. The tree will execute the first child of a selector node that passes its precondition. .. command:: priority_selector ... end_priority_selector Priority-Selector nodes are connector nodes used in the behavior tree in order to choose and execute whichever child is highest valued. The value of a child is determined by its precondition script block. Priority-Selector nodes always (and only) execute their highest valued child. .. command:: weighted_random ... end_weighted_random Weighted-Random nodes are connector nodes used in the behavior tree in order to randomly choose and execute a child. A uniform weighted random selection is performed, and the weights for each child are determined by their precondition script blocks. For example, if a Weighted-Random node has two children and both return a value of "3", then they are equally likely to be chosen. It will be common for Weighted-Random nodes to use the "run_selection" feature, in order to allow their selected child to execute for a while (or until done) before another random selection is made. .. command:: *(only useful for types: selector, priority_selector, and weighted_random)* .. command:: run_selection [ until_done | for