Random numbers

Blitz3D Forums/Blitz3D Beginners Area/Random numbers

Gord(Posted 2005) [#1]
What is the best way top generate a random number which will not repeat a sequence too often?


puki(Posted 2005) [#2]
How about changing the seed whenever you need to throw a random number.


octothorpe(Posted 2005) [#3]
Is there something wrong with SeedRnd(Millisecs()), Rnd(), and Rand()?


Rook Zimbabwe(Posted 2005) [#4]
there was a certain lack of randomness seen or reported as seen by a few... to kill this lack the following was suggested...
SeedRnd MilliSecs()
reseed = Rand(1,1000) ;this compensates for known Random bug (just ask 'Morduun' )
reseed = Rand(1,1000)
SeedRnd MilliSecs()+reseed
At least thats what I have always used and it has seemed to be much more random...


Raitsun(Posted 2005) [#5]
MORE random? that sounds weird...
In Fact Rand() was random enough for me all the time... it is, in fact, VERY random as it gives out a random number...


puki(Posted 2005) [#6]
Well, not using a seed will probably result in predictable behaviour "Raitsun" every time you run your code.


Raitsun(Posted 2005) [#7]
of course i set the seedrnd millisecs(), that seems to be standard and working very well...
the thing is... i don't really know what this reseeding is for...


octothorpe(Posted 2005) [#8]
this compensates for known Random bug (just ask 'Morduun' )

I searched Morduun's posts and could only find that s/he had problems with sets of random numbers from the same seeds not being reproducible on some hardware (i.e. the same program would run differently on some machines.)

From what I read, Morduun ported a Mersenne Twister algorithm to Blitz as a solution to this problem. I didn't see anything about reseeding being necessary or the first call to Rand() not being random.

Rook, please cite something.


Ross C(Posted 2005) [#9]
Reseeding could be used to create random levels, using the seed to select a level.


Sir Gak(Posted 2005) [#10]
Sometimes, you need reproducible random numbers. For instance, if you are writing a top-down, tiled "dungeon" type game, you might find it desirable (because you are too lazy or it is too much work) to generate levels reproducibly based on which level your adventurer is currently exploring. To go back up to a level previously explored, would still find the same layout, but repopulated.