Design behavior for artificial intelligence
Behavior Trees are a method of designing behavior for artificial intelligence that is often used in games.
Behavior Trees excel in their modularity. Parts of behavior trees or even entire behaviors can be used in other behavior trees to easily recycle behavior and cut down production time.
Before we dive into the behavior tree tool itself, it might be useful to get up to speed with some basic behavior tree theory.
Nodes are the building blocks of the behavior tree
A node can return one of three results:
These return values are used for logic in the behavior tree. A success value will for example tell a Selector node that its child has successfully executed its task, causing the Selector node to stop evaluating the child nodes that come next.
The Root node
The Root node is the start of the behavior tree, and like decorator nodes, they have one child.
Decorator nodes have one single child and are often used to alter the return value of their child. Take, for example, the Succeed node: it alters the return value of its child to "Success" no matter what happens.
Composite nodes have multiple children and return the product of their children. An example of a composite node is the Sequence node, which executes the behavior of all its children until one fails.
Leaf nodes are where the action happens. That's why they're also called Action nodes. They cause the behavior tree agent to move or to shoot a projectile.
The behavior tree is executed from top to bottom, and from left to right, always starting with the Root node.
This particular behavior tree causes the red agent cube to continuously look at the blue target sphere while shooting projectiles at it with a waiting period in between them.
Want to know more about behavior tree theory? Check out the articles below.