RNG & Drop Table
Random Number Generator (RNG)
The Wind Waker makes use of the Wichmann-Hill Pseudo-Random Number Generator (PRNG), presented in pseudocode as follows:
double rng() {
static int s1 = 100, s2 = 100, s3 = 100;
s1 = (171 * s1) % 30269;
s2 = (172 * s2) % 30307;
s3 = (170 * s3) % 30323;
return fmod(s1/30269.0 + s2/30307.0 + s3/30323.0, 1.0);
}
This generator makes use of three linear congruential generators that are then combined to produce a distribution between zero and one. This generator is initialized on console reboot to s1 = s2 = s3 = 100, a fixed initial seed. The values of (s1, s2, s3) at any given time determine what the next value of the random number generator will be. We can call this the "state" of the random number generator. Each iteration of the RNG will advance the seed values and generate a new random return value. The first few steps of this process can be seen below:
| RNG | |||
| s1 | s2 | s3 | return value |
| 100 | 100 | 100 | 0.6930906199656834 |
| 17100 | 17200 | 17000 | 0.5253911237999249 |
| 18276 | 18621 | 9315 | 0.1491021216452075 |
| 7489 | 20577 | 6754 | 0.9526796411193339 |
| 9321 | 23632 | 26229 | 0.8229855100670485 |
| 19903 | 3566 | 1449 | 0.8003992983171554 |
| ... | ... | ... | ... |