// Simply make a list (0,1,..N-1) and randomize it, seeded with "p".
// Note that this is perhaps not what you want...
for (int i = N; --i >= 0;) {
permutation[i] = i;
}
Uniform gen = new Uniform(new MersenneTwister((int) p));
for (int i = 0; i < N - 1; i++) {
int random = gen.nextIntFromTo(i, N - 1);
//swap(i, random)
int tmp = permutation[random];