}
public Random(int Seed) {
- int ii;
+ int ii = 0;
int mj, mk;
//Initialize our Seed array.
SeedArray[55]=mj;
mk=1;
for (int i=1; i<55; i++) { //Apparently the range [1..55] is special (Knuth) and so we're wasting the 0'th position.
- ii = (21*i)%55;
+ if ((ii += 21) >= 55) ii -= 55;
SeedArray[ii]=mk;
mk = mj - mk;
if (mk<0) mk+=MBIG;
}
for (int k=1; k<5; k++) {
for (int i=1; i<56; i++) {
- SeedArray[i] -= SeedArray[1+(i+30)%55];
- if (SeedArray[i]<0) SeedArray[i]+=MBIG;
+ int n = i + 30;
+ if (n >= 55) n -= 55;
+ SeedArray[i] -= SeedArray[1 + n];
+ if (SeedArray[i]<0) SeedArray[i]+=MBIG;
}
}
inext=0;