Difference between revisions of "Forest Fire Tutorial"
imported>Andri |
imported>Andri |
||
Line 45: | Line 45: | ||
== Programing the Tree == | == Programing 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 | + | 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: |
<table width="900"> | <table width="900"> | ||
Line 53: | 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 80% chance, I will change into a burning tree myself</td> | + | <td height="150">If I am a healthy tree and I am next to a burning tree, with a 80% chance, I will change into a burning tree myself. This probability 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 50% chance i will turn into a completely burnt tree, to simulate the fire dying out (50% can turn into a " | + | <td height="100">If I am a burning tree, with 50% chance i will turn into a completely burnt tree, to simulate the fire dying out (50% can turn into a "Fire_Die_Out_Probability" simulation property for future experimentation. </td> |
</tr> | </tr> | ||
</table> | </table> | ||
Line 66: | Line 66: | ||
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: |
Line 75: | Line 75: | ||
<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 85: | Line 85: | ||
'''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 to synchronize/parallelize tree burning == | == Programming the Controller to synchronize/parallelize tree burning == |
Revision as of 17:05, 21 August 2011
Contents
- 1 Introduction
- 2 Creating the Project
- 3 Creating Agents
- 4 Creating a Forest
- 5 Programing the Tree
- 6 Programming the Controller to synchronize/parallelize tree burning
- 7 Regenerating the forest with a certain density
- 8 Simulation Properties
- 9 Updating worksheet 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 worksheet to create a forest like the one shown below.
This is a good time to save the world!
Programing 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 to synchronize/parallelize tree burning
|
|
Now try running your simulation again. Stepping through your fire simulation should look like this:
<youtube v="bbAA5qWKX50"/>
Regenerating the forest with a certain density
File:Controller behavior.png |
|
|
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 worksheet to include Controller and Start_Here agents
Add a controller agent and a Start_Here agent to your worksheet as shown below, save your worksheet, and you are ready to start data collection for the Sampling and Bivariate Data Analysis unit.