- All Known Implementing Classes:
public interface Behavior
The base class for the second iteration of the
GoalAPI, which can be made backwards compatible by extending
BehaviorGoalAdapter. A behavior is a common term for the parts of a behavior tree, which is a simple directed acyclic graph (DAG) for AI. It is a simple state machine using
BehaviorStatus. Nodes are executed in a top-down fashion through the tree. For legacy reasons, the tree is executed as a number of executing nodes which are transitioned between using the
BehaviorStatusthey return. New child nodes are selected to become executing nodes based on
shouldExecute(). The selection behavior can vary, e.g. running a list of nodes using
Sequenceor choosing from children nodes using
Selector. The executing nodes are repeatedly
run()until the return result changes from
resetvoid reset()Resets the behavior and any state it is holding.
runBehaviorStatus run()Runs the behavior for one 'tick', optionally changing the state that it is in.
- The new state
shouldExecuteboolean shouldExecute()Returns whether the behavior is ready to run. Note this is called once when deciding whether to start execution of a leaf node. The actual execution status is determined by the return value of
run()which is repeatedly called by the executing node.