Creating the Model
Variables & Breeds First, using our flow chart, we see that we need to declare variables and add sliders to the interface page. The forest will be of varying density, so set up a density slider that will color a certain percentage of the patches to represent a tree on that patch. Call it density and label it with % with trees. The user will set the wind-speed and wind-direction, so build in these two sliders. Think about what an appropriate range of numbers will be for each.
Should the slider start at zero or one? What should be the maximum number? Wind-direction will involve numbers only to 359 since the circle starts at zero and ends at zero not 360. Wind speeds over 100 mph do not occur often enough to be included. The slider for drought may be problematic also. How long is a dry-spell before it is called a drought? Droughts last for years in the west, so what will be your maximum? You might want to put in a units label to show how you are measuring the time without rain.
Now, put in variable for the initial trees and the trees that are burned. Do this by making a globals list. Include the initial trees and the burned-trees. We will use three breeds of turtles in this model – fires, sparks, and embers. We must declare the breeds at the beginning of the program, so make a breeds list containing the three types.
Setup Our setup must have an interface button. Put that in now. Then, go to the procedures page and start the “to setup” procedure. You will clear all using ca.
Now create the forest in the prescribed density by asking all patches to set their pcolor to green if random-float is less than density.
Our flow chart indicates that we need a procedure to create borders. This border will prevent the fire from wrapping as it would in a torus. An easy way to create a border is with the patch color (pcolor). If we change the patch color around the edge and have the turtles die if they get on a certain color we can stop the wrap. The only ones we want a different color are the ones on the screen edge. We really only need to color the top or bottom and one side. What are the coordinates of those patches? Using the primitives dictionary we see how to use screen-edge-x and screen-edge-y. Make the top and the right side blue. Your interface should look like the following:
|