- Art
- Astronomy
- Biology
- Selection and Mutation Series
- Ant Patterns
- Bacterial Growth
- Bark Beetles
- Biological Buffer
- Birds Competing For Worms
- Color Bunnies
- Ecosystem - Predator, Prey, and Grass
- Ecosystem - Rabbits and Grass
- Ecosystem - Two Species
- Ecosystem With Predator, Prey, And Grass
- Forest Fire
- Honeycomb Formation
- Termites Perimeter
- Yeast Growth
- Chemistry
- Earth Science
- Mathematics
- Physics
- Social Science
Forest Fire
Submitted by librarian on Mon, 2006-03-20 18:28. :: Category
Forest Fire by Taylor, Molly & Emily of Santa Fe 8-1-2000
Our project is a model of a forest fire and its behavior, using different types of trees, as well as different factors such as wind, rain and firefighters.
Turtle procedures
turtles-own [energy] ;Each turtle has an energy variable.
breeds [raindrops flames firefighter winds] ;The four types of turtles used in this model are rain, flames, and wind.
;The make-trees button creates a number of tree turtles set by the trees slider, give them random xy positions, and
;executes this procedure.
to make-trees
let [:i 1
:tree-type (pick tree-list)]
repeat 9
[stamp-at 0 :i :tree-type
set :i :i + 1]
set :i 4
repeat 5
[stamp-at -1 :i :tree-type
set :i :i + 1]
set :i 4
repeat 3
[stamp-at -2 :i :tree-type
set :i :i + 1]
stamp-at -3 4 :tree-type
set :i 4
repeat 5
[stamp-at 1 :i :tree-type
set :i :i + 1]
set :i 4
repeat 3
[stamp-at 2 :i :tree-type
set :i :i + 1]
stamp-at 3 4 :tree-type
end
;The flame turtles are given an initial energy of 3, and move forward from their starting position in an expanding circle
;(because Starlogo gives each turtle a heading initially that faces outward from the center). As the flames reach
;tree patches, depending on the type of tree they are given a different amount of energy. The tree is then burned
;and stamped with a brown color for that tree species. This procedure is used for the first few burns, when the model
;is being set up. During the actual run, the burning is carried out by the "burn" procedure below.
to start-burn
if breed = flames
[setc red
setenergy 3
fd 1
if pc = lime [setenergy (energy + 5) stamp 2]
if pc = green [setenergy (energy + 4) stamp 33]
if pc = 62 [setenergy (energy + 3) stamp 34]
if pc = 60 [setenergy (energy + 2) stamp 20 wait .5]]
end
;Like the previous procedure, as flame turtles land on tree patches, they check the color of the patch and act differently
;accordingly. Each different tree type provides a different energy value but also causes each turtle to wait different
;amounts of time as they burn the tree. If the flame lands on an empty patch, they lose energy. If they go below -15
;energy, they die. When they are above 5 energy, they create a new flame.
to burn
if breed = flames
[if pc = lime [setenergy (energy + 5) stamp 2]
if pc = green [setenergy (energy + 4) stamp 33 wait .05]
if pc = 62 [setenergy (energy + 3) stamp 34 wait .1]
if pc = 60 [setenergy (energy + 2) stamp 20 wait .5]
if pc = 0 [setenergy (energy - 4)]
if energy < -15 [die]
if energy > 5 [setenergy (energy / 2)
hatch [seth random 360]]]
end
to turn-fire
if (ycor >= int(screen-height / 2)) or
(ycor <= int((0 - screen-height) / 2)) or
(xcor >= int(screen-width / 2)) or
(xcor <= int((0 - screen-width) / 2))
[die]
end
to rain
if breed = raindrops
[grab one-of-turtles-here
[if (color = blue) and
((color-of partner) = red)
[setenergy-of partner ((energy-of partner) - 17)]]
if pc = lime [setenergy-of pc (energy-of pc + 2)]
if pc = green [setenergy-of pc (energy-of pc + 2)]
if pc = 62 [setenergy-of pc (energy-of pc + 1)]
if pc = 60 [setenergy-of pc (energy-of pc + 1)]]
end
to wind
if breed = winds
[setc 8
seth 315
grab one-of-turtles-here
[if ((breed-of partner) = flames)
[seth-of partner 315 setenergy-of partner (energy + 5)]]]
end
Observer procedures
globals [tree-list]
;Part of the make_fire button's procedure. Uses the start-burn1 procedure to create flame turtles, then sets each
;turtle's heading to 45 degrees.
to start-burn
repeat 10 [start-burn1]
ask-flames [seth 45]
end
;Creates the number of flame turtles based on the value of the fire slider.
to start-burn1
create-flames fire-turtles
ask-flames [start-burn]
end
;This procedure sets up the rain turtles based on the number given by the rain slider. These turtles are given a random
;x position and a y position at the very top of the screen.
to rainy
create-raindrops rain-turtles
ask-raindrops [setc blue setxy ((random screen-width) - screen-half-width) (105)
rain]
end
;Creates a graph to track the four different variables in this model: fire, rain, living trees, and dead trees.
to setup-graph
pp 1 ppreset setppc purple ppd ;living trees
pp 2 ppreset setppc sky ppd ;burned trees
pp 3 ppreset setppc orange ppd ;fire
pp 4 ppreset setppc blue ppd ;rain
setplot-title "Forest Fire"
setplot-yrange 0 500
setplot-xrange 0 500
setplot-xlabel "time"
setplot-ylabel "factors"
viewplot
end
to graph-it
pp 1 plot (((count-pc lime) + (count-pc green) + (count-pc 62) + (count-pc 60)) / 1000)
pp 2 plot ((count-pc 2) + (count-pc 33) + (count-pc 34) + (count-pc 20))
pp 3 plot (count-flames)
pp 4 plot (count-raindrops)
end
;To make the wind, wind turtles are created based on the wind slider. They are given an xy coord in the lower right corner
;(screen-half-width - 35 and 35 - screen-half-height ensure that the turtles are 35 patches in from the lower right corner).
;Then, each turtle moves forward and sets their heading between 90 and 270 (done 10 times), spreading them across in
;a diagonal line. The turtles then randomly either head 45 degrees (towards the upper right) or 225 degrees (lower left) and
;begin to move forward, creating a wind front.
to windy
create-winds (wind-front * 6)
ask-winds [setxy (screen-half-width - 35) (35 - screen-half-height) wind]
ask-winds [repeat 10 [fd 1 seth (random 180) + 90]]
ask-winds [ifelse (random 2) = 0 [seth 45] [seth 225]
fd random wind-front]
end
5132 reads
