Difference between revisions of "Forest Fire Tutorial"
imported>Andri |
imported>Andri |
||
(17 intermediate revisions by the same user not shown) | |||
Line 4: | Line 4: | ||
== Creating the Project == | == Creating the Project == | ||
− | Launch | + | Launch AgentCubes and create a new project (choose the location and name of your project). |
== Creating Agents == | == Creating Agents == | ||
Line 13: | Line 13: | ||
<td> | <td> | ||
<table width="500"> | <table width="500"> | ||
+ | <tr> | ||
+ | <td align="top" height="75">The '''Controller agent''' is used (later on) to synchronize the fire and signal the ground to generate forests of different densities</td> | ||
+ | </tr> | ||
+ | <tr> | ||
+ | <td align="top" height="75">The '''Ground agent''' has one depiction and generates forests of different densities </td> | ||
+ | </tr> | ||
+ | <tr> | ||
+ | <td align="top" height="75">The '''Start Here agent''' is used (later on) as a visual clue during experimentation and data collection for students to start the fire at the same location every time they run an experiment </td> | ||
+ | </tr> | ||
<tr> | <tr> | ||
<td align="top">The '''Tree agent''' has three depictions:</td> | <td align="top">The '''Tree agent''' has three depictions:</td> | ||
Line 18: | Line 27: | ||
<tr> | <tr> | ||
<td align="top" height="75"> | <td align="top" height="75"> | ||
− | + | * a healthy tree<br> | |
− | + | * a burning tree for when the tree is on fire, and<br> | |
− | + | * a burnt tree for then the fire completely goes out. | |
</td> | </td> | ||
</tr> | </tr> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
</table> | </table> | ||
</td> | </td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
− | |||
− | |||
== Creating a Forest == | == Creating a Forest == | ||
− | If you haven't created a new | + | If you haven't created a new world, use the + button at the top of the project window to create one. Please note that later on we will be generating the forest automatically, but for now let's do this manually: Select your Ground agent in the Agents list and using the Volume Insert tool, lay out a layer of Ground agents in the background of your world. Then select your healthy Tree agent shape and using the Draw tool place a few on the Ground. Place one Tree_Burning, which will start the fire, somewhere in the middle of the world to create a forest like the one shown below. |
[[Image:Initial forest.png|350px]] | [[Image:Initial forest.png|350px]] | ||
− | This is a good time to save the | + | This is a good time to save the world! |
− | + | == Programming the Tree == | |
− | + | We need to program the Tree agent to catch on fire if it's next to a burning tree and burn completely when the fire dies out. Select the Tree agent in the Agents list and its behavior will appear in the Behavior view. Create two rules for the tree:, one to start the fire if it's a healthy tree with a certain probability, and one to stop it when the fire dies out with a certain probability: | |
− | == | ||
− | We need to program the Tree agent to catch on fire if it's next to a burning tree and burn completely when the fire dies out. Select the Tree agent in the | ||
<table width="900"> | <table width="900"> | ||
Line 57: | Line 53: | ||
<table width="400"> | <table width="400"> | ||
<tr> | <tr> | ||
− | <td height="150">If I am a healthy tree and I am next to a burning tree, with | + | <td height="150">If I am a healthy tree and I am next to a burning tree, with a certain percent chance, I will change into a burning tree myself. This probability be a number (e.g. 80%) or can also be defined by a simulation property called Fire_Spreading_Probability.</td> |
</tr> | </tr> | ||
<tr> | <tr> | ||
− | <td height="100">If I am a burning tree, with | + | <td height="100">If I am a burning tree, with certain percent chance i will turn into a completely burnt tree, to simulate the fire dying out. This probability can be a constant (e.g. 50%) or can be a "Fire_Die_Out_Probability" simulation property for easier experimentation. </td> |
</tr> | </tr> | ||
</table> | </table> | ||
Line 66: | Line 62: | ||
</tr> | </tr> | ||
</table> | </table> | ||
− | |||
Now try out your simulation by running it. Depending on the density of the forest you created, the fire spreads widely or dies out quickly. | Now try out your simulation by running it. Depending on the density of the forest you created, the fire spreads widely or dies out quickly. | ||
− | '''''But notice something''''': if you reset your | + | '''''But notice something''''': if you reset your world to its original saved state and hit the Step button to run one cycle of the simulation you will get something like this: |
− | |||
<table width="900"> | <table width="900"> | ||
Line 79: | Line 73: | ||
<table width="550"> | <table width="550"> | ||
<tr> | <tr> | ||
− | <td>'''What is wrong with this picture?''' You will notice that trees that are far away from the source (the initial burning tree) catch on fire in the very first step, which is not very realistic (especially given that we are not simulating wind). This happens because | + | <td>'''What is wrong with this picture?''' You will notice that trees that are far away from the source (the initial burning tree) catch on fire in the very first step, which is not very realistic (especially given that we are not simulating wind). This happens because AgentCubes has a random, but explicit order in with it executes the behaviors of the agents in the world. The healthy trees that are in the execution list ''after'' the burning tree, will catch on fire (based on the probability) in the very first step, even if they are far away from the initial burning tree. If it happens that all the trees were placed on the list after the burning tree, all of them would catch on fire in the first step. |
</td> | </td> | ||
</tr> | </tr> | ||
Line 86: | Line 80: | ||
</tr> | </tr> | ||
</table> | </table> | ||
− | |||
'''How can we fix this?''' We need to coordinate the behavior of the tree so that within the same simulation cycle, all the trees have a chance to determine if they should be burning first, and then actually perform the burning actions. For that, we can use a Controller agent to synchronize the tree behavior (make it parallel). | '''How can we fix this?''' We need to coordinate the behavior of the tree so that within the same simulation cycle, all the trees have a chance to determine if they should be burning first, and then actually perform the burning actions. For that, we can use a Controller agent to synchronize the tree behavior (make it parallel). | ||
− | + | == Programming the Controller & Tree to synchronize/parallelize tree burning == | |
− | |||
− | == Programming the Controller to synchronize/parallelize tree burning == | ||
<table width="900"> | <table width="900"> | ||
<tr> | <tr> | ||
Line 99: | Line 90: | ||
<table width="400"> | <table width="400"> | ||
<tr> | <tr> | ||
− | <td height="150">To synchronize the actions of trees, the | + | <td height="150">To synchronize the actions of trees, the '''Controller''' broadcasts to all trees a PERCEIVE message to determine if they are supposed to be burning, followed by an ACT message to actually start burning or have the fire die out. |
</td> | </td> | ||
</tr> | </tr> | ||
Line 106: | Line 97: | ||
</tr> | </tr> | ||
</table> | </table> | ||
− | |||
<table width="900"> | <table width="900"> | ||
<tr> | <tr> | ||
− | <td width="500">[[Image:Tree behavior.png]]</td> | + | <td width="500">[[Image:Tree behavior.png|500px]]</td> |
<td> | <td> | ||
<table width="400"> | <table width="400"> | ||
<tr> | <tr> | ||
− | <td align="top" height="200">The PERCEIVE method of the | + | <td align="top" height="150">The tree does not do anything in its While-Running method. |
+ | </td> | ||
+ | </tr> | ||
+ | <tr> | ||
+ | <td align="top" height="200">The PERCEIVE method of the '''Tree''' determines whether a healthy tree should start burning - it does so if the healthy tree is next to at least one burning tree, with a certain probability (defined by the simulation property Fire_Spreading_Probability in this case). Please note that the PERCEIVE method does not actually set the tree on fire by turning it into a burning tree, but sets a variable/flag to indicate that the tree should be burning. This way, all the trees get a chance to determine whether they should be burning in parallel, avoiding the issue encountered in the previous section. | ||
</td> | </td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
− | <td align="top" height="250">The ACT method of the tree actually carries out the burning: if the tree is healthy and its "burning" flag is set, it turns into the burning tree. Otherwise, if it's an already burning tree, with a certain probability, it turns into a burnt tree and increments the @burnt_trees counter (simulation property) | + | <td align="top" height="250">The ACT method of the tree actually carries out the burning: if the tree is healthy and its "burning" flag is set, it turns into the burning tree. Otherwise, if it's an already burning tree, with a certain probability (defined by the simulation property Fire_Die_Out_Probability), it turns into a burnt tree and increments the @burnt_trees counter (simulation property). |
</td> | </td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
− | <td align="top" height="200">Starting a fire: when | + | <td align="top" height="200">Starting a fire: when a tree is clicked with the mouse tool while holding the Control key, it turns into a burning tree. </td> |
</tr> | </tr> | ||
<tr> | <tr> | ||
Line 132: | Line 126: | ||
</tr> | </tr> | ||
</table> | </table> | ||
− | |||
Now try running your simulation again. Stepping through your fire simulation should look like this: | Now try running your simulation again. Stepping through your fire simulation should look like this: | ||
− | <youtube | + | <youtube>bbAA5qWKX50</youtube> |
− | |||
== Regenerating the forest with a certain density == | == Regenerating the forest with a certain density == | ||
− | |||
<table width="900"> | <table width="900"> | ||
<tr> | <tr> | ||
− | <td width="500">[[Image:Controller | + | <td width="500">[[Image:Controller mouse click.png|500px]]</td> |
<td> | <td> | ||
<table width="400"> | <table width="400"> | ||
<tr> | <tr> | ||
− | <td><BR><BR><BR>To regenerate the forest, we add a method to the Controller's behavior that is triggered with | + | <td><BR><BR><BR>To regenerate the forest, we add a method to the Controller's behavior that is triggered with a mouse click. When the controller is clicked with in the world, it broadcasts to all the current trees in the forest to delete themselves, resets the total number of trees (@trees simulation property) and the number of burnt trees (@burnt_trees) to 0 and sends a "create_forest" message to the ground to generate the new forest. |
</td> | </td> | ||
</tr> | </tr> | ||
Line 154: | Line 145: | ||
</tr> | </tr> | ||
</table> | </table> | ||
− | |||
− | |||
<table width="900"> | <table width="900"> | ||
Line 170: | Line 159: | ||
</tr> | </tr> | ||
</table> | </table> | ||
− | |||
== Simulation Properties == | == Simulation Properties == | ||
Line 183: | Line 171: | ||
<td> | <td> | ||
* Burnt_trees: the number of burnt trees (set to 0 initially) | * Burnt_trees: the number of burnt trees (set to 0 initially) | ||
− | |||
* DESIRED_DENSITY: density your generated forests should have (set to 50% initially; this will change for experimentation) | * DESIRED_DENSITY: density your generated forests should have (set to 50% initially; this will change for experimentation) | ||
* PERCENT_BURNT: percentage of trees that got burnt (set to 0 initially - the simulation will calculate this) | * PERCENT_BURNT: percentage of trees that got burnt (set to 0 initially - the simulation will calculate this) | ||
+ | * Trees: the total number of trees the forest has (set to some number ''other than 0'' initially - the simulation will set it to the right number when you regenerate the forest and you should save your properties with that number) | ||
+ | * Fire_Spreading_Probability: the probability with which fire spreads from a burning tree to a healthy tree | ||
+ | * Fire_Die_Out_Probability: the probability that the fire on a burning tree will die out, making the tree a completely burnt tree | ||
</td> | </td> | ||
</tr> | </tr> | ||
Line 197: | Line 187: | ||
Please note that we capitalized the DESIRED_DENSITY and the PERCENT_BURNT to make it easier for users to tell which simulations properties they need to manipulate or look at for their experimentation. | Please note that we capitalized the DESIRED_DENSITY and the PERCENT_BURNT to make it easier for users to tell which simulations properties they need to manipulate or look at for their experimentation. | ||
− | + | == Updating the world to include Controller and Start_Here agents == | |
− | == Updating | + | Add a controller agent and a Start_Here agent to your world, save your world, and you are ready to start data collection for the [[Sample_Forest_Fire_Lesson_Plans | Sampling and Bivariate Data Analysis unit]]. |
− | |||
− | Add a controller agent and a Start_Here agent to your | ||
− | |||
− |
Latest revision as of 23:44, 24 August 2011
Contents
- 1 Introduction
- 2 Creating the Project
- 3 Creating Agents
- 4 Creating a Forest
- 5 Programming the Tree
- 6 Programming the Controller & Tree to synchronize/parallelize tree burning
- 7 Regenerating the forest with a certain density
- 8 Simulation Properties
- 9 Updating the world to include Controller and Start_Here agents
Introduction
The forest fire simulation built with this tutorial enables you to explore how forest fires unravel by letting you set fires to virtual forests with different tree densities. This simulation can them be used for data collection and analysis in math units.
Creating the Project
Launch AgentCubes and create a new project (choose the location and name of your project).
Creating Agents
The simulation has a Tree agent, a Ground agent, a Controller agent, and a Start Here agent.
Creating a Forest
If you haven't created a new world, use the + button at the top of the project window to create one. Please note that later on we will be generating the forest automatically, but for now let's do this manually: Select your Ground agent in the Agents list and using the Volume Insert tool, lay out a layer of Ground agents in the background of your world. Then select your healthy Tree agent shape and using the Draw tool place a few on the Ground. Place one Tree_Burning, which will start the fire, somewhere in the middle of the world to create a forest like the one shown below.
This is a good time to save the world!
Programming the Tree
We need to program the Tree agent to catch on fire if it's next to a burning tree and burn completely when the fire dies out. Select the Tree agent in the Agents list and its behavior will appear in the Behavior view. Create two rules for the tree:, one to start the fire if it's a healthy tree with a certain probability, and one to stop it when the fire dies out with a certain probability:
|
Now try out your simulation by running it. Depending on the density of the forest you created, the fire spreads widely or dies out quickly.
But notice something: if you reset your world to its original saved state and hit the Step button to run one cycle of the simulation you will get something like this:
|
How can we fix this? We need to coordinate the behavior of the tree so that within the same simulation cycle, all the trees have a chance to determine if they should be burning first, and then actually perform the burning actions. For that, we can use a Controller agent to synchronize the tree behavior (make it parallel).
Programming the Controller & Tree to synchronize/parallelize tree burning
|
|
Now try running your simulation again. Stepping through your fire simulation should look like this:
<youtube>bbAA5qWKX50</youtube>
Regenerating the forest with a certain density
|
|
Simulation Properties
Running your simulation will create the simulation properties used without your explicitly creating them. But especially for the input properties (e.g. Desired_Density), it's good to create them yourself so you can initialize it to the values you want - otherwise, the simulation automatically creates them with 0 as the default value. Pull up the Simulation Properties editor, using Tools->Simulation Properties and add the following properties:
|
Once you have your properties set, make sure you hit the Save button to save them.
Please note that we capitalized the DESIRED_DENSITY and the PERCENT_BURNT to make it easier for users to tell which simulations properties they need to manipulate or look at for their experimentation.
Updating the world to include Controller and Start_Here agents
Add a controller agent and a Start_Here agent to your world, save your world, and you are ready to start data collection for the Sampling and Bivariate Data Analysis unit.