Do you keep hearing phrases like “social distancing” and “flatten the curve” in the news? What do they mean? Why are they important? In this activity, you will use the kid-friendly programming language Scratch to write a simulation that uses bouncing dots to represent healthy and sick people. The simulation will show how we can take measures to slow the spread of a transmissible disease like COVID-19.

Time: 1-2 hours

Key Concepts: Programming, disease transmission, social distancing
All you need is your MacBook with access to Scratch


Prep Work

1. Create an account at

2. Optionally, if you have never used Scratch before, you can follow some of their tutorials.



  • Watch this video for an overview of how to create a basic COVID-19 simulator in Scratch:


  • Now, you can either start with a blank project of your own, or you can “remix” this Science Buddies Scratch project. You can also run the simulation here:

  • Once you have a working simulation, explore the effects of social distancing.
  • What happens if you increase the number of “people” in the simulation? To do this in the Science Buddies project, increase the “num_clones” variable.
  • What happens if the people in the simulation practice social distancing? To do this in the Science Buddies project, increase the second number in the “pick random 1 to 1” block. Question: Why is social distancing important to help slow the spread of infectious diseases like COVID-19?
  • See the Further Exploration section suggestions about more things you could add to your program.

What Happened?

In your Scratch simulation, people are represented by colored dots that bounce around the screen. Green dots are healthy and red dots are sick. The virus is passed between dots that touch each other, representing close personal contact. When all the dots are moving around, they bump into each other very frequently, allowing the virus to spread rapidly. When people “stay home” (some of the dots hold still), it takes much longer for the virus to spread.

Digging Deeper

Infectious diseases like COVID-19 are spread primarily through close person-to-person contact, including through droplets people emit when they cough or sneeze. This means that you are at the highest risk for catching the virus through daily contact with other people, like shaking hands with a sick person or sitting next to a coughing person on the bus. Once you are infected with the virus, you, in turn, can spread it to others. This is why social distancing—avoiding large gatherings, and staying at least 6 feet away from others in public places—is important to help slow the spread of the virus. Slowing the spread of the virus means that, at any given time, fewer people overall will have it. This, along with other preventative measures like frequent hand washing, helps “flatten the curve,” and keep the total number of sick people below our healthcare system’s capacity. You can visualize this effect by implementing social distancing in your Scratch simulation, which slows the rate at which the virus spreads.


Further Exploration

  • Add a timer and make your program stop when every person is infected.
  • Add counters for the number of healthy and sick individuals in your simulation.
  • Add recovery to your simulation, so individuals eventually get better (or die) after they become infected.
  • Make the dots bounce off of each other instead of passing through each other.
  • Add an animated graph showing the number of healthy/infected (and recovered/dead) individuals over time.
  • Include a “super spreader” (a dot that moves faster than all the other ones).



Ben Finio, PhD, Science Buddies