Game Development Reference
In-Depth Information
With precomputed odds or a sufficient number of runs of a good simulation, the
AI can accurately determine the odds of future events. The most common way
such odds are used is to create weights to influence an otherwise purely random
selection. The weights can take in more than the probability of success; they can
also factor in potential gains, potential losses, and the cost of taking an action
regardless of success or failure.
People weigh decisions this way in real life. Going to a day job each day typically
has a very high probability of success, good but not great gain, almost zero
potential loss, and modest costs. Buying one lottery ticket with the leftover
change from a purchase has an extremely low probability of success, incredible
potential gain, no potential loss, and low cost. Cutting in and out of traffic has far
lower odds of success than normal driving, small potential gains in saved time,
substantial potential losses from accidents and tickets, and modest additional
costs in gas and wear on the car.
Impulsive behavior is easy to model with these methods. To get this with a Monte
Carlo simulation, run the simulation just one time. With precomputed odds, this
happens when a random selection falls outside the most probable outcomes.
Much of the time, the system will select a typical response, but occasionally it will
select a low-probability outcome. The normally reasonable AI is thinking,
''Today is my lucky day.''
You can model compulsive behaviors by using different weights on the factors.
The compulsive gambler ignores the probability of success and bases decisions on
potential gains to the near exclusion of other factors. The gambler says, ''I use all
of my leftover money on lottery tickets.'' A miser focuses on minimizing costs.
''If you order a cup of hot water, you can use the free ketchup on the table to
make tomato soup.'' A timid person is obsessed with avoiding potential loss. ''I
won't put money in the stock market or bonds, and I can barely tolerate having it
in banks. Those companies could all go bankrupt!''
Slow and steady behavior weighs an accurate probability of success against
potential gains, avoids unnecessary risks, and indulges lightly in cheap long-shot
activities. In the real world, such people seek steady employment at a good wage,
maximize their retirement contributions, carry insurance, and avoid risky
behaviors, but are not above entering the occasional sweepstakes. These beha-
viors may lack entertainment value, but the game AI programmer benefits by
knowing how to program ''boring and normal.''