Learning the basics of behavior trees
Behavior trees got their name from their hierarchical, branching system of nodes with a common parent, known as the root. As you've surely learned by now from reading this book, behavior trees too mimic the real thing they are named after—in this case, trees and their branching structure. If we were to visualize a behavior tree, it would look something like the following figure:

A basic tree structure
Of course, behavior trees can be made up of any number of nodes and child nodes. The nodes at the very end of the hierarchy are referred to as leaf nodes, just like a tree. Nodes can represent behaviors or tests. Unlike state machines, which rely on transition rules to traverse through them, a BT's flow is defined strictly by each node's order within the larger hierarchy. A BT begins evaluating from the top of the tree (based on the preceding visualization), then continues through each child, which, in turn, runs through each of its children until a condition...