Skip to content

Pattern: PRandomWalk

Random walk around list.

Jumps between min and max steps inclusive.

Arguments

values (list): Array of values to walk around

min (int): Minimum number of steps to move

max (int): Maximum number of steps to move

wrap (bool): Whether to wrap around the start/end of the array

Example output

>>> PRandomWalk([ 0, 2, 5, 8, 11 ], min=1, max=2).nextn(16)
[8, 11, 0, 8, 0, 11, 2, 11, 2, 0, 5, 8, 11, 8, 5, 8]