kamziro
kamziro

Reputation: 8140

Non sequential random number generator (not sure of the terminology)

So a game 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?

Upvotes: 1

Views: 843

Answers (2)

Jörg W Mittag
Jörg W Mittag

Reputation: 369458

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.)

Upvotes: 0

RichieHindle
RichieHindle

Reputation: 281435

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();

Upvotes: 1

Related Questions