Game Development Reference
many, and it will run too slowly. Alas for the beginning AI programmer,
experience is the best guide. Other AI techniques can be employed, including
faking it, to give the look-ahead system a fighting chance.
When the AI looks ahead, it has to think using views of the world that do not exist
outside of the AI's thought process. The AI programmer has to make sure that
those views are rich enough to allow the AI to answer any questions it is allowed to
ask of the current state of the world plus any questions it wishes to pose to its
predictions of the future. The AI programmer needs to carefully consider how the
AI will deal with knowledge. Besides being rich enough to be useful, the view has to
be small enough that it can be passed around, copied, modified, and restored as
needed. If the AI is not going to cheat, the view also needs to be properly restricted
to keep the AI from having access to information that should be unavailable to it.
One method for dealing with these views of the world is to have just one copy.
The AI can edit the world view as needed while it is deciding what to do, but it
needs to restore the view to its original state when it is done. If the view takes up a
large amount of storage, and no piece of the AI code changes very much of it, this
method makes sense. This method dies if the restoration code has any imper-
fections at all. One part of the AI will consider doing something, and later AI code
will treat the earlier consideration as having happened. The computational cost
of setting the view back also needs to be considered against the very low cost of
discarding a copy.
Another method is to give each part of the AI its own private copy of the view to
play with as it sees fit. The act of copying by itself has only modest cost. It is no
surprise that computers can copy from memory to memory with good speed.
Doing so begs the question, ''How many copies exist at one time?'' Look-ahead
methods are often recursive. How deep is the AI allowed to look? Heuristics that
control depth not only save us from computation, they also can save us from
excessive memory usage.
Look-ahead provides a minimum level of competence for the AI even when other
methods are used for longer-term planning. With a few moves of look-ahead, the
AI will not willingly step into instant disaster. It may not be all that smart, but it's