Last year was a tough year for all of us. When the COVID-19 pandemic arrived, many people all over the world were feeling uncertainty and fear. Some of us even had to bear pain and grief after coming into close contact with the virus.

I was fortunate enough to have been in good health. Likewise, I had a stable job for which I could work from home. At the time, the latest research and mysteries surrounding the virus became a hot topic in the news. And from my position of relative safety, I became quite fascinated with how the virus was spreading.

New analyses along with charts, information, and advise were popping up all over the internet. One prominent notice was “the curve” of the pandemic, along with the slogan “Flatten the curve!”. It lead me to wonder if the curve could be visualized in a programmatic petri dish, so to speak. It was early summer 2020, and I was bored at home and in need of a new personal project. So, I decided to make a simulator to model virus spread.

My intention was to keep the simulator simple. My objective was to get the basics down: movement of a population, modeling of virus contact and spread, and the tracking of phases of sickness with a graph. There are many aspects of the real life corona virus that are hard to model. Therefore I made many assumptions, such as a mortality rate of 20%, and a 100% spread rate on contact. In real life, these factors can vary greatly depending on the circumstances, but for now these were beyond the scope of my project.

The main feature of my simulator, however, was a social distancing mode. When social distancing mode is off, people (and thus, the virus) can move freely. When social distancing mode is on, people are greatly restricted in movement. I added the feature to see if social distancing would have an impact on the pandemic curve…

So, does social distancing work? Go and see for youself.

A run of the pandemic simulator without social distancing:

A run of the pandemic simulator with social distancing:

During this project I managed to retest my Java programming skills, in particular, the solving of graphics and gaming related problems. The main challenges I faced were: handling of collisions, running a thread for rendering graphics at a stable frame rate, running a thread for motion vector calculations, and the tracking of sickness in order to plot the pandemic curve. All in all, a great learning experience.

If you are interested, download the code and test it yourself: