Epidemic Simulation
Real-time SIR disease spread simulation with vaccination zones, lockdowns, and virus variants

Overview
A real-time 2D epidemic simulation using an SIR model variant. Agents transition through Susceptible, Infected, Recovered, and Dead states on a dark canvas with glowing infection radii and pulsing rings. Place vaccination zones to immunize survivors, trigger lockdowns to flatten the curve, and introduce virus variants mid-simulation to watch competing strains battle for dominance.
Modeling realistic disease dynamics requires balancing transmission parameters — R₀, mortality rate, infection duration, radius — where small tweaks produce wildly different outcomes. The simulation needed real-time interactivity so users can intervene with public health measures and immediately see their impact on the outbreak curve.
Built as a single-file vanilla JavaScript application with zero dependencies. Agents move with configurable speed on an HTML Canvas, transmitting infection within a visual radius. A full control panel exposes 10+ parameters for tuning outbreak behavior. Vaccination and lockdown zones are placed interactively on the canvas. Virus variants spawn with randomized R₀, mortality, and duration multipliers, each rendered with a distinct color. Real-time R_eff tracking and population charts visualize the epidemic curve.
The simulation produces intuitive demonstrations of epidemiological concepts — herd immunity thresholds, the effect of lockdowns on R_eff, how variants with higher transmissibility outcompete existing strains, and why early intervention dramatically changes outcomes. The dramatic red infection haze visualization makes outbreak severity immediately visceral.
Key Features
Gallery
