Comments/explanations to the source code to be released soon.
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
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.
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.
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.
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.
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).
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.
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.
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.