Skip to content

Random Walkers

Nawaf Abdullah edited this page Feb 17, 2019 · 1 revision

The class RWPopulation, contained in the script SIM_RandomWalkers.py, allow the user to simulate a population of random walkers in 2d or 3d, can also be self-avoiding, or avoiding other walkers, and detect whether one of the walkers visited the same point visited by another walker, or if they collided.

Usage Example:

# Simulate 6 non-self avoiding walkers and print repeatedly visited coordinates
import random

walkers = []
for i in range(0, 5):
    x = random.randint(0, 3)
    y = random.randint(0, 3)
    z = random.randint(0, 3)
    walkers.append(Walker(x, y, z))
    walkers[i].saw_3d(1000, False)

sys = RWPopulation(walkers)
print(sys.detect_intersection_3d())
sys.plot_3d()

Console out put for the repeatedly visited coordinates:

[(2, 1, 1, 2), (2, 0, 3, 5), (3, 0, 4, 8), (2, 1, 1, 2), (2, 0, 3, 5), (3, 0, 4, 8)]

for the format for every coordinate in the list is: [x-coordinate, y-coordinate, z-coordinate, time step]

Clone this wiki locally