Is this an acceptable method for creating a Seed?

Monkey Forums/Monkey Programming/Is this an acceptable method for creating a Seed?

benmc(Posted 2013) [#1]
I feel like this should be OK, but I'm not sure if I'm overlooking something. I'm trying to create a seed that will be random every time the game is run without using any extra modules.

Does this look OK?

Seed = -Int(GetDate[0] + "" + GetDate[1] + "" + GetDate[2] + "" + GetDate[3] + "" + GetDate[4] + "" + GetDate[5] + "" + GetDate[6])


GW_(Posted 2013) [#2]
I think the common method is grab the 'millisecs' when the user clicks the first button, an old trick from NES days.


Gerry Quinn(Posted 2013) [#3]
RealMillisecs() from diddy.externfunctions seems like the best way to go.

If that didn't work on my target system, I'd save a seed between games.

If I couldn't do that, I'd pull in some entropy from user actions as suggested, but I wouldn't base it on just the first click, but modify the seed periodically based on user actions.

(By the way, if you fear that diddy will change underneath you, you could always make your own module with a similar function, or just always target the same version of diddy.)


Midimaster(Posted 2013) [#4]
1.
I normaly save the Millisecs() value into SaveState() when the user leaves the app. When he restarts I load this value with LoadState() and use it as a seed.

2.
You need no Diddy for doing that! GetDate returns an also good value. But it is sufficient if you use...
Seed = GetDate[5]*1000 + GetDate[6]) 



therevills(Posted 2013) [#5]
Realmillisecs was one of the first things in Diddy, due to the lack of date functions in Monkey at the time... to create a "proper" seed.

I really should change it to wrap the newish date functions to remove the external code.


Paul - Taiphoz(Posted 2013) [#6]
in the past I have done it based on player action, I also tried taking the players current game score at the end of each mission and using that as a seed for the next level, which worked out well as the player score was never really the same each play through.


benmc(Posted 2013) [#7]
Thanks for all the ideas.

In my testing the GetDate method I posted seems to be working perfectly given the seconds and millisecs are on there. I can't really find any reason why it wouldn't be a good idea to do it this way, and it uses straight mojo/monkey so I don't have to load any external modules.