- /* setting initial seeds to mt[N] using */
- /* the generator Line 25 of Table 1 in */
- /* [KNUTH 1981, The Art of Computer Programming */
- /* Vol. 2 (2nd Ed.), pp102] */
-
- if (seed == 0) /* This would make the PRNG procude only zeros */
- seed = 0x6b842128; /* Just set it to another number */
-
- rand->mt[0]= seed & 0xffffffff;
- for (rand->mti=1; rand->mti<N; rand->mti++)
- rand->mt[rand->mti] = (69069 * rand->mt[rand->mti-1]) & 0xffffffff;
+ switch (get_random_version ())
+ {
+ case 20:
+ /* setting initial seeds to mt[N] using */
+ /* the generator Line 25 of Table 1 in */
+ /* [KNUTH 1981, The Art of Computer Programming */
+ /* Vol. 2 (2nd Ed.), pp102] */
+
+ if (seed == 0) /* This would make the PRNG procude only zeros */
+ seed = 0x6b842128; /* Just set it to another number */
+
+ rand->mt[0]= seed;
+ for (rand->mti=1; rand->mti<N; rand->mti++)
+ rand->mt[rand->mti] = (69069 * rand->mt[rand->mti-1]);
+
+ break;
+ case 22:
+ /* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */
+ /* In the previous version (see above), MSBs of the */
+ /* seed affect only MSBs of the array mt[]. */
+
+ rand->mt[0]= seed;
+ for (rand->mti=1; rand->mti<N; rand->mti++)
+ rand->mt[rand->mti] = 1812433253UL *
+ (rand->mt[rand->mti-1] ^ (rand->mt[rand->mti-1] >> 30)) + rand->mti;
+ break;
+ default:
+ g_assert_not_reached ();
+ }