Game Development Reference
nouns: egg, worm, dragon. All of these lists are different ways of doing or being or
existing in some way. We build the states in an FSM to model these ways. For
game AI, the key idea is that different states imply different behaviors. We expect
dragons to behave differently from dragon eggs.
That leaves the transitions. The transitions answer the question, ''What would
make the AI change from one state to a different state?'' Since we are using the
states in the FSM to map to behaviors, the question translates to, ''What would
make the AI change from this set of behaviors to that set of behaviors?''
So can we make our FSMs meet our basic definition of game AI from Chapter 1,
''What Is Game AI?'' Can they act intelligently in the face of changing conditions?
The actions are handled in the states. The transitions provide the mechanism to
handle changing conditions. The intelligent part depends on the quality of the fit
between the simulated world and the selected states and transitions. Horatio, the
simulated opera singer from Chapter 2, ''Simple Hard-Coded AI,'' would still
inappropriately break into song if his AI did not correctly differentiate between
an opera house and a funeral home. In short, the intelligence is in states and
Besides being a programming method to implement AI, FSMs are an effective
AI analysis tool. Before using an FSM, the programmer must ask, ''Can I break
the AI into concise, independent states?'' In order to answer that question, the AI
programmer must first solidify his or her idea of what the AI must do. It is
imperative to know what the AI must do before an implementation can be
selected. The act of determining whether an FSM is appropriate forces the AI
programmer to first define the AI.
Look back at the three lists we used to finish the ''I am ...'' statement. The
answers were concise; it is hard to beat single-word answers for brevity. The
answers were also independent; that is to say, each one was not like any of
the others. More importantly, it would not make sense for the AI to be any two at
the same time. Traffic lights and thermostats have concise, independent states
and clear transitions. Simulated monsters or very simple simulated people might
easily break into a few states, but more complex simulated people do not. A
simple monster might be content only to hide, attack, or flee, but a simulated
person in the game The Sims has to be able to be hungry, lonely, and bored all at