{"id":21964945,"url":"https://github.com/wesdoyle/python_epidemic_simulation","last_synced_at":"2025-10-07T11:03:37.563Z","repository":{"id":38189871,"uuid":"253340581","full_name":"wesdoyle/python_epidemic_simulation","owner":"wesdoyle","description":"A crude simulation of an epidemic in Python with pygame visualization","archived":false,"fork":false,"pushed_at":"2024-08-12T03:25:37.000Z","size":21524,"stargazers_count":22,"open_issues_count":45,"forks_count":252,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-07T11:02:52.630Z","etag":null,"topics":["epidemic-simulations","pygame","simulation"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wesdoyle.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-05T22:01:30.000Z","updated_at":"2025-07-11T13:38:35.000Z","dependencies_parsed_at":"2023-01-21T00:46:59.407Z","dependency_job_id":"6b9d0426-675e-4923-a20e-62e592a63ed8","html_url":"https://github.com/wesdoyle/python_epidemic_simulation","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/wesdoyle/python_epidemic_simulation","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wesdoyle%2Fpython_epidemic_simulation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wesdoyle%2Fpython_epidemic_simulation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wesdoyle%2Fpython_epidemic_simulation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wesdoyle%2Fpython_epidemic_simulation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wesdoyle","download_url":"https://codeload.github.com/wesdoyle/python_epidemic_simulation/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wesdoyle%2Fpython_epidemic_simulation/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278762930,"owners_count":26041447,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-07T02:00:06.786Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["epidemic-simulations","pygame","simulation"],"created_at":"2024-11-29T12:31:15.956Z","updated_at":"2025-10-07T11:03:37.532Z","avatar_url":"https://github.com/wesdoyle.png","language":"Python","readme":"# Python Epidemic Simulation\n\n## Summary\n\n### This is not a scientifically correct or rigorous simulation. It is used for programming learning purposes only!\n\nThis is a crude simulation of an edpidemic using Python and `pygame`.\n\nThe simulation consists of a 2-dimensional space in which a configurable number of epidemiological hosts move and transmit a contagious state with variable linear velocity.\n\nEach host exists in a state of `unexposed`, `infected`, or `recovered`.\n\n\n## Demos\n\n### No Preventative Measures\n![No measures](./example_gifs/simul_no_measures.gif)\n\n### Shelter In Place - Partial Adherence\n![Shelter in place](./example_gifs/simul_shelter.gif)\n\n### Limit Travel - Partial Adherence\n![Limit travel](./example_gifs/simul_limit_travel.gif)\n\n### Vaccinate, Shelter - Partial Adherence, Variable Drip\n![Reduce travel](./example_gifs/simul_shelter_vaccine.gif)\n\n## Key simulation concepts:\n\n### Basic Laws\n\nThe laws below govern the simulation:\n\n- When initialized, a configured percentage of adherent hosts follow preventative measures.\n- Unless limited by preventative measures, hosts initialize traveling in a random direction in a specified range of speed.\n- If an `unexposed` and `infected` host come into contact, the `unexposed` host becomes `infected`\n- `infected` hosts, while contagious, gradually recover over time\n- All hosts survive\n- After a configurable period of time, an `infected` host becomes `recovered`\n- `recovered` hosts are not contagious\n\n### Preventative Measures\n\nSeveral preventative measures can be simulated. A configurable percentage of the population adopting preventative measure can be chosen. Given a percentage of `PREVENTATIVE_MEASURE_ADHERENCE`, a random sample of the population is chosen to behave accordingly.\n\n#### Shelter In Place\n\nThe `SHELTER_IN_PLACE` preventative measure sets the velocity of adhering hosts to 0 (permanent)\n\n#### Vaccination\n\nThe `VACCINATE_POP` preventative measure provides the adhering hosts with a recovery multiplier. The vaccination for any host provides is a random value between 0 and `VACCINATION_DRIP`, which is added to the recovery constant for any host.\n`VACCINATION_DRIP` is intended to simulate the idea that of the percentage of units that adhere, each vaccinates at a variable time. Vaccination effect takes place immediately, even if a host is in unexposed state.\n\n#### Limit Travel\n\nThe `LIMIT_TRAVEL` preventative measure sets the initial velocity of adhering hosts to 50%\n\n## Running\n\n### Manually run the simulation\n\nPython 3 is required.\n\n- Install dependencies:\n    - `pip install -r requirements.txt`\n\n- Customize parameters\n    - Edit any of the provided values in `constants.py` to change boundary conditions.\n    - the `PreventativeMeasure.SELECTED` array provides the active `PreventativeMeasures`\n\n- Run the simulation\n    - `python universe.py`\n   \nA `Makefile` is provided for convenience.\n\n ## Credits\n \nThank you to [Vue Minh Khue's example](https://github.com/khuevu/pygames/tree/master/bouncingball), from which I adapted basic 2-dimensional particle interactions for simulating collisions between circular objects in `pygame`.\n\n ## Improvements\n \n Improvements, additions, and corrections to the simulation are welcome. Please create a pull request if you would like to contribue.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwesdoyle%2Fpython_epidemic_simulation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwesdoyle%2Fpython_epidemic_simulation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwesdoyle%2Fpython_epidemic_simulation/lists"}