Build an Epidemic Model (part 1 of 8)

Tagged:

In this tutorial we will create a simple model of an epidemic - a model in which red agents represent sick individuals and green agents represents healthy individuals. When a red individual touches a green one, the green one will get sick. Then we add a recovery variable that can be adjusted by the user and graph the changing number of sick and healthy agents.

Setup

First, we’ll create some agents and put them on the screen. Move to the Setup portion of the canvas, either by scrolling to that section or using the minimap at the top of the screen. Grab a Clear Everyone block from the Setup and Run tab of the Block Factory and drag it onto the Setup area.

Click on My Blocks and then click on the Turtles tab. Drag out a Create Turtles and Do block and attach it beneath the Clear Everyone block. When the Create Turtles and Do block comes out it has the number 10 attached to it. Change that number to something between 100 and 500 (use smaller numbers on slower/older systems).

Inside the Do section of that block grab a Set Color block from the Traits tab in the Factory. Attach the Set Color block to the Do section and change the color from Red to Green by clicking on the drop down menu that appears when you hover over the Red block.

Now open the Turtle's tab again and grab a Scatter Turtles block and attach it to the bottom of the stack.

Finally, go to the Setup and Run tab of the Factory and grab a Setup block and put the stack that you created inside of the Setup block.

The Setup block runs once to set the initial conditions of the simulation. In this case, we want to delete all agents from the previous run, create 500 turtle agents and set their color to green (to represent 500 healthy individuals), and scatter them randomly in Spaceland. Note that turtles are the default agent, but both the name and shape can be changed in the Breed Editor.

Click on Edit Breeds button near the top of the canvas to open the Breed Editor. Select the Basic Shapes category and choose the sphere shape. Click OK.

To test the Setup block, look at the Runtime space connected to Spaceland. You should see a button named Setup. Click it and you will see the agents created and dispersed.

Next: Part 2 of 8 - Seeding the Infection Back To Top