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.
The parameters are the interesting part: 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 actually change the shape of the curve. Confinement freezes a fraction of the particles in place — the flattening, in the most literal form it has.
Written in March 2020, for the obvious reason, as vanilla JavaScript on two canvases with no libraries at all. The source is commented far past the point of necessity, because it doubled as a place to work out how the pieces of a web page fit together.