Project Report: COVID-19 Spread Simulation in a Realistic City Environment
- Problem Statement
The COVID-19 pandemic revealed the critical importance of understanding how infectious diseases propagate through populations in urban environments. Traditional mathematical models offer high-level insights but fail to visualize or adapt dynamically to behavioral or environmental changes. To address this gap, there is a need for an interactive simulation tool that visualizes how the virus spreads among individuals moving across a realistic cityscape, while considering age-based vulnerability, vaccination, quarantine strategies, and social distancing.
- Our Solution
We present a C++-based simulation that visually models the spread of a virus (inspired by COVID-19) within a city-like environment. Individuals are modeled as agents who move along streets and intersections generated as a grid-based map with additional randomness. Each individual possesses attributes like age, vaccination status, and health state (susceptible, infected, quarantined, recovered). The simulation offers real-time statistical feedback, age-based infection probability, and configurable intervention strategies such as vaccination rate, quarantine policy, and social distancing.
- Tech Stack
Programming Language: C++
Graphics and UI:
SFML (Simple and Fast Multimedia Library) for rendering
ImGui + ImGui-SFML for GUI controls and real-time data display
Build System: g++ with appropriate linking flags for SFML and OpenGL
- Functionalities Explained
4.1 Realistic City Map Generation
The map consists of grid-based intersections representing streets and avenues.
Random nodes are added to simulate parks or crowd zones.
Nodes are interconnected to form a navigable graph with realistic movement paths.
4.2 Agent (Person) Modeling
Each person is modeled with the following key properties:
Position, Velocity, and Movement Path
Age: Influences infection risk
Health State:
Susceptible (at risk of infection)
Infected (can transmit virus)
Quarantined (isolated and non-contagious)
Recovered (immune)
Vaccination Status: Includes effectiveness probability
4.3 Age-Based Infection Logic
Individuals under 10 or over 60 are more likely to be infected due to weaker immunity.
Others have reduced infection probabilities.
Color-coded visualization:
Cyan: Children (<10 years)
Pink: Elderly (>60 years)
Light Blue: Other susceptible individuals
4.4 Infection Spread Dynamics
Infection is proximity-based: closer individuals have higher transmission chance.
Vaccination reduces infection probability by a randomized effectiveness factor.
Social distancing reduces speed and proximity, mitigating spread.
4.5 Quarantine Strategies
Configurable via UI:
Symptomatic Detection (based on probability)
Random Testing
Contact Tracing (infected quarantines traced contacts)
Quarantined individuals cannot infect others and recover after a set duration.
4.6 User Interactions
Control Panel (via ImGui):
Modify simulation parameters (infection rate, population, vaccine rate)
Toggle strategies and behaviors
Add individuals manually
Person Tracking: Click an individual to follow their stats and nearest infected distance
Real-Time Graphs: Display population health distribution over time
- Algorithms and Data Structures Used
5.1 Algorithms
Floyd–Warshall Algorithm: Used for precomputing all-pairs shortest paths between nodes in the city grid. Enables fast pathfinding and dynamic rerouting.
Randomized Monte Carlo Logic: Used for probabilistic infection transmission and strategy simulation (e.g., symptom detection).
5.2 Data Structures
Graph (Adjacency List): Represents the city layout with intersections (nodes) and roads (edges).
2D Vectors (Matrix): Used for distance and next-node matrices in the Floyd–Warshall algorithm.
Dynamic Arrays (std::vector): Store lists of people, paths, and time-series statistics.
Structs and Enums: Represent complex agent states and behaviors efficiently.
- Conclusion
This simulation provides a dynamic and educational tool to understand how virus spreads in a city, highlighting the effects of individual behavior, public health strategies, and demographic vulnerability. It merges agent-based modeling with interactive visualization, making it ideal for both academic demonstration and public awareness.
- Future Enhancements
Implement stacked area chart for epidemic progression
Introduce behavior-based decision making for agents
Add support for masks and varying infection strains
Export statistics to CSV for external analysis
Built With
- c++
- imgui
- sfml
Log in or sign up for Devpost to join the conversation.