Firebreak NetLogo Model

Produced for the book series "Artificial Intelligence";

Author: W. J. Teahan; Publisher: Ventus Publishing Aps, Denmark.

powered by NetLogo

view/download model file: Firebreak.nlogo

WHAT IS IT?

This model is an extension of the Fire model developed by Uri Wilensky that comes with NetLogo's Models Library. It simulates the spread of a fire through a forest. This model allows the user to add firebreaks, extra forest and ignition points. It also allows the user to import a small area taken from a simulated natural colour satellite image of Ch‰teaubriant, France in order to test out what might happen in a real-life environment.


HOW IT WORKS

The setup button will set up a random forest with the specified density. If the user presses the import forest button, then the satellite image of Ch‰teaubriant, France is imported instead.

The user can start fires at various points by pressing the ignite forest button and then clicking the mouse button at the required location. Alternatively, the user can choose to ignite the fire on a continuous vertical line at the left of the environment using the ignite on the left button. Extra forest can be drawn using the draw forest button, and firebreaks can be drawn using the draw firebreak button.

Pressing the go button will then start the simulation, and the fire will then spread to neighbouring trees in four directions (N, S, E and W) from the initial ignition points. The spread of the fire depends on the density of the surrounding forest. There is no wind being simulated in the model, so the fire can only spread to adjacent trees, and has no ability to jump over an unwooded area (patch).

The fire is implemented using fire turtle agents. The fire spreads in a breadth-first manner similar to the breadth-first search implemented in the Searching Mazes, Missionaries and Cannibals and Searching for Kevin Bacon models. Once a fire agent has ignited its nearest neighbours (if there are any), then it will change its breed to an ember agent, whose colour slowly fades from red to black according to the value of the fire-fade-amount slider, and then it will die.


HOW TO USE IT

First press the setup button. This will create a forest of randomly spaced trees with density as specified by the density slider. Alternatively, to import the satellite image of Ch‰teaubriant, France, press the import forest button.

To start a fire at a specific point, press the ignite forest button and click the mouse button at the required location. To have the fire start at the left of the environment as with the Fire model, then press the ignite on the left button.

To create more forest, press the draw forest button. To create a firebreak, press the draw firebreak button. Firebreaks can be removed using the remove firebreaks button. Burnt forest can be "unburnt" using the unburn forest button. This means that a simulation for the same forest can be run multiple times using different firebreaks and ignition points.


THE INTERFACE

The Interface buttons are defined as follows:

- setup: This will reset the simulation and create a random forest.

- go: This will start the simulation. If there have been any fire ignition points placed in the environment, then the fire will start spreading to adjacent trees.

- draw forest: This will draw more trees where the mouse is subsequently clicked.

- import forest: This will import an environment based on a small area in a satellite image taken of Ch‰teaubriant, France.

- unburn forest: This will restore the trees to the way the forest was before any trees were burnt. Note that this will not work when the satellite image has been imported. To restore that forest, simply press the import forest button again.

- burn all the forest: This will eventually burn all the forest. It repeatedly chooses unburnt trees at random each tick to spontaneously combust, while at the same time spreading the fire from the previously selected trees. When the satellite image is imported, this will end up showing which parts of the image the is-tree? reporter considers to be trees.

- ignite forest: This will set an ignition point where the mouse is clicked from which the fire will start burning. Keeping the mouse down will draw multiple overlapping ignition points. The fire will then spread out once the go button is pressed.

- ignite on the left: The vertical line of fire will be ignited from the left side of the environment. The fire will then spread across to the right once the go button is pressed.

- draw firebreak: This will draw a firebreak coloured dark brown into the environment at the point where the mouse is clicked. To continue drawing the firebreak, keep on clicking the mouse, while at the same time dragging it in the desired direction.

- remove firebreaks: This will remove all firebreaks that have been drawn in the environment.

The Interface monitor and sliders are defined as follows:

- percent burned: This is the percentage of trees that have been burnt.

- density: This is the density of the randomly generated forest when the setup button is pressed.

- firebreak-width: This sets the width of the firebreaks.

- fire-fade-amount: This controls how long a tree remains burning once it has been ignited and has already spread the fire to its neighboring trees.


THINGS TO NOTICE

Notice how much of the forest burns for different density settings. What threshold does the density setting need to be reached so that almost all of the forest gets burned?

