Game Development Reference
may involve multiple points where random events, decisions, or assumptions are
employed. In the case of Blackjack, a simulation may pick the next cards to be
dealt using random selection from the set of cards not yet dealt. The simulation
may involve deterministic decisions with random outcomes. Artillery simula-
tions deal in the real-world concept of ''circular error probable,'' which means
''Half the shells land inside this circle.'' The more often these random points are
simulated, the more likely the simulation will converge to an accurate estimation
of the actual probability.
Monte Carlo methods are conceptually simple and elegant, but the development
time to implement them and the computational cost to run them make them
unsuitable for most game AI applications. Their narrow niche is occasional use in
NPCs. An NPC that runs a simulation a few times, or only once, is impulsive or
short sighted. An NPC that runs the simulation many times, however, has a very
good idea of what the future holds.
Given sufficient memory, looking up the odds in a table is so much faster than
any other method that it should be employed whenever possible. (''Sufficient''
memory is relative; the Wii is particularly constrained for memory compared to
PCs used for gaming). In many situations, the odds can be exactly precomputed.
In many other situations, the odds can be approximately precomputed. There are
two tricks to this. First, the approximation has to match closely enough to be
useful. (Think: ''This is like X, and the odds for X are....'')
The second trick is to validate the odds before the game ships. The only place to
get actual numbers is from the game itself. Be warned that during development,
the numbers will be change—possibly drastically—as the game evolves. Each
time the game is played, it could be logging events and crunching numbers on
behalf of the AI programmer. The AI programmer uses these numbers to validate
the odds in the table. It is up to the AI programmer to decide if the guidance
provided by any particular set of numbers should be followed. This works only if
the game has the instrumentation built in early enough to generate the required
amounts of data, however. There are many other benefits to building in the
instrumentation as early as possible that we will not cover. Real armies need to
know the circular error probable of their artillery long before they go to war; AI
programmers should heed that lesson.