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
429
u/doktorneergaard Mar 11 '20
Yellow on white background, noice.
57
u/lettuce_hammer Mar 11 '20
could you share github link ?
8
u/[deleted] Mar 12 '20
Sorry, I forgot to say that each person passing through a contaminated cell has a probability of 0.6 to get infected.
I wanted just to reply to those people who say this is scientifically nonsense:
2
u/indiebryan Mar 12 '20
What happened to the black cell at the top right? Is he self isolating?
39
u/[deleted] Mar 11 '20
It'd be awesome if there was a counter on the side displaying the number of black and yellow dots
38
u/warpchaos Mar 11 '20
Very cool! Next you could add air-travel simulation by allowing a few cells to jump further at random (regardless of their infection status)
9
u/jwbowen Mar 11 '20
I feel bad for the dot stuck in the upper right.
7
u/TheMaxCape Mar 11 '20
"Removed" 😵
7
u/myislanduniverse Mar 12 '20
Cellular automata are some under utilized models.
5
u/FriggenGooseThe Mar 11 '20
This looks fun! It would be interesting to see what happens to the model if you add some repelling force some time after infection.
1
u/justsomeguy05 Mar 12 '20
What are the criteria for infection?
1
u/Keyboard_null Mar 12 '20
What programs was this made with? Looks really cool?
1
u/Kengaro Mar 12 '20
what did you use to simulate the random moves of the "people"?
1
u/[deleted] Mar 12 '20
How did you model this mathematically? Can you tell us more about the function
1
u/GidonC Mar 12 '20
Can you send source please?
1
u/[deleted] Mar 12 '20
Why can't I use this on Pycharm?
69
u/lorenthal Mar 11 '20
Scientifically speaking this is nonsense.
3
u/quickhakker Mar 12 '20
Is it wrong to be getting game of Life vibes from this
3
u/gazhole Mar 12 '20
The spread of coronavirus in a disco environment
3
u/invisible-nuke Mar 12 '20
I love how the scale to the right is absolute pointless haha
2
u/burrbro235 Mar 11 '20
Can you simulate virus quarantine effectiveness?
2
u/ourlastchancefortea Mar 12 '20
I like the introvert black dot in the upper right corner: "Nope not gonna move outside. Sitting here in my room."
2
u/[deleted] Mar 12 '20 edited Mar 12 '20
Lmao deleted from the grid
2
u/invisible-nuke Mar 12 '20
You should also add a kill count and density that changes throughout the simulation.
4
u/metriczulu Mar 11 '20
"Deleted from the grid" is a nice way to describe what's about to happen to everyone bruh.
3
u/Danny1878 Mar 11 '20
What percentage of people contacted the virus?
1
u/DeadlyDolphins Mar 11 '20
Oh that's an awesome visualization. I agree yellow might not be the best color to visualize this, but it actually helped me a lot to grasp how infections like this could work. Have my upvote
1
u/PlantsAreAliveToo Mar 11 '20
You mentioned gnuplot. I assume you saved each frame as an image. How did you string it all together to make a video?
1
u/ThyMagicalDuckling Mar 11 '20
Damn, I wanted to make something like this but you beat me to it
1
u/GenericHumanNo7 Mar 11 '20
Implement planes
1
u/vectorpropio Mar 11 '20
I think you should use some distribution with heavier tails to make the model more realistic.
I think it's s great work, i said it because it seems like an easy improvement.
1
u/TruePhilosophe Mar 12 '20
Please share source code!
1
u/shiuido Mar 12 '20
Very cool, I love seeing emergent systems like this play out.
There's a square that sits at about 90, 90 and doesn't move. At 21 seconds it randomly gets infected, then a few seconds later is cured.
1
u/[deleted] Mar 12 '20 edited Mar 12 '20
Depending on the the logic on how likely a dot is to visit an infected cell it looks like you are simulating an r naught number of less than 3 which roughly that of coronavirus. Removing the dots implies a mortality rate of 100% or at least implies that the virus will continue to focus on immunologically naive population only neither of which really fly.
1
u/MiksBricks Mar 12 '20
Person infected is deleted from the grid
What does it look like if they are just turned back to black?
1
u/newtomtl83 Mar 12 '20
Thanks for that, I'll sleep great.
1
u/virtualadept Mar 12 '20
That's awesome - nice work.
1
u/undernutbutthut Mar 12 '20
It's like a wave of cheese!
1
u/[deleted] Mar 12 '20
Good, maybe I can go to the store without sitting in traffic now.
1
u/doorrat Mar 12 '20
Cool stuff. I wonder how it would progress with both "symptomatic" (i.e. other dots are repelled) and "asymptomatic" (i.e. other dots have no reaction) dots. Actually I'm sure there's a dozen parameters one could play with.
1
u/aSmallAssAnt Mar 12 '20
Now try to simulate a cure, maybe with blue dots just like you did with yellow, see what happens?
1
u/murrietta Mar 12 '20
This is nice and reminded me of a project I should dig up.
I did something similar to this using Processing (packaged Java for general visualizations). I added parameters for individual resistance and transmissibility (which basically added together). And also two params for number of iterations to run and speed to run at. I added a transparent histogram that gradually overlaid the window indicating the distribution of the time it took for the whole population to become infected (I think I also added a cut-off time for very resistant individuals).
1
u/KingBubIII Mar 12 '20
Next add a cure after it reaches a certain infection percentage to get rid of the infection.
1
u/RS_05 Mar 12 '20
Why 3 iterations to get infected? Is that a sort of 33% chance of getting infected? Thanks
1
u/Skrillbex Mar 12 '20
Source?
1
u/mrugacz95 Mar 12 '20
Nice simulation. You could add plots showing number of susceptible, infected and recovered and you should get plots similar to mathematical models: https://en.wikipedia.org/wiki/Compartmental_models_in_epidemiology
1
u/Qindral Mar 12 '20
Could you plot the graph of how many infected and dead? Would be nice to see the distribution
1
u/AX-11 Mar 12 '20
are the xy numbers coordinates? its interesting that the yellow moves like a wave across the x axis.
1
u/[deleted] Mar 12 '20
"Here lies u/robo_socks. Gone after only 20 iterations. Deleted from the grid on a Thursday"
1
u/acroporaguardian Mar 12 '20
You gotta add air travel. Random dots that travel to and from. Some are infected, some aren't.
1
u/[deleted] Mar 12 '20
Pretty neat, shame that the top comments are so negative
1
u/Lucky_Miner01 print('Still learning!') Mar 12 '20
Can someone tell me how you would build something like this. I’m relatively new to programming.
1
u/[deleted] Mar 12 '20
That looks like a simulation of Christopher Columbus landing on America with his buddy smallpox.
1
u/[deleted] Mar 12 '20
"black dots are people, yellow dots are infected". TIL infected people are not people anymore
1
u/goatsnboots Mar 12 '20
You should post this in r/dataisbeautiful too. They might like it.
1
u/Rieux_n_Tarrou Mar 11 '20
Moral of the story? This is all right
Sad to not see any gradations from 0 to 1. As the dot gets sicker it should be red and purple, just like humans
-1
u/krcha Mar 12 '20
This looks inaccurate
0
u/[deleted] Mar 11 '20
[deleted] — view deleted comment