For clouds, use a RNG seed that only changes every 10 minutes.

This allows multi-process deploymentes to keep their clouds in sync.
This commit is contained in:
Stuart Buchanan
2012-11-09 20:25:53 +00:00
parent 54778ee1e1
commit 279445d6bc
8 changed files with 49 additions and 20 deletions
+5
View File
@@ -59,6 +59,11 @@ void mt_init(mt *mt, unsigned int seed)
mt->index = MT_N+1;
}
void mt_init_time_10(mt *mt)
{
mt_init(mt, (unsigned int) time(NULL) / 600);
}
unsigned int mt_rand32(mt *mt)
{
unsigned int i, y;
+7
View File
@@ -47,6 +47,13 @@ typedef struct {unsigned int array[MT_N]; int index; } mt;
*/
void mt_init(mt *mt, unsigned int seed);
/**
* Initialize a new MT state with a seed that only
* changes every 10 minutes. Used to synchronize
* multi-process deployments.
*/
void mt_init_time_10(mt *mt);
/**
* Generate a new 32-bit random number based on the given MT state.
*/