Game Development Reference
In-Depth Information
The behavior tree form of the AI system
A behavior tree is another kind of AI system that works in a very similar way to finite
state machines. Actually, behavior trees are made up of finite state machines that
work in a hierarchical system. This system of hierarchy gives us great control over
an individual, and perhaps many finite state systems within the behavior tree, allow-
ing us to have a complex AI system.
Taking a look back at the table explaining a finite state machine, a behavior tree
works the same way. Instead of states, you have behaviors, and in place of the state
functions, you have various finite state machines that determine what is done while
the AI is in a specific behavior. Let's take a look at the behavior tree that we will be
using in this chapter to create our AI:
On the left-hand side, we have four behaviors: Idle , Guard , Combat , and Flee . To
the right are the finite state machines that make up each of the behaviors. Idle and
Flee only have one finite state machine, while Guard and Combat have multiple.
Within the Combat behavior, two of its finite state machines even have a couple of
their own finite state machines.
As you can see, this hierarchy-based system of finite state machines allows us to
use a basic form of logic to create an even more complex AI system. At the same
time, we are also getting a lot of control by separating our AI into various behaviors.
Each behavior will run its own silo of code, oblivious to the other behaviors. The only
time we want a behavior to notice another behavior is either when an internal or ex-
ternal action occurs that forces the behavior of our AI to change.
Search WWH ::




Custom Search