maximum seed

Started by GrindalfGames, May 18, 2019, 22:48:09

Previous topic - Next topic

GrindalfGames

does anyone know what the maximum seed is for the rand/rnd commands  before getting the same results again(or if this is even possible)
For instance if I have an infinite amount of procedurally generated worlds with each worlds ID being the seed(starting from 1 obviously) how many worlds before I find an identical world(Or would I never find an identical world) If there is a limit I know its a big limit Im just worried I crossed that line

Matty

That depends on the modulus divisor used in the internal random command.

It could be anything, likely large.  But in blitz3d the biggest it could be would likely be max 32bit integer before it loops or in otherwords several billion.

However no guarantee mark sibly went that high.  Your best method is to look at the blitz3dsdk and check what value he used for the random number generator.

Derron

You could multiply ... just use two differend number generators.
Requires the updated brl.mod of NG as "HurryStarfish" added it some weeks ago.

https://github.com/bmx-ng/brl.mod/blob/master/random.mod/random.bmx


Now you could just have two different seeds and use a RNG for "world" and another RNG for "weather" (or whatever) and this will create more variations.
This would even allow then to have "this world" but "another weather".
Or "this world" and "other creatures".

Think you got what I mean.



bye
Ron

GrindalfGames

Thanks but that appears to be for BlitzMax

Derron

Ahhh sorry, totally missed to look at the category of this thread.

Sorry then.


bye
Ron

Flanker

You can find the functions used to generate random numbers in Blitz3D here : https://github.com/blitz-research/blitz3d_msvc2017/blob/master/bbruntime/bbmath.cpp

I can't read CPP very well but I can see that it's a pseudo-random generator using several key values (A, M, Q, R), and the seed is changed based on the previous seed every time you use a random function. With this kind of stuff, as long as you use several random values to generate your world, you're unlikely to generate the same random chain.

After some testing I would say you can use a seed beetween 1 and 2147483646 wich is almost the maximum positive value of a 32 bits integer (2147483647 produces strange results). If you use a negative seed it just loops with positive numbers.
Everyone knew it was impossible, until someone who didn't know made it.

GrindalfGames

someone else on discord said they thought it was the same number so that pretty much confirms it(for me at least :P )
I thought I should check as I have a mapped out universe with galaxies generating around 1.5 million worlds. I know nobody could explore enough worlds to find matching worlds(and if they did they would never remember if it was identical) I think its more for my peace of mind that all the worlds are actually different.
Thanks

peteswansen

I just use the 'millisecond' feature to generate random number.. and 32 bit seems like hi enough.... I forgot what the highest Integer is ...

GrindalfGames

millisecond is great if you want it to be different everytime but I need the worlds to be the same each time