Kryzsec  avatar

An Infectious Agent Simulation in PyGame

kryzsec

Published: 10 Mar 2018 › Updated: 10 Mar 2018An Infectious Agent Simulation in PyGame

An Infectious Agent Simulation in PyGame

So in my messing around at school today I decided to build a little infectious agent simulation program with pygame. This is literally version 1 so it looks a little weird and stuff but I find it pretty cool to mess around with, especially to mess around with the config for it.

If the configuration there are 6 major things which I will explain below after you see an example config file.

config.txt
______________________________________
dvr = 0.1
vaccinated = 0.22
infected = 0.08
dinfect = 0.60
dcure = 0.05
vef = 3

This setup is actually the one used in this video. Anyways to explain some of the information present.


DVR

Delta Vaccination Rate: this is the rate at which unvaccinated cells (squares) become vaccinated. Depending on the vef (vaccination effectiveness) will change the importance of vaccination however more on that later. Generally I keep the vaccination rate below that of the infection rate but I have messed with it a couple of times to see what its like the other way.

vaccinated

% tries to vaccinate original population. So there is an initial population of 6400 with the current setup and this rate says that when each cell is initialized (created) it has that percentage of being vaccinated. Lets say it had a value of 0.22 (22%) then with each cell there is a 22% chance it will be vaccinated. This doesn't necessarily mean 22% of the population will be vaccinated but it is likely to be around that much.

infected

This is the same as the vaccinated except it is for the infected.

dinfect

This is the rate at which uninfected cells (in contact with infected cells) have a chance of being infected. So each generation (as I call it) will go and have a chance of being infected proportional to the number of its neighbours that are infected. So with a 60% chance, if a cell has 3 infected neighbours then its chance of being infected is 1-(1-0.6)3 or around 93%

dcure

This is the same as the previous except its the rate at which infected become cured.

vef

Vaccine Efficiency is a rate (direct multiplication) to calculate the rates of these things for vaccinated cells. For instance, with a vef of 3, a vaccinated cell is 3 times less likely to get infected and is 3 times more likely to be cured.

Everything in the config is static (doesn't change over time) though it wouldn't be hard to adjust that. I just thought it would be cool to do something like this and see the results. Originally there were 16384 cells but it had some wacky behaviour though so does this (those diagonal lines)

Honestly, each cell can only interact with the cells directly next to is (that is a total of 4 cells) so I think that the diagonal (and other odd behaviours) are due to an error in how I coded the interaction member function. That being said, the diagonal lines are not always running in the same direction (meaning it could be an honest implementation within the thing and not an error) however with a size allowing for 16384 causes X's to form, however smaller groups (400 cells) creates something more similar to random noise in their patterns.


Kryzsec's Steemit Board


Image Source from nitesh9@nitesh9


Do you enjoy reading or writing topics related to STEM (Science, Technology, Engineering, and Mathematics) then I would suggest checking out steemstem@steemstem! They do wonderful work curating the best STEM related posts on Steemit. For more information check out the SteemStem chat room on steemit.chat or check out their Guidlines and start writing.

Leave An Infectious Agent Simulation in PyGame to:

Written by

Programmer, Engineering student, Science Enthusiest

Read more #vaccine posts


Best Posts From Kryzsec

We have not curated any of kryzsec's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From Kryzsec