Non sequential random number generator (not sure of the terminology)
So a gam开发者_开发知识库e I'm developing has a map system where individual parts of the map can be loaded independently from (most of) the other parts.
I wanted to have a random number generator which, given a seed number, and a map part number, would generate a random number. But this number has to be consistent for each pair of seed and map part number.
What is such a random number generator called? Also, what are good examples of such a RNG?
Most random number generators work like this. You call a seed()
function with some combination of your seed
and part_number
, then call a random()
function to get the "random" number you want (which of course isn't actually random, but that's what you want).
For instance, in C++:
srand(seed*part_number); // How you combine seed and part_number doesn't matter.
result = rand();
It sounds to me like you're not looking for a PRNG at all, but rather for Procedural Generation aka Procedural Synthesis. (Although, of course, a PRNG with a fixed seed value is a very common and popular implementation technique for Procedural Generation.)
精彩评论