Notice what happens when the unburnt forest is used to reset the forest back to the way it was when the setup button was pressed, and then the go button is pressed again. Are the same parts of the forest burnt? If so, then why?

Notice that the turtles do not move. (How can you check whether this is true?) But yet the fire seems to move. How?

Notice which arrangements of firebreaks seem to be best at containing the fire.

Notice which parts of the imported satellite image are confused with trees. How could the is-tree? reporter be improved to make a better categorisation of the image?


THINGS TO TRY

Try drawing firebreaks as the fire is spreading. Often it is very difficult to contain the fire and prevent it from spreading further. Slowing down the simulation using the Interface speed slider can help, but this will also slow down the drawing of the firebreaks.

Try drawing a firebreak from one side of the environment to the other. Then try leaving in some gaps. Also try drawing firebreak circles to see what happens (with ignition points placed inside and outside of the circles).

Load the satellite image for Ch‰teaubriant, France and start the simulation using different ignition points. How well does the simple code for recognizing a tree (i.e. the is-tree? reporter) do at recognizing where the trees in the image are?

Try different ignition points with different configurations of firebreaks. What firebreak drawing behaviour works best at containing the different fires?

Try changing the values of the three sliders to see how this affects the simulation.

Try pressing the unburn forest button while the fire is still spreading.

Try using the BehaviorSpace feature (see Tools menu) to see the affect on the percentage of trees burnt for different slider values.

Try changing the way the fire spreads using the neighbours reporter instead of the neighbors4 reporter in the code. How does this affect the ability of the fire to spread?


EXTENDING THE MODEL

Add wind to the model so that the fire has a chance to "jump" over firebreaks.

Add two types of people agents to the model - firstly, fire-fighters who autonomously fight the fire by creating firebreaks and using water to put out the fire; and secondly, fire-lighters who run around lighting the fire.

Add a further helicopter breed of agent that will fly over the forest with a large water bucket trying to put out the fire.

Add the ability to import any image file, not just the one used by the model.


RELATED MODELS

See the implementation of Breadth First Search in the Searching Mazes, Missionaries and Cannibals and Searching for Kevin Bacon models.


HOW TO CITE

If you mention this model in an academic publication, we ask that you include citations for the original Fire model and for the NetLogo software:
- Wilensky, U. (1997). NetLogo Fire model. http://ccl.northwestern.edu/netlogo/models/Fire. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.
- Wilensky, U. (1999). NetLogo. http://ccl.northwestern.edu/netlogo/. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.

In other publications, please use:
- Copyright 1997 Uri Wilensky. All rights reserved. See http://ccl.northwestern.edu/netlogo/models/Fire for terms of use.

The extension to the model was written by Bill Teahan. To refer to this model in publications, please use:

Firebreak NetLogo model.
Teahan, W. J. (2010). Artificial Intelligence. Ventus Publishing Aps


COPYRIGHT NOTICE

Copyright 1997 Uri Wilensky. All rights reserved.

Permission to use, modify or redistribute this model is hereby granted, provided that both of the following requirements are followed:
a) this copyright notice is included.
b) this model will not be redistributed for profit without permission from Uri Wilensky. Contact Uri Wilensky for appropriate licenses for redistribution for profit.

This model was created as part of the project: CONNECTED MATHEMATICS: MAKING SENSE OF COMPLEX PHENOMENA THROUGH BUILDING OBJECT-BASED PARALLEL MODELS (OBPML). The project gratefully acknowledges the support of the National Science Foundation (Applications of Advanced Technologies Program) -- grant numbers RED #9552950 and REC #9632612.

This model was developed at the MIT Media Lab using CM StarLogo. See Resnick, M. (1994) "Turtles, Termites and Traffic Jams: Explorations in Massively Parallel Microworlds." Cambridge, MA: MIT Press. Adapted to StarLogoT, 1997, as part of the Connected Mathematics Project.

This model was converted to NetLogo as part of the projects: PARTICIPATORY SIMULATIONS: NETWORK-BASED DESIGN FOR SYSTEMS LEARNING IN CLASSROOMS and/or INTEGRATED SIMULATION AND MODELING ENVIRONMENT. The project gratefully acknowledges the support of the National Science Foundation (REPP & ROLE programs) -- grant numbers REC #9814682 and REC-0126227. Converted from StarLogoT to NetLogo, 2001.


