Game Development Reference
In-Depth Information
dozens of possible choices available to a player in a modern war game. Furthermore,
because of the way neural networks store data, there is no way to tell what the data
actually mean. You can't teach the network a new pattern simply by tweaking the
numbers stored inside it; you have to start over again from the beginning.
Hierarchical Finite State Machines
In the absence of orders, go find something and kill it.
—E RWIN R OMMEL
Hierarchical finite state machines have proven to be the most successful mechanism
for creating artificially intelligent opponents in war games because they can handle
large numbers of units and produce seemingly intelligent, coordinated behavior.
WHAT IS A FINITE STATE MACHINE?
A finite state machine (FSM) is a conceptual machine rather than a real piece of
mechanical engineering. Its rules establish a simple behavioral system for an indi-
vidual automated character, such as a unit in a war game. The unit can inhabit a
limited number of states (such as scouting, guarding, pursuing, and retreating),
and it's only ever in one state at a time. As long as the unit is in a given state, it per-
forms a particular activity. Certain events cause it to make a transition to a new state,
after which it starts performing a new activity. Here's an example from real life.
In 1960, researchers at Johns Hopkins University built a little robot called the
Hopkins Beast. The only thing the robot did was wander around the computing
laboratory. When its batteries got low, it would start to search for an electrical out-
let with its photocell eye. (Electrical outlets were the only object that it could
recognize.) If it found an outlet, it would plug itself in until its batteries recharged.
Then it would set off wandering again. So the Hopkins Beast possessed only three
possible states: wandering, searching, and recharging. Its initial state was always
wandering. The only thing that would cause a transition to searching was a low
battery. When it detected that its battery was low, it would transition to the search-
ing state, turn on its eye, and continue to move through the halls. Once it detected
an outlet, it would transition to the recharging state and plug itself in. Once it
detected that it was charged up, the Beast would transition back to the wandering
state. It would unplug itself and start wandering again.
The Hopkins Beast was extremely simple, but you get the idea. You can use FSMs to
define the behavior of units. One state should be a default for that unit type—nor-
mally, holding its current position or patrolling (General Rommel's advice notwith-
standing). For each state that you define, you must indicate how the unit behaves in
that state and list all the things that will cause it to transition to a new state. FSMs
have a weakness in that they can't walk and chew gum at the same time—that is,
they can only be in one state at a time, so a single individual can't work on two
things at once. However, the units in war games seldom need to do this anyway.
Search WWH ::




Custom Search