Game Development Reference
A subset of the behavior tree used in Spore.
observation is that the tree is not a proper tree in that children can have more
than one parent. The careful eye will note that Grenade appears in many places in
the Halo 2 tree. REST and FIGHT appear more than once in the Spore tree. These
are not different behaviors with the same name; they are the same behaviors with
multiple parents in the tree. The third and less obvious observation is that there
are no loops in the trees. A final observation is that these diagrams are far easier
to understand than an equivalent single-level FSM diagram would be. Behavior
trees attempt to keep the best parts of an FSM while managing their drawbacks.
We will look at how behavior trees work by looking at the two ways we can
evaluate them: top-down and bottom-up.
So how do behavior trees work? The Spore behavior tree in Figure 10.5 is marked
with asterisks to denote the current state of the AI, which is EAT_FOOD. Each
time the AI is asked to think, it starts at the top of the tree and checks that the
current decision is still a good one. A common arrangement for the items at any
level is a prioritized list. Note that IDLE is listed last on both diagrams. All the
ways of disambiguating states can come into play here. All the states have a
decider that indicates if it wants to activate and possibly how strongly it wants to
activate. So in the Spore case, FLEE, GUARD, and FIGHT can interrupt EAT. If
any of them do want to interrupt, the machine has EAT_FOOD terminate, then
EAT is asked to terminate, and then the new sequence is started. With no
interruptions at the highest level, EAT continues to run. FIND_FOOD has