Game Development Reference
In-Depth Information
and an update function that runs when there is no transition to be made. The
entry function runs when the state is entered from another state. It provides any
setup capability the state needs in order to run properly. The entry function for
the Hiding state might be tasked with picking the hiding spot. The exit function
runs when the FSM is leaving the current state and provides clean-up
functionality. Upon leaving the Attack state, the monster might want to put
away any weapon it is carrying in order to run away faster or to more easily
climb into a hiding spot. The update function runs each time the AI gets to
think while in the state. In the Flee state, our monster needs to go quickly in a
direction that is away from the players, and the update function for the Flee
state handles all of that.
Failure Modes
FSMs have some common failure modes. We will touch on three of them:
concurrent states, state explosion, and transition explosion. The latter two may
be dealt with through careful design practice, but the concurrent states are
usually a clear indicator that you should not use an FSM implementation.
Concurrent States
When reduced to an FSM, the AI might need to be in more than one state at once.
For example, simulated people may need to be hungry, lonely, and bored all at
the same time. The original states are clear and concise, but they are not exclusive
from each other. Do not attempt to use FSM machines for this kind of AI
problem, because it is better solved by other methods, such as the various agent
State Explosion
The term ''state explosion'' describes when the finite number of states becomes
too large, especially when the number of states starts multiplying. State explosion
is often the result when the original states selected blur into each other and more
states are added to better differentiate them. Note that our original states were
concise, one-word responses to ''I am....'' The programmer should be con-
cerned when those answers become full sentences. Plain FSMs are not appro-
priate when those responses become paragraphs.
One method of controlling state explosion is to use hierarchical state machines.
Typically, this involves two levels. Each high-level state runs a low-level state as
Search Nedrilad ::

Custom Search