Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you seed a PRNG with two seeds?

Tags:

random

For a game that I'm making, where solar systems have an x and y coordinates, I'd like to use the coordinates to randomly generate the features for that solar system. The easiest way to do this seems to seed a random number generator with two seeds, the x and y coordinates. Is there anyway to get one reliable seed from the two seeds, or is there a good PRNG that takes two seeds and produces long periods?

EDIT: I'm aware of binary operations between the two numbers, but I'm trying to find the method that will lead to the least number of collisions? Addition and multiplication will easily result in collisions. But what about XOR?

like image 385
Penchant Avatar asked Sep 02 '25 10:09

Penchant


1 Answers

Why not just combine the numbers in a meaningful way to generate your seed. For example, you could add them, which could be unique enough, or perhaps stack them using a little multiplication, for example:

seed = (x << 32) + y
like image 55
tadman Avatar answered Sep 04 '25 23:09

tadman