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];
permutation[random] = permutation[i];
permutation[i] = tmp;