Skip to content

IvanHornung/Pandemic-Simulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

96 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pandemic Simulator

by Ivan Hornung

Featured in Austrian government-funded art festival "No-Place Like The Future"

Click to see the short film Click to see the short film

About

With COVID-19 terrorizing the world, I decided to create a simulative environment that would demonstrate coronavirus-like conditions and traits. This simulator implements artificial life creatures, Boids, to realistically simulate disease spread.

One may need to adjust the initial Boid count depending on the device. Found in the BoidRunner.java file:

public class BoidRunner extends JPanel implements KeyListener, MouseListener, MouseMotionListener  {
        private static final long serialVersionUID = /**/;

        public static final int BOIDCOUNT = 1200; //CHANGE THIS VALUE

Comments/explanations to the source code to be released soon.


Boids

Boids are artificial life objects first developed by Craig Reynolds in 1986 that collectively mimic the behavior of bird flocks or fish schools. They contain three basic steering mechanics:

  • Alignment - steer to match the average velocity of its neighboring Boids.
  • Cohesion - steer toward the average position of its neighboring Boids.
  • Separation - keep a distance from each Boid to prevent crowding.

Types of Boids

Healthy

Marked with a white color.

  • Almost all Boids begin the simulation as healthy.
  • Healthy Boids are susceptible to infection and demonstrate all three steering mechanics (alignment, cohesion, and separation).
  • Each healthy Boid has its unique immunity value within a given range.
  • If a Boid's immunity level reaches zero, the Boid becomes infected.
  • If a Boid is healthy, it gains immunity from each other healthy Boid within its perception radius by a value that is inversely proportional to the distance between them. This is one of the herd immunity principles in this simulation.
  • Altogether, they behave as a peaceful and undisturbed flock.
  • Once in a while, a new, healthy, community member joins the grid. New healthy community members are also summoned when a dead Boid's body is cleared.
  • Boids do not want to be clustered in groups of larger than 40.
  • Can be artificially summoned by pressing the R key.

Infected

Marked with a red color.

  • There is always at least one infectant in the simulation.
  • Decreases the immunity value of healthy Boids in its perception radius by a value that is inversely proportional to the distance between them.
  • An infected Boid behaves just like a healthy Boid steering-wise (infection may be interpreted as a contagious incubation period).
  • Healthy Boids cannot tell if a Boid is infected or not.
  • Each infected Boid has its lifespan. If the lifespan falls to zero over time, the Boid's fate is decided using real-world COVID-19 statistical death rates.
  • If the fate decides death, the Boid undergoes death, else the Boid recovers.
  • An infected Boid has the chance to undergo diagnosis.
  • Can be artificially summoned by pressing the F key.

Recovered

Marked with a light blue color.

  • A Boid recovers if there previously were an infected Boid that survived the 14% mortality when their lifespan reached zero.
  • A Boid can also become recovered if they received paramedic treatment in time.
  • A recovered Boid shares the same steering mechanics as a healthy boid.
  • A recovered Boid is immune to the pandemic disease for a relatively long length of time.
  • A recovered Boid is not considered to be healthy count-wise.
  • Can be artificially summoned by pressing the T key.

Dead

Marked with a purple color.

  • If an infected Boid's infection lifetime reaches zero and undergoes the 14% mortality chance, the Boid then dies.
  • A dead Boid is left to rot on the ground for a calculated period of time.
  • A dead Boid is contagious.
  • All Boids try to avoid dead Boids (except for on-duty paramedics).
  • Can be artificially summoned by pressing the G key.

Diagnosed

Marked with a dark red color.

  • There is a chance that an infected Boid becomes diagnosed within its infection lifetime.
  • If a Boid is diagnosed, it is publicized to the entire Boid community and all Boids but on-duty paramedics avoid the Boid, even infected Boids.
  • There is a chance (dependent how large depending on the total current amount of diagnosed Boids in the simulation) that a diagnosed Boid becomes the current patient.
  • If the Boid is the current patient, paramedics rush to treat it.
  • If the Boid is the current patient, it signals a blinking effect.
  • If the diagnosed Boid is treated by paramedics, it becomes a recovered Boid.
  • A diagnosed Boid tries to reach toward any rushing paramedics, even if the Boid is not the patient.
  • Can be artificially summoned by pressing the H key.

Paramedic

Marked with a dark blue color.

