Help Page: Help with the Script for Spreading Disease

To check if any healthy turtles are in the same patches as infected turtles, we need another test. There are 3 parts to this: 1) test whether each turtle is healthy; 2) if a turtle is healthy, test whether it is near an infected turtle; and 3) if a turtle is healthy and near an infected turtle, infect it.

Step 1: Test if turtles are infected
Tear off a test statement and add it to your “spreadDisease” script. Once again, we need to check if each turtle is infected. (Keep in mind that all the turtles are from the same breed; thus, each turtle is called “turtle1.”) If the turtle is already infected, that’s great – we don’t need to do anything. If it is not, however, then we need to check whether that turtle is near an infected turtle.

Step 2: Test if healthy turtles are near infected turtles
To do this, we actually need another test statement inside our previous test. The first test told us whether each turtle was infected. Now, we want to test if any healthy turtle is in the same patch as an infected turtle. If so, the healthy turtle should also become infected.

The way to determine if it is in the same patch as an infected turtle is to look at the patch value; remember, we set the patch values where all infected turtles are to 1. Select “turtle1’s patchValueIn” from the “kedama turtle” menu again. This time, we are checking if the patch’s value is one.

If the patchValueIn equals 1, then we need to infect the healthy turtle1.

Step 3: Infecting healthy turtles
We can infect the healthy turtles by adding our “Infect” script from turtle1’s viewer to the “Yes” condition of the test statement. This way, only turtles who are in the same patches as infected turtles will become sick, while healthy turtles who are not near sick turtles will remain healthy.

BACK / RETURN TO MAIN