This page was automatically generated by NetLogo 5.0.4.

The applet requires Java 5 or higher. Java must be enabled in your browser settings. Mac users must have Mac OS X 10.4 or higher. Windows and Linux users may obtain the latest Java from Oracle's Java site.


In order for this to work, this file, your model file (myFireModel7.nlogo), and the files NetLogoLite.jar and NetLogoLite.jar.pack.gz must all be in the same directory. (You can copy NetLogoLite.jar and NetLogoLite.jar.pack.gz from the directory where you installed NetLogo.)

On some systems, you can test the applet locally on your computer before uploading it to a web server. It doesn't work on all systems, though, so if it doesn't work from your hard drive, please try uploading it to a web server.

You don't need to include everything in this file in your page. If you want, you can just take the HTML code beginning with <applet> and ending with </applet>, and paste it into any HTML file you want. It's even OK to put multiple <applet> tags on a single page.

If the NetLogoLite files and your model are in different directories, you must modify the archive= and value= lines in the HTML code to point to their actual locations. (For example, if you have multiple applets in different directories on the same web server, you may want to put a single copy of the NetLogoLite files in one central place and change the archive= lines of all the HTML files to point to that one central copy. This will save disk space for you and download time for your users.)

powered by NetLogo

view/download model file: myFireModel7.nlogo

WHAT IS IT?

(a general understanding of what the model is trying to show or explain)

HOW IT WORKS

(what rules the agents use to create the overall behavior of the model)

HOW TO USE IT

(how to use the model, including a description of each of the items in the Interface tab)

THINGS TO NOTICE

(suggested things for the user to notice while running the model)

THINGS TO TRY

(suggested things for the user to try to do (move sliders, switches, etc.) with the model)

EXTENDING THE MODEL

(suggested things to add or change in the Code tab to make the model more complicated, detailed, accurate, etc.)

NETLOGO FEATURES

(interesting or unusual features of NetLogo that the model uses, particularly in the Code tab; or where workarounds were needed for missing features)

RELATED MODELS

(models in the NetLogo Models Library and elsewhere which are of related interest)

CREDITS AND REFERENCES

(a reference to the model’s URL on the web if it has one, as well as any other necessary credits, citations, and links)

CODE

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; declarations
globals
[
  initial_trees
  initial_grass
  burned_trees
  burned_grass
  fire_dataList ; list of sizes of fires
  ;treeDispersalDistance
  ;grassDispersalDistance
  ;global_grass_burn_probability
  ;global_tree_burn_probability
  ]

patches-own
[
  ;vegetation_type
  burn_attempt ; boolean
  burned       ; boolean
  pburn_probability; set to be equal to vegetation burn_probability
]

breed [lightning_strikes lightning_strike]
breed [fires fire]
breed [embers ember]
breed [grasses grass]
breed [trees tree]

grasses-own
[
  burn_probability
  time_born
  age
  ]

trees-own
[
  burn_probability
  time_born
  age
  ]

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; set up
to setup
  
  clear-all
  reset-ticks
  set-default-shape trees "dot"
  set-default-shape grasses "dot"
  
  set-default-shape fires "square"
  set-default-shape lightning_strikes "x"
  
  
  ask patches [
  let tree_density random-float 100
  ifelse (tree_density < density) 
   [sprout-trees 1]
   [sprout-grasses 1]
  ]
  
  ask trees [
    set color 64
    set burn_probability global_tree_burn_probability
    set time_born ticks
    set age time_born - ticks + 1 ;; trees are age 1 when born
    ]
  
  ask grasses [
    set color 44
    set burn_probability global_grass_burn_probability
    set time_born ticks
    set age time_born - ticks + 1 ;; trees are age 1 when born
    ]
  
    ask patches [
      set burned false
      set burn_attempt false
      ask grasses-here [set pcolor yellow] 
      ask trees-here [set pcolor green]
      ask grasses-here [set pburn_probability burn_probability]
      ask trees-here [set pburn_probability burn_probability] 
       ]
  
  set fire_dataList[ ]
  ;set initial_trees count patches with [vegetation_type = "tree"]
  ;set initial_grass count patches with [vegetation_type = "grass"]
  
