Posted: 10th Sep 2011 6:10
I'm working on trying to seed my random number generator and found that using Timer() doesn't exactly get me the results I want. Does anyone have a good way of doing it? If we had access to get System Time I would go with that but since that doesn't exist I will need to go with some math functions. Trying to see if there is a way to code the Mersenne twister in this.
Posted: 10th Sep 2011 8:20
Hi

From how I understand it, when you use the Timer() to seed the random number the timer() part only starts when your app starts hence you get the same results, the easy way to use it is to have the user tap the screen to start the game then seed the random number as this at least creates a slight difference in the seed number as the player will not always tap the screen at the same time.

That is the easiest way I've found but like you say system time would be better if it existed.

Hope this helps some.

Scotty
Posted: 10th Sep 2011 15:08
This is what I came up with after doing a little reading on the subject. It's better than nothing I guess at the moment and seems to produce acceptable results.

+ Code Snippet
FUNCTION SetRandomization()
    gen1 = Random(1,65000)
    gen2 = gen1*gen1
    gen1 = Random(gen1,gen2)
    gen1 = gen1*timer()
    SetRandomSeed(gen1)
ENDFUNCTION
Posted: 11th Sep 2011 0:28
Another cool trick is to tie the generation of the seed value with some user defined amount of time (such as the time it takes for the user to press BEGIN on the title page). You can then use the Timer() command which will always return a slightly different value each time the game is started.