random_seed()
Contents
random_seed()¶
Sets the seed value for py5’s random functions.
Examples¶
1 2 3 4 5 6 7 | def setup():
py5.random_seed(42)
a = py5.random()
py5.random_seed(42)
b = py5.random()
# the values a and b will be the same
py5.println(a, b)
|
1 2 3 4 5 6 | def setup():
py5.random_seed(0)
for i in range(100):
r = py5.random(255)
py5.stroke(r)
py5.line(i, 0, i, 100)
|
Description¶
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.
Syntax¶
random_seed(seed: int) -> None