// TODO: find more triplets for different n sclass TripletLSFR { // params int n; int start = 1; int a, b, c; // the triplet // changing variables int step, value; // triplets mask for different n's (TODO) static final int[] triplesTable = {}; *(int *n, int a, int b, int c) { value = start; // handle triplets with 0s (meaning to skip one of the 3 xorshifts) meta-for a in a, b, c { this.a = a == 0 ? n : a; } } int cycleLength() { ret (1 << n)-1; } int next() { int mask = ((1 << n)-1); step = (step+1) & mask; int x = value; x ^= (x << a) & mask; x ^= x >>> b; x ^= (x << c) & mask; ret value = x; } }