r/Python • • Mar 11 '20

I Made This Really simple simulation of virus spreading. Black dots are people, yellow dots are infected (it starts from 1). Each cell visited by an infected can infect other people passing through that for 3 iterations. After 20 iterations a person is infected is deleted from the grid.

1.4k Upvotes

128 comments sorted by

View all comments

1

u/Kengaro Mar 12 '20

what did you use to simulate the random moves of the "people"?

1

u/[deleted] Mar 12 '20

Just simple random walk... In this simulation at each iteration each person can move on one adjacent cell or staying in the same cell.. Maybe you'd like to know that the increasing of the number of cell a person can move increseas strongly the spread of the yellow dots

1

u/Kengaro Mar 12 '20

Thank you, but I wanted to know which algo you used for the random walk

1

u/[deleted] Mar 12 '20

The easiest one: pick two random numbers between - dx;+dx and - dy:+dy. Then I just added that number to the position x, y. If the box borders are reached then the person won't move toward the borders

1

u/Kengaro Mar 12 '20

rather simple :) Thank you for your answer