Game Development Reference
AI for a more self-aware monster.
against a weak or inept player will result in quick victory for the monster, which
will go back to hiding. If the combat goes against the monster and the monster's
health gets too low, it will flee. If the monster is not healed by some means and it
successfully evades the players, it will hide. So far, so good. What if the player now
wanders into the monster's sight? The monster still has low health. It will attack the
player on sight and then immediately flee when it realizes that it has low health.
The monster would have been better off if it had remained hidden. So we change
the transition from the Hiding state to the Attack state as shown in Figure 3.2.
The change we made between Figures 3.1 and 3.2 improved a single transition to
make it better. This change avoids artificial stupidity, and we only had to look at
each transition by itself. There is only one transition out of the Hiding state in
our FSM. Looking at each transition by itself is the easiest way to review an FSM
for potential problems. At first, the original transition looked perfect. The change
came after the system left the starting state and ran for a while. The original
transition assumed that a monster that was hiding had high health. This is true at
the beginning, causing the original transition to seem reasonable, but it was not
required to be true. It makes sense for a monster with low health to hide, so we do
not want to prevent a low-health monster from hiding. We have already pro-
grammed monsters with low health to break away from combat, so it makes sense
for us to program monsters with low health to avoid combat.
You should review each single transition of your FSM designs to see that it is
always reasonable. It will probably be reasonable during the initial phases of