Get random seed value in p5.js?

Until randomSeed() is invoked for the 1st time there’s no seed yet, so random() merely invokes JS builtin Math.random() till then:

The local constant randomStateProp contains the string name of the “secret” seed property:

And that property is initialized w/ null by default:

We can log that property like this: print(_lcg_random_state);

AFAIK that “seed” algorithm is used by both Java Mode & Pjs flavors as well.

1 Like