random_seed()#

Sets the seed value for py5’s random functions.

Examples#

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)
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.

Signatures#

random_seed(
    seed: int,  # seed value
) -> None

Updated on March 06, 2023 02:49:26am UTC