Book Image

Mastering Unity 2D game development

By : Simon Jackson
Book Image

Mastering Unity 2D game development

By: Simon Jackson

Overview of this book

Table of Contents (21 chapters)
Mastering Unity 2D Game Development
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Free Chapter
1
Overview
Index

Exploring randomness


Now one strange thing to keep in mind is that there is no such thing as a completely random system, especially in gaming and computing. You can get close with some really complex mathematical systems but nothing is truly random. The best we can do is make it random 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 systems try to balance this out by also randomly generating the seed number, but this again falls under the same pattern...