end

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; go

to go
  lightning_ignite
  fire_spread
  vegetation_change
  tick
   
  set-current-plot "Fire"
  set-current-plot-pen "Fire_Plot"
  plot count fires / count patches
  
  clean_landscape
  if ticks >= 100 [stop]
 
  
  set-current-plot "Fire Size Distribution"
  histogram fire_dataList
  
end

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; lightning_ignite
to lightning_ignite
  
  create-lightning_strikes 1 
  [
    setxy random-pxcor random-pycor 
    ifelse (random-float 1 < pburn_probability and burned = false and burn_attempt = false)
      [ 
      ;print "true"
      set color red
      set burned true
      set pcolor black
      hatch-fires 1
      ; ask patch-here [ask trees-here [set breed grass 1] ]; change tree to grass when burned
      
      ]
      [
      ;print "false"
      set burned false
      set color black
      ]
      
    set burn_attempt true 

    ]
    
end


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; fire_fade
to fire_fade
  
ask fires [
  ifelse color < 13
  [
    set color black
  ]
  [
  set color color - 1
  ]

  ]
    
end


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; fire_spread

to fire_spread
   
while [ any? patches with [ any? fires-here and any? neighbors4 with [ burn_attempt = false ] ] ]
[
 fire_spread_oneStep
 fire_fade
]
 
 let fireCount count fires
 set fire_dataList fput fireCount fire_dataList
end 
  
  

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; fire_spread_oneStep

to fire_spread_oneStep
  
  ask fires 
  [
    ask neighbors with [burned = false and burn_attempt = false] 
     [
      ifelse (random-float 1 < pburn_probability)
          [ 
          ;print "false"
          ;set color red
          set burned true
          set pcolor black
          sprout-fires 1 [set color red]
          ]
          [
          ;print "false"
          set burned false
          ;set color black
          ]
       set burn_attempt true 
     ]
  ]
  ;ask fires [print "here"]
 
  
end

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; vegetation_change

to vegetation_change
  
    ; if sum [count trees-here] of neighbors > 0 [

ask patches with [burned = true] [ 
  ask trees-here [
    let grassCount count grasses in-radius grassDispersalDistance
    let treeCount count trees in-radius treeDispersalDistance
    let probGrass grassCount / (grassCount + treeCount)
    
    if random-float 1 < probGrass [
    set breed grasses 
    set pcolor blue 
    set time_born ticks] 
  ]
  ]

ask patches with [burned = false] [ 
  ask grasses-here [
    if age > 5 [
      
    let grassCount count grasses in-radius grassDispersalDistance
    let treeCount count trees in-radius treeDispersalDistance
    let probTree treeCount / (grassCount + treeCount)
    
    if random-float 1 < probTree [
      
      set breed trees 
      set pcolor blue 
      set time_born ticks] ] ]
]
  
end

;ask patches with [burned = true] [ 
;  ask trees-here [
;    if count grasses in-radius 3 > 0 [
;    set breed grasses 
;    set pcolor blue 
;    set time_born ticks] 
;  ]
;  ]

;ask patches with [burned = false] [ 
;  ask grasses-here [
;    if age > 5  and count trees in-radius 3 > 0  [
;      set breed trees 
;      set pcolor blue 
;      set time_born ticks] ] ]
  

;;and any? neighbors with trees = true

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; clean_landscape

to clean_landscape
  
  tick
  
  ask patches [
    set burned false
    set burn_attempt false]
  
  ask fires [die]
  ask lightning_strikes [die]
  
  ask patches [
     set burned false
     set burn_attempt false
     ask grasses-here [set pcolor yellow] 
     ask trees-here [set pcolor green]
     ask grasses-here [set pburn_probability burn_probability]
     ask trees-here [set pburn_probability burn_probability] 
   ]
  
  ask trees [
    set color 64
    set burn_probability global_tree_burn_probability
    set age ticks - time_born + 1 ;; trees are age 1 when born
    ]
  
  ask grasses [
    set color 44
    set burn_probability global_grass_burn_probability
    set age ticks - time_born + 1 ;; grasses are age 1 when born
    ]
  
;  print ticks
  
end