pandemic-billiard
JavaScript Canvas Simulation Web
Run the simulation Runs entirely in the browser. Nothing is uploaded.
Particles bounce around a box. Purple ones are susceptible, red ones are infected, green ones have recovered, and the dead simply stop being drawn. Every collision is a chance to pass the infection on, and a second canvas plots the four populations over time as the epidemic runs its course.
Particle count, size and speed set how often anyone meets anyone, recovery time and immunity duration decide how long an infection lasts and whether it can come back, and fatality rate and initial confinement are the two levers that change the shape of the curve. Confinement freezes a fraction of the particles in place.
Written in March 2020, at the start of the COVID-19 pandemic, as vanilla JavaScript on two canvases with no libraries. The source is heavily commented, because it doubled as a way to work out how the pieces of a web page fit together.