Page 3 of 3

Re: good seeding for math.random

Posted: Tue Feb 03, 2009 10:26 am
by osuf oboys
It's not weird because changing the seed by 1 changes the first random number only by a little as well. The ranom number is 32 bits or the like and is scaled to the given range (although modulus would have been better) and hence a change in a minute results in no change in the random number 1 to 9. Call math.random once and you should be fine.

Re: good seeding for math.random

Posted: Thu Feb 05, 2009 2:47 am
by Simtex
Some of you are probably familiar with Brain Damage, another Lua based game engine. One of the changes the author made to default Lua behavior was the random number generation, here's what he listed as his reasons:
math.randomseed was provided by Lua, but was overwritten by Brain Damage. The reason I chose to rewrite math.randomseed was to provide a mechanism for seeding the RNG based on the system time in milliseconds, and to use a better RNG algorithm. Currently, Brain Damage uses the SIMD oriented Fast Mersenne Twister (SFMT) pseudo-random number generator.
It might be worthwhile for LÖVE to snag that from Brain Damage (I believe the licenses are compatible).