I want to briefly describe the different types of nodes that exist within a Behavior Tree data structure when considering AI.
There are 3 general archetypes of Behavior Tree nodes:
Composite - Composite nodes are nodes that mainly exist to control the flow of an artificially intelligent agent’s behavior (or sequence of behaviors) and in which order to perform these behaviors. These nodes can have one or more children nodes and are responsible for processing (i.e. determining the status of) any or all of their children nodes. The most common type of Composite node is the Sequence, which processes each child in some specified sequence (in an order) and returns failure to its parent node if any of the children nodes returns a failure status message. The Sequencer will return success if every child returns success.
Decorator - Decorator nodes are like Composites, except these nodes can only have one child. Depending on the type of Decorator node, their specific purpose is to either:
transform or manipulate the result they receive from their child node's status
to terminate (stop execution of) the child
or repeat processing of the child
The most common type of Decorator is the Inverter, which simply just inverts the result returned by the child node (child returns failure —> decorator returns success, or child returns success —> decorator returns failure)
Leaf - Leaf nodes are the most expressive and powerful types of nodes for a developer, since these nodes define the game-specific behaviors/actions that an AI can perform. The developer can create the AI behaviors however he/she wants with these nodes! Without these nodes, a Behavior Tree would be useless because there wouldn’t be any behaviors for the AI to perform! Leaf nodes don’t have any children and are (usually) at the lowest level of a tree. Leaf nodes can also be used for determining the current state of the game or to check if a given condition in the game is satisfied.