Game Development Reference
In-Depth Information
Exploring randomness
Now one strange thing to keep in mind is that there is no such thing as a completely ran-
dom system, especially in gaming and computing. You can get close with some really com-
plex mathematical systems but nothing is truly random. The best we can do is make it ran-
dom enough to fool the player making them believe it is random.
The reason for this is simple: computers are not random and don't think in random terms.
When they generate a random number, they are using a seed (a unique number to base their
random generation on) to work out what number to give you. But every time you generate
a number based on that same seed, it will always be the same sequence; this is known as
pseudo-random .
So, if I generate a random number from a seed of 1234, every number generated from that
seed will always follow the same pattern (1, 5, 3, 7, 2, 4, 10, and so on). Most basic sys-
tems try to balance this out by also randomly generating the seed number, but this again
falls under the same pattern. However, it does make the random pattern a little more ran-
dom. A lot of systems use the date or current clock tick as the seed. It's important to know
and remember this when you are planning to use random systems.
There is also a drawback to trying to make your random system even more random: you
end up spending more time computing the random number in your game and stealing re-
sources from other systems such as physics, AI, and so on. It's always a balancing game to
ensure you plan where your precious system resources are going to be spent. For instance,
if you use a triple-pass-random system using several levels of Perlin noise generated for
each frame, it is a heavy burden on the CPU (although, this is a rather extreme example,
you should never generate it for every frame unless there is a very good reason to do so!).
In most cases, developers use other effects to try to create randomness by using noise gen-
erating systems (Perlin/fractals/Gaussian drift) and other techniques to try to make the best
use of low-cost generation systems with as few passes needed to get the desired result. By
combining two or more systems, you can create an approximate and fairly complex random
system.
Note
If you want to read up more on random and pseudo-random systems, you can get a full his-
tory on RANDOM.ORG at http://www.random.org/randomness/ , which also features some
examples of free and paid random systems.
Search WWH ::




Custom Search