PROCEDURES

globals [
  initial-trees   ;; how many trees (green patches) we started with
  burned-trees    ;; how many have burned so far
]

breed [fires fire]    ;; bright red turtles -- the leading edge of the fire
breed [embers ember]  ;; turtles gradually fading from red to near black

patches-own
[ tree?    ;; this is used to "unburn" the forest so that different configurations of fire-breaks
           ;; can be tried on the same forest
  break? ] ;; this is where the firebreaks have been drawn

to setup
  clear-all
  set-default-shape turtles "square"
  ;; make some green trees
  ask patches with [(random-float 100) < density]
    [ set pcolor green
      set tree? true ]
  ; ignite-forest-on-the-left - the user has to now do this explicitly using a button
  ;; set tree counts
  set initial-trees count patches with [is-tree? pcolor]
  set burned-trees 0
end

to go
  if not any? turtles  ;; either fires or embers
    [ stop ]
  ask fires
    [ ask neighbors4 with [is-tree? pcolor]
        [ ignite ]
      set breed embers ]
  fade-embers
  tick
end

to-report is-tree? [colour]
;; Reports true if the colour is a shade of green.

  report ((colour > 50) and (colour < 60)) or ((colour > 60) and (colour < 70))
      or ((colour > 0) and (colour < 9))
end

;; creates the fire turtles
to ignite  ;; patch procedure
  sprout-fires 1
    [ set color red ]
  set pcolor black
  set burned-trees burned-trees + 1
end

to ignite-forest
;; light a fire where the user says to

  if (mouse-down?)
    [
      ask patch mouse-xcor mouse-ycor
      [
        sprout-fires 1
        [
          set color red
          set burned-trees burned-trees + 1
          ask patches in-cone 2 360
          [ sprout-fires 1
            [
              set color red
              set burned-trees burned-trees + 1
            ]
          ]
        ]
        display
      ]
    ]
end

to ignite-forest-on-the-left
;; make a column of burning trees on the left
  ask patches with [pxcor = min-pxcor]
    [ ignite ]
end

;; achieve fading color effect for the fire as it burns
to fade-embers
  ask embers
    [ set color color - fire-fade-amount  ;; make red darker
      if color < red - 3.5     ;; are we almost at black?
        [ set pcolor color
          die ] ]
end

to draw-forest
;; draw some forest
  if (mouse-down?)
    [
      ask patch mouse-xcor mouse-ycor
      [
        sprout 1
        [
          ask patches in-cone 3 360
          [ set pcolor green
            set tree? true
          ]
          die
        ]
        display
      ]
    ]
end

to import-forest
;; Imports the forest from an image.

  ask patches
  [ set pcolor white
    set tree? false ]

  import-pcolors "Chateaubriant_France.png"
  ; import-pcolors "Forest-1.png"
  
  ask patches with [is-tree? pcolor]
  [ set tree? true ]
end

to draw-firebreak
;; draw a firebreak in the forest
  if (mouse-down?)
    [
      ask patch mouse-xcor mouse-ycor
      [
        sprout 1
        [
          ask patches in-cone firebreak-width 360
          [ set pcolor 31 ; very dark brown
            set break? true
          ]
          die
        ]
        display
      ]
    ]
end

to remove-firebreaks
;; removes any firebreaks that have been drawn in the environment

  ask patches with [break? = true]
  [ ifelse (tree? = true)
      [ set pcolor green ]
      [ set pcolor black ]
    set break? false
  ]
end

to unburn-forest
;; to reset the simulation to the forest when the setup button was pressed,
;; but keeping the user-drawn fire-breaks
  ask patches with [tree? = true]
  [ set pcolor green ]
  set burned-trees 0
end

to burn-all-the-forest
;; uses a random algorithm to burn all the forest.

  let this-patch one-of patches with [is-tree? pcolor]
  if (this-patch != nobody)
  [
    ask this-patch
    [
      ignite
      display
      ask fires
        [ ask neighbors4 with [is-tree? pcolor]
            [ ignite ]
          set breed embers ]
      fade-embers
      display
    ]
  ]
end
; Copyright 1997 Uri Wilensky. All rights reserved.
; The full copyright notice is in the Information tab.

; Extended code used for this model: Copyright 2010 Bill Teahan.