Dark theme

Modelling deadly diseases

 

Of course, most diseases aren't like the Zombie Bite disease. Most people don't usually stay infectious and wander around infecting other people forever; they either get better or die (there are some exceptions).

1) The simplest case is when people die after a certain amount of time. Here's some code to model that. It requires a third costume, called "dead", which is a black circle, plus a new variable "infectedTime". This variable, unlike the others, should be set to "For this sprite only" so each has its own copy with different values in it.

Screenshot: Deadly code

Note that "stop this script" stops that particular sprite but leaves the others running. Note also that the new if block has a quite complicated condition, which is built up like this:

Screenshot: Deadly condition

If checks whether a certain amount of time (5 seconds) has gone by since the sprite was infected and also checks whether the sprite is red. If we didn't do the last bit all the sprites would die 5 seconds into the model run, as we set the infectedTime to zero at the start. The infectedTime is updated at the same time the sprites go red.

Note that you may have to end your model run manually by pushing the red stop button next to the green flag in the top-left corner of scratch.

 

2) We now have a new value (or model "parameter") to play with - how fast the sprites die (5 seconds, in the above). Have a play around with this. You might imagine that a short time to death was always worse for everyone; is that the case? If not, why not? How does this relate to, for example, how the government deals with potentially deadly diseases in cattle like Foot and Mouth, and the risks associated with Ebola in humans?

When you're done head back to the start page.