Game Development Reference
In-Depth Information
player never sees artificial stupidity, then for all practical purposes that stupidity
did not happen.
This powerful tool fails if the game ever offers the player a chance to see things the
player could never see while playing the game. For example, the any-angle
instant-replay capability popular in sports games kills this method of handling
ambiguities. In our example, we might claim that no player will see our monster
being stupid because it only happens when there are no players present. The idea
of ''no players present'' needs closer examination, however. Is the player sup-
posed to be able to hide from the monster? If so, then the player will expect the
monster to not detect the hidden player when the player is actually present. If the
monster acts like it knows that the player is present when the player is hidden,
then the AI is cheating and—more importantly—it is visibly cheating. Players
hate visible cheats worse than they hate artificial stupidity. If players can hide and
the monster properly ignores them when they do, then the race conditions in the
FSM of Figure 3.2 must be dealt with. A player who was hidden from both the
monster and the other players will indeed be able to see the monster attack or flee
from the other players who are no longer there.
The next simplest way to handle ambiguities is to fully specify every transition in
terms of every one of the conditions on which any transition depends. This can
be characterized as ''Look at all the data every time.'' ''Simple'' in this usage does
not mean easy or effective, however; it merely means that it is not hard to
understand the concept. Full specification adds complexity to the transitions and
quickly becomes a nightmare to maintain.
The third and most common way to handle ambiguities is by prioritizing the
transitions. If the No Players transitions from the Attack and Flee states are
checked before the health-related transitions out of those states, the monster AI
will never attempt to attack or flee from players who are not there. The impli-
cation here is that the first valid transition found will be the transition taken. This
capability is very easy for the programmer to provide by making the code that
checks the transitions for validity go through them in a fixed order set by the
programmer. The programmer will probably write the code to check the tran-
sitions in a fixed order anyway. All that is required is that the programmer thinks
about the order and forces it to be optimal. This simple approach often meets a
''good enough'' criterion.
When there are numerous transitions and states, a fixed order may not always
yield the best AI, however. If need be, the programmer can employ a more
Search Nedrilad ::

Custom Search