Game Development Reference
In-Depth Information
If we were to list the time periods between updates of the different actions in
the list, we would find a range of times. We, as drivers, may perform some of the ac-
tions every second, some every few seconds, and some every minute or so. It would
not make sense for us to wait until we have updated everything , however. In fact, the
opposite is true. If we have updated any of our information, we need to reprocess
the entire decision using the information that we already have. What we are estab-
lishing is a minimum granularity . If the shortest update interval is one second, for
instance, it is possible that our information would change in as little as one second.
Therefore, we need to reprocess our decision at that interval.
Interrupting with an Event
The one glaring exception that doesn't work on a timed-update-based system is the
final item: unexpected events. Almost by definition, continually checking for an
unexpected event is counter-productive. This is where the event-based system is
helpful. Putting our driving example into computer terms, if the driver ahead slams
on his brakes, that car sends an “I'm braking!� message to other nearby cars. The ef-
fect is much like the grenade message earlier. This event would immediately trigger
a recalculation—not necessarily to stop (what if the driver “ahead of us� is a full
block ahead?), but to recalculate our current situation and construct an appropri-
ate decision. In essence, the message is telling us, “You really need to recalculate
everything right now !�
Timers as Interrupts
By constructing the timers we discussed above so that they send messages as well,
we effectively combine the two methods. The difference is minor and mostly logis-
tical. The agent's message receiver (again, beyond the scope of this topic) would not
need to differentiate whether the message instructing him to recalculate the deci-
sion arrived from an internal timer or an external event. The result is the same:
“Recalculate now.�
I NTHE G AME
Dudes Revisited
In the previous chapter, we constructed an elaborate method of determining who
the “best� target is for us to shoot. Let us now examine the possible solutions for
how and when to reexamine our decision and, possibly, reevaluate our target.
First, we do have a natural division that we can work from—one shot. The ratio-
nale for using a single shot as the minimum granularity is simple; we can't change
targets in the middle of a shot. Of course, the time period that each shot may take
 
Search WWH ::




Custom Search