top of page
example_see_always.png
see-approach-shoot-return_large.gif

Behavior Trees

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

Nodes are the building blocks of the behavior tree

Return values

A node can return one of three results:

  • Success

  • Running

  • Failure

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.

root.png

The Root node

The Root node is the start of the behavior tree, and like decorator nodes, they have one child.

decorator_succeed.png

Decorator nodes

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_sequence.png

Composite nodes

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.

action_destroy.png

Leaf nodes

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.

Execution order

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.

behavior_tree_execution_order.gif
shootattarget3.gif

Further Reading

Want to know more about behavior tree theory? Check out the articles below.

bottom of page