Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Random Number Generator, getting the seed value

Author
Message
XanthorXIII
AGK Gold Backer
12
Years of Service
User Offline
Joined: 13th May 2011
Location:
Posted: 10th Sep 2011 06: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.
Scotty1973
AGK Backer
12
Years of Service
User Offline
Joined: 2nd Jun 2011
Location: Burton-on-Trent, uk
Posted: 10th Sep 2011 08: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
XanthorXIII
AGK Gold Backer
12
Years of Service
User Offline
Joined: 13th May 2011
Location:
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.

LeeBamber
TGC Lead Developer
24
Years of Service
User Offline
Joined: 21st Jan 2000
Location: England
Posted: 11th Sep 2011 00: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.

I drink tea, and in my spare time I write software.

Login to post a reply

Server time is: 2024-04-19 06:13:44
Your offset time is: 2024-04-19 06:13:44