Sets the seed value for py5’s random functions.


1def setup():
2    py5.random_seed(42)
3    a = py5.random()
4    py5.random_seed(42)
5    b = py5.random()
6    # the values a and b will be the same
7    py5.println(a, b)
1def setup():
2    py5.random_seed(0)
3    for i in range(100):
4        r = py5.random(255)
5        py5.stroke(r)
6        py5.line(i, 0, i, 100)


Sets the seed value for py5’s random functions. This includes random(), random_int(), random_choice(), and random_gaussian(). By default, all of these functions would produce different results each time a program is run. Set the seed parameter to a constant value to return the same pseudo-random numbers each time the software is run.


random_seed(seed: int) -> None


  • seed: int - seed value

Updated on September 11, 2021 16:51:34pm UTC