Game Development Reference
In-Depth Information
be made for FSM: Random selection is a good way to disambiguate equally good
choices .
Choices are not always equally good, however. When the AI needs to avoid being
predictable, it must sometimes select a sub-optimal choice. A real-life Blackjack
dealer is required to be predictable; the prediction that must be true is that in the
long run, the house always wins. But game AI must balance the flaw of pre-
dictability against the flaw of making sub-optimal choices. The game AI needs to
consider the odds in order to strike that balance.
Odds are situational. The odds for many games of pure chance can easily be
precomputed. The methods for doing so are presented in most probability and
statistics topics. More advanced treatments are available in topics on combina-
torics, which, while fascinating in its own right, might not be for the faint of
heart. We will look at three ways of computing the odds: Monte Carlo methods,
precomputing, and faking it. Each method has unique strengths and costs.
How can one know the odds in cases where the situation cannot be known in
advance? One way is to simulate some or all of the potential game outcomes and
compute the odds from the simulated results. This is known as a Monte Carlo
method, and it can be directly applied to game AI. If one view of intelligence is
that current actions increase future gains, then game AI could surely benefit from
the ability to look into the future before making a decision.
The quality of a Monte Carlo simulation depends on how accurately the AI's
Monte Carlo simulation models the actual game situation. An AI programmer
wishing to use Monte Carlo methods needs to ensure that the simulation is close
enough to the situation and make sure the simulation is computationally cheap
enough to be worthwhile. Also, the simulation may involve simplifications and
assumptions; the programmer must ensure that they are ''good enough'' and that
the results are better than other alternatives. Even if Monte Carlo methods are
not employed, probabilistic AI needs to get the odds, also thought of as weights,
to apply to the alternatives.
The accuracy of a Monte Carlo prediction depends not only on the quality of the
simulation but also on how many times the simulation is run. The simulation