Thanks all! I realize this is maybe a but unusual but I could see a good use here: when working with random values you often want variety (ie randomness) but also to be able to return to something you like. By running random()
with the built-in seed, each time you run the sketch the results are different. But by being able to print that seed (or use it to build a filename for the output) you can return to those exact settings later.
For sure: I could create a seed myself and I do that a lot, but this involves updating that seed manually.
@GoToLoop – thanks for tracking that down! I tried several permutations but _lcg_random_state
always returns null
for me.
Seems like maybe the best option is something like this:
function setup() {
createCanvas(400, 400);
// create a random random-seed :)
let seed = random(0, 10000);
randomSeed(seed);
}
function draw() {
background(220);
// do random stuff
}