Though the pattern is rather uniformly distributed, it isn't quite random. Let's look at the numbers generated from the same sequence for reference and compare with numbers created by getting the first number in of each of 65536 sequences created from the seeds 0 to 65535. But for something a bit more fun and informative, let's do some experiments and look at the results. You can also look at this Stack Overflow question about RNG for procedural content if that's more trustworthy. And it won't be any better if you take the 10th, 100th, 1000th number from each sequence.Īt this point some people will be skeptical, and that's fine. So if you have 100 sequences and take the first number from each, those numbers will not be random in relation to each other. The things I know about this are hard earned and don't seem to be readily available elsewhere, so I thought it would be in order to write it down and share it. In this article we'll look into two different ways to produce random numbers - random number generators and random hash functions - and reasons for using one or the other. The defining trait for a seed is that the same seed will always produce the same output, but even the slightest change in the seed can produce a completely different output.
A seed can be a number, text string, or other data that's used as input in order to get a random output. We've mentioned the word seed a few times. This is essentially the same as the ability to revisit the same level/world mentioned above, except that the same seed is always used. This is for example the case in No Man's Sky. Maybe you want your game world to be the same for everyone who play it, exactly as if it wasn't procedurally generated. If you have a world that's generated on the fly as the player moves around in it, you may want locations to remain the same the first and subsequent times the player visit those locations (like in Minecraft, the upcoming game No Man's Sky, and others), rather than being different each time as if driven by dream logic.
In this article we'll use level/world generation in games as example use cases, but the lessons are applicable to many other things, such as procedural textures, models, music, etc.