Virus spread sim

Social distancing: limits amount of movement in the population

Mortality: how likely you are to die during the length of infection. Spread evenly across each iteration for simplicity

Virality: how likely you are to get infected after coming into contact with an infectious person

Immunity last: how much immunity does surviving a virus give you

Length of infection: number of iterations before you recover

First coding the population

Movement

Now lets add social distancing

Now lets make sure that they don't leave the area

Infecting

Most of the checking if someone is infected will be calculated outside of the class

So lets make a couple people to test this

Now lets make one of them infected

Lets make the space a bit smaller

Now lets make it so if two people are in the same square and one has the virus it will have a chance to infect the healthy person depending on the virality

We'll start with just setting off infection if one infected and one healthy person is in the same position

Seems that is works, now lets add some movement

It seems to work but lets make this a bit easier to see

Seems it works now lets add the virality

At the moment virality is set to 1, so there is a 100% chance that an infected person will infect a healthy person in the same square

Lets change it to 0.2, so it will be 20% instead of 100%

As you can see, the end amount of infected is much smaller than the when the virality was 1

Recovery time

As you can see the infected now goes up down due to people recovering

But this is not realistic as people get immunity when getting the virus

As you can see the infected goes to 0 as the people become immune to the disease

Lets record the immunity and the infected

immunity = orange, infected = blue

Now if we change the amount of time the immunity lasts for

As you can see the virus continues

And if we repeat it lots of times it continues on for longer due to the immunity not lasting

Mortality

As you can see people aren't lasting long due to them dying if they are infected

Lets see the dead people

Adding other variables

Now we're going to more variables ie hospitals, natural immuminity, prior health problems, ect

Some of these variables will be applied inside the class and others out

Some variables will affect more than others

Natural immunity

Some people might have a natural immunity to the virus before they get the virus

As you can see if everyone has natural immunity no one will get the virus

But this is very unrealistic so lets tone it down a bit

Now lets compare it to when there is no natural immunity

Now you can see that the deaths are much more

Hospitals

Normally there will be hospitals, which can help people from dying

If a person is in "critical conditions" if they are 2 "spaces" between them and a hospital they will spend the rest of there recovery in the hospital in which they will have a reduced chance of dying

Now that we've the hospitals set lets use them

As you can see hospital's aren't that effective at stopping people from dying due to hospitals not being in all space

So lets add another precautions

Testing, symptoms and self-isolation

In the real world people wont know their infected until they start showing symptoms or get a test

So lets start with testing

We'll change it so at the start people will have houses at the start

Which will also require their houses to be in seperate places so no-one can have houses in the same places

Now lets implement testing

Lets make the testing happen with more time between each test

Now lets make sure people dont come into peoples house when self-isolating

We'll make them just not move if they are about to move into an self-isolating square

Now normaly people won't die if they don't have sypmtoms

So lets quickly make that

We'll also make it so that it if people show symptoms they will get tested

Prior health issues

Now sometimes people will have prior health problems

This will increase the mortality of the disease

Now lets see how many people there are with health problems

Now that we've finished lets run this a few more times

Full code, with comments