mercredi 9 octobre 2019

Java Random setSeed() not deterministic

I have a class called 'Face' that creates a static instance of java.util.Random:

public static Random random = new Random();

Then, in Main, I set the seed and get a random value:

Face.random.setSeed(1);
int rand = random.nextInt(len);

The value of 'rand' is different every time I run the program, though. I need it to be the same every time. I thought setting a seed did this, but I must not understand correctly. What am I missing?




Aucun commentaire:

Enregistrer un commentaire