  • There are always at least 3 paramedics on the grid while there a diagnosed Boid present.
  • Paramedics behave like normal Boids until one person in the community becomes diagnosed.
  • If one person is diagnosed, the paramedics change to an emergency state, where they turn on their sirens and rush to the position of the patient in need.
  • When paramedics are in an emergency state, they do not undergo any form of separational steering from other Boids (including dead).
  • The longer the distance the patient is from the paramedics, the more acceleration they give to reach the patient in time.
  • Paramedics decelerate significantly when in close contact with the patient.
  • Boids surrounding a paramedic in an emergency state attempt to make way for the paramedic to pass.
  • If the paramedic is in close contact with the patient, the patient undergoes the curing process, and will most likely be treated and recover. The more paramedics in immediate contact with the patient, the faster the curing process takes.
  • If the patient gets cured, a new patient is chosen, assuming there are more diagnosed Boids on the grid.
  • While paramedics have significantly high immunity values relative to normal Boids, they are never immune to the disease and can end up becoming infected.
  • Paramedics create a "pop effect" after curing a patient.
  • More and more paramedics are called depending on the infection/noninfection ratio.
  • Paramedics are slowly removed if the proportion to infected/noninfected is less.
  • Can be artificially summoned by pressing the Y key.

Paranoid

Marked with a pastel green color.

  • A Boid becomes paranoid by a random chance that increases as more total boids are infected relative to the total community size.
  • Once a Boid becomes paranoid, the only way it can lose the paranoia is to undergo infection and recovery
  • If a Boid is paranoid, it loses all trust in everybody and attempts to distance itself from every Boid as if they were all dead bodies.
  • aka the social distancing Boid.
  • Can be artificially summoned by pressing the U key.

Additional Features

Keybindings

Key/Button Action
Click adds a new healthy Boid to the click location
; decreases the separation force between Boids 1
P increases the separation force between Boids 2
\ clears the grid of all Boids3
E hides the counter
Q shows the counter
R artificially summons a healthy Boid
F artificially summons an infected Boid
T artificially summons a recovered Boid
G artificially summons a dead Boid
H artificially summons a diagnosed Boid
Y artificially summons a paramedic Boid
U artificially summons a paranoid Boid
1: can be used to simulate public gatherings.
2: can be used to simulate social distancing.
3: made to be a demonstration/testing environment. (Note: there is always at least one infectant, and Boid spawn naturally).

Music and Sounds

Key/Button Action
/ stops the main music (plague.wav)
. restarts the main music 1 (plague.wav)
W turns off sound effects listed below
1 triggers newpatient.wav to play
2 triggers recovery.wav to play
4 triggers death.wav to play
3 triggers immunitylost.wav to play
5 triggers diagnosis.wav to play
6 triggers paranoia.wav to play
7 triggers paranoiaEnded.wav to play
8 triggers treatment.wav to play
9 triggers deathmilestone.wav to play
0 triggers intensity.wav to play
B triggers bell.wav to play
N triggers ambulance.wav to play
1: only do this if you have turned off the music already, otherwise there will be two tracks playing simultaneously

Sound Meanings

plague.wav plays when the simulation initiates or when the . key is pushed.

newpatient.wav plays when a healthy Boid becomes infected.

recovery.wav plays when an infected Boid recovers.

immunitylost.wav plays when a recovered Boid's immunity wears off, thus turning into a healthy boid.

death.wav plays when an infected Boid dies.

diagnosis.wav plays when an infected Boid becomes diagnosed.

paranoia.wav plays when a healthy Boid becomes paranoid.

paranoiaEnded.wav plays when a paranoid Boid becomes infected.

treatment.wav plays when a diagnosed Boid receives paramedic treatment and becomes recovered.

deathmilestone.wav plays whenever the death count reaches a multiple of 100.

intensity.wav plays when more than 80% of the Boids are infected.

bell.wav plays when a paramedic gets infected, or when all Boids on the grid are removed via the \ key.

ambulance.wav, ambulance2.wav, ambulance3.wav play whenever paramedics turn on their sirens to treat a diagnosed Boid.