Game Development Reference
First try at a simple monster AI using a finite state machine.
the same time. [Forbus02] If the problem does not easily resolve into indepen-
dent states, an FSM is not the best solution.
Another question to ask is, ''What do the states represent?'' For a traffic light,
the states might be the color that is currently illuminated. In this case, each state
corresponds to an output. This is the most intuitive way of implementing a finite
FSM machines lend themselves to pictures. One of the better ways to design an
FSM is to lay out the states and transitions as a drawing. Figure 3.1 corresponds
to our monster AI. It appears quite simple, but it is probably more interesting to
analyze than yet another thermostat.
The states are the circles, and the transitions are the arrows. The double circle for
the Hiding state means that it is the starting state for our monster. Each tran-
sition is an arrow with text showing what causes the transition. There are many
drawing programs that make it easy to draw FSM diagrams. This diagram was
drawn using Microsoft Visio. In this diagram, the transitions depend on whether
the monster can see players or the value of the monster's health. How intelligent
is this model? We start reviewing by looking at each single transition by itself.
This model is intelligent, but not intelligent enough. The monster starts out
hiding and then attacks when it sees the player. A powerful monster pitted