Game Development Reference
In-Depth Information
CHAPTER 15
■ ■ ■
Probabilistic and Monte Carlo
Simulations
A s you probably know, there is a lot of randomness in the world. If a golfer hits a golf ball ten
times, chances are it will wind up in ten different locations when it comes to rest. At the same
time, there is often some structure to the randomness. While the temperature on any given day
will vary, the average maximum daily temperature for a given time of year will probably remain
more or less the same.
The field of probability attempts to mathematically model the likelihood that random
events will occur in order to predict the behavior of a larger system. This chapter will provide
an introduction to the world of probability and how to incorporate it into your game programs.
Probability techniques will allow you to build structured randomness into your games. Rather
than having a flight of arrows all travel along the same trajectory, which would be boring and
fake-looking, probability techniques can give the arrows a range of initial velocities and flight
angles for a much more realistic appearance. Probability techniques can be used to vary the
speeds of snowmobiles in a snowmobile game, how far golf balls are hit in a golf game, and
many other things besides.
This chapter will be more mathematically oriented than most of the previous ones, but the
concepts discussed here can be (and are) used to model physical phenomena. After studying
the basics of the mathematical expressions that model probability, we will look at Monte Carlo
simulations, which use probability theory and random number generation to model complex
systems by modeling the behavior of the individual subcomponents that make up the system.
For example, the movement of traffic through a busy intersection might be simulated by modeling
the movements of the individual cars, trucks, and motorcycles.
This chapter will only scratch the surface of Monte Carlo and probabilistic simulations.
A lot of people have spent a lot of time over the years developing very sophisticated and compli-
cated probabilistic techniques that are beyond the scope of this topic, but this chapter will
introduce you to the subject and show how probability concepts can be applied to game
programming simulations by modeling the charge of a company of soldiers. Specific topics
covered in this chapter include the following:
How to generate random numbers to use in your game simulations
Probability functions and how they can be used to incorporate “structured randomness”
into a game simulation
403
Search WWH ::




Custom Search