Game Development Reference
In-Depth Information
the point.) The continual analysis of a decision that we have already made and that
is unlikely to change quickly is horribly inefficient (and sounds amazingly like a
four-year-old).
Defined Time Periods
Going back to the reactions vs. behaviors question, from a pragmatic standpoint,
one argument to not use continuous processing is a matter of reaction time. Human
reaction time to a stimulus generally runs in the range of 150-300 milliseconds.
A game running at 50 frames per second averages 20 ms per frame. Therefore, a
human reaction time would be about 7 to 15 frames.
For purposes of calculation, let us use 12 frames (240 ms) as our typical bench-
mark. If our agent reprocesses the world every frame, and reacts to changes in the
world in that same frame , it is acting in 1/12 the time that a human would. What's
more, if the stimulus continues to change every frame, our agent could theoretically
make 12 different decisions in the time it should take for a real human to even react
to the first stimulus.
You can test yourself (and see the results of other people's tests) at
http://www.humanbenchmark.com/tests/reactiontime/. All they ask is that you
click the mouse when the image changes from red to green. (This is similar to
the test that cab drivers in major urban areas put the rest of us through at stop-
lights—their horns being the punishment for failure.)
It's actually startling to realize how long it takes humans to react to things. I
refuse to divulge what my average was… but I'm old. Let's just say that my
teenagers fared significantly better. Even my teenagers' relatively rapid times
and those of the people on the “high score� board make the idea of a single
frame reaction look a little absurd.
As we can see, continuous recalculation makes for serious overkill. We can
mitigate this effect somewhat by ensuring that we don't process more than one
reaction in a set amount of time. By waiting for an animation to finish before we
check for another stimulus, for example, we can slow down our agent's hypersen-
sitivity. If a “fire weapon� animation takes a full second, we can only decide to
check for a new target at the end of each fire animation. We have limited the pro-
cessing to once every 50 frames.
We can also set an arbitrary limit on how often an agent will process decisions.
If, for example, we use the 240 ms reaction time as our guide, we can elect to have
an agent only process a decision every 12 frames. By setting this pace for the reactions
of one agent, we open up those frames to allow other agents to make their decisions.
Search WWH ::




Custom Search