See here.
Starter films: UK Influenza Simulation, Swine Flu Simulation (US)
Make sure breed is set to sphere.
Factory: Add a Setup block
From Setup & Run: Clear Everyone.
From MyBlocks/Turtle: Create Turtles (500).
From Factory: Set Color (green).
From MyBlocks/Turtle: Scatter Everyone
My Blocks: Setup & Run: Choose a Run Once block. Rename it 'infect'.
Add an if/then block from Logic.
Set the test under if (from Math) to Random (100) <= 10.
Set the result (Then part of If block) to Set Color red (from Traits).
From Set up & Run: New Forever block. Change name to 'Run'.
Add forward, left and right from Movement. Set forward to 1 step. Set the turns to random 10.
MyBlocks/Turtles: drag out collision block for Turtles/Turtles (we only have one breed on the board).
Add an if/then block to the first part of the collision block. Set the 'if' part to color of collidee = red. This will need anequals block from Maths and a Color of block from Other Agents. Set the 'then' part to set color red.
Repeat this for the second part of the Turtles collision block.
Add a slider from Setup and Run.
Add a shared number (variable) from the Variables area. Call it 'recovery'. Drag it into the slider. In Spaceland click on the number in the bottom right corner of the slider and set it to 100 so it can be a percentage value.
In the Turtles section of the canvas add a procedure block from Procedures. Call it recover.
Add an if/then block to the procedure. Set the test to random 100 <= recovery (the variable created above).
For the 'then' part add set color green from Traits.
MyBlocks/Turtles: add a copy of the recover procedure block to the Run block (under the left block).
Drag an Agent Boolean variable from Variables onto the Turtles area of the canvas. Call it 'immune'.
MyBlocks/Turtles: new blocks available.
Move to Setup area. Under Create Turtles add an if/else block (under set color green). Set the test to random 100 <= 10.
Set the 'then' part to Set immune true (from MyBlocks/Turtles and Logic).
Set the 'else' part to Set immune false (from MyBlocks/Turtles and Logic).
In the Turtles area add a new procedure block and call it 'check for immunity'.
Add an if/then block. Set the test to turtles immune (from MyBlocks/Turtles) = false (from Logic).
Set the Then part to set color red.
In the Collisions area change the set color red blocks to check for immunity (procedure calls).
Setup area: drag a Monitor block from Setup & Run. Rename it infections.
From MyBlocks/Turtles drag out a Count Turtles With block and slot it into the Monitor.
Add condition color = red to the Count Turtle With block.
From Setup & Run drag out a line graph.
Add 'count turtles with color = red' and 'count turtles with color = green'.
Now a line graph will show changes in the populations of healthy and infected turtles.
How realistic is the model? What happens in real infections? How do infection rates vary between, say, influenza, measles and Ebola?
Videos:
Complete the exercises in this document (Word 2007) or this (Word 2003).
Films:
| Plague & Fire in London | Influenza | Measles |
| Ebola | ||
| Science of Simulating Disease | Modelling Influenza Pandemic | Epidemiological Modelling |