S
Simon
I have a quick question on the Mersenne Twister (hereinafter MT)
I'm using the standard C code downloaded from the MT website
(http://tinyurl.com/6d8t3). It's being used for a game to generate
random levels, monsters, items and so on, and I want the game to be
different each time I play it.
The standard MT code gives me the same string of random numbers each
time I run it. This is not surprising - computers are deterministic
and it always starts with the same seed. The obvious way to get around
this is to seed the MT with the current time each time the game is run.
Although I appear to have achieved this I'm concerned that I've done
it in a stupid / wrong way.
I've made only one change to the code. In the init_by_array function
I've changed line 79 from:
init_genrand(19650218UL);
to:
init_genrand(time());
As I say, this seems to work fine - whenever I start up the program and
initialise the MT I get a different string of random numbers. However,
it would be great if someone who is familiar with MT could let me know
whether this is a horrific hatchet job or not.
Simon
I'm using the standard C code downloaded from the MT website
(http://tinyurl.com/6d8t3). It's being used for a game to generate
random levels, monsters, items and so on, and I want the game to be
different each time I play it.
The standard MT code gives me the same string of random numbers each
time I run it. This is not surprising - computers are deterministic
and it always starts with the same seed. The obvious way to get around
this is to seed the MT with the current time each time the game is run.
Although I appear to have achieved this I'm concerned that I've done
it in a stupid / wrong way.
I've made only one change to the code. In the init_by_array function
I've changed line 79 from:
init_genrand(19650218UL);
to:
init_genrand(time());
As I say, this seems to work fine - whenever I start up the program and
initialise the MT I get a different string of random numbers. However,
it would be great if someone who is familiar with MT could let me know
whether this is a horrific hatchet job or not.
Simon