December 04, 2020, 02:05:03 PM

Author Topic: maximum seed  (Read 2115 times)

Offline grindalf

  • Full Member
  • ***
  • Posts: 152
maximum seed
« on: May 18, 2019, 10:48:09 PM »
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

Offline Matty

  • Hero Member
  • *****
  • Posts: 1258
    • MattiesGames
Re: maximum seed
« Reply #1 on: May 19, 2019, 05:26:03 AM »
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.

Offline Derron

  • Hero Member
  • *****
  • Posts: 3275
Re: maximum seed
« Reply #2 on: May 19, 2019, 09:46:11 AM »
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

Offline grindalf

  • Full Member
  • ***
  • Posts: 152
Re: maximum seed
« Reply #3 on: May 19, 2019, 06:28:22 PM »
Thanks but that appears to be for BlitzMax

Offline Derron

  • Hero Member
  • *****
  • Posts: 3275
Re: maximum seed
« Reply #4 on: May 19, 2019, 06:51:03 PM »
Ahhh sorry, totally missed to look at the category of this thread.

Sorry then.


bye
Ron

Offline Flanker

  • Jr. Member
  • **
  • Posts: 41
    • Youtube channel on Blitzmax programming prototypes
Re: maximum seed
« Reply #5 on: May 21, 2019, 03:42:39 PM »
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.

Offline grindalf

  • Full Member
  • ***
  • Posts: 152
Re: maximum seed
« Reply #6 on: May 21, 2019, 10:22:43 PM »
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

Offline peteswansen

  • Jr. Member
  • **
  • Posts: 57
Re: maximum seed
« Reply #7 on: May 21, 2019, 11:41:42 PM »
I just use the 'millisecond' feature to generate random number.. and 32 bit seems like hi enough.... I forgot what the highest Integer is ...

Offline grindalf

  • Full Member
  • ***
  • Posts: 152
Re: maximum seed
« Reply #8 on: May 22, 2019, 08:10:09 AM »
millisecond is great if you want it to be different everytime but I need the worlds to be the same each time

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal