randomSeed() reuse

I still don’t get your question.

What you would do for example is run a program like this:

long seed;

void setup() {
  seed = System.nanoTime(); // Get a random seed (will "always" be different for each execution)
  randomSeed(seed);         // Set the seed of the random number generator
  println(seed);            // Print out the seed used on screen
  
  // Do whatever you want to do to generate your image
 generateImage();
}

If there is an image for which you are happy with, then you can copy the seed written in the console.
Let’s say I run the code for the first time. The seed printed in the console is: 123456. But I don’t like the outcome so I run the program again.
This time the seed is: 987654 and I like the outcome. Then I can save that seed number.
If later on I want to regenerate the same image I will alter the previous code like this:

long seed;

void setup() {
  // seed = System.nanoTime(); // No need for this anymore
  seed = 987654;            // Set the seed to the value that generated the image I liked.
  randomSeed(seed);         // Set the seed of the random number generator
  println(seed);            // Print out the seed used on screen
  
  // Do whatever you want to do to generate your image
 generateImage();
}
2 Likes