Adding this here from old forum:
Greetings
Its been a while since I’ve been with netlogo and looking to get back into things and just started to play around with the fire model with the help of Microsoft CoPilot (apologies up front)
Anyhow I am looking to add water silos that help extinguish or hinder fire expansion. I have two codes - the first just added silos that are indestructible to the spread of fire and that is clean and working as I intended.
the second tries to expand on those silos by have them spray water (blue) in are directions 5 patches and thereby potential stopping the spread of fire as if they were empty spaces (patches) not trees.
That second model is close, but the water spreads sporadically and only few patches receive blue instead of a blanket of water in all directions as you can see when model is run
Thank you for the help.
First:
Add indestructible silos
globals [
initial-trees ;; how many trees (green patches) we started with
]
patches-own [on-fire? silo?]
to setup
clear-all
;; make some green trees
ask patches [
if (random 100) < density [
set pcolor green
set on-fire? false
set silo? false
]
;; make a column of burning trees at the left-edge
if pxcor = min-pxcor [
set pcolor red
set on-fire? true
]
]
create-silos
;; keep track of how many trees there are
set initial-trees count patches with [pcolor = green]
reset-ticks
end
to create-silos
let number-of-silos 10 ;; Define the number of silos
ask n-of number-of-silos patches [
make-silo-cluster pxcor pycor
]
end
to make-silo-cluster [x y]
ask patches in-radius 2 [ ;; Create a cluster with radius of 2 (5x size)
if (distancexy x y) <= 2 [
set pcolor violet
set silo? true
]
]
end
to go
;; stop the model when done
if all? patches [ pcolor != red ] [
stop
]
;; ask the burning trees to set fire to any neighboring non-burning trees
ask patches with [ pcolor = red ] [ ;; ask the burning trees
ask neighbors4 with [pcolor = green and not silo?] [ ;; ask their non-burning neighbor trees that are not silos
set pcolor red ;; to catch on fire
set on-fire? true
]
set pcolor black ;; once the tree is burned, darken its color
]
tick ;; advance the clock by one “tick”
end
Second: trying to add water-spray ability:
globals [
initial-trees ;; how many trees (green patches) we started with
]
patches-own [on-fire? silo? water-sprayed?]
to setup
clear-all
;; make some green trees
ask patches [
if (random 100) < density [
set pcolor green
set on-fire? false
set silo? false
set water-sprayed? false
]
;; make a column of burning trees at the left-edge
if pxcor = min-pxcor [
set pcolor red
set on-fire? true
]
]
create-silos
;; keep track of how many trees there are
set initial-trees count patches with [pcolor = green]
reset-ticks
end
to create-silos
let number-of-silos 10 ;; Define the number of silos
ask n-of number-of-silos patches [
make-silo-cluster pxcor pycor
]
end
to make-silo-cluster [x y]
ask patches in-radius 2 [ ;; Create a cluster with radius of 2 (5x size)
if (distancexy x y) <= 2 [
set pcolor violet
set silo? true
]
]
end
to go
;; stop the model when done
if all? patches [ pcolor != red ] [
stop
]
;; ask the burning trees to set fire to any neighboring non-burning trees
ask patches with [ pcolor = red ] [ ;; ask the burning trees
ask neighbors4 with [pcolor = green and silo? = false] [ ;; ask their non-burning neighbor trees that are not silos
set pcolor red ;; to catch on fire
set on-fire? true
]
;; Trigger water spray if fire hits a silo
if any? neighbors4 with [silo? = true and water-sprayed? = false] [
ask neighbors4 with [silo? = true] [
set water-sprayed? true
spray-water pxcor pycor
]
]
set pcolor black ;; once the tree is burned, darken its color
set on-fire? false
]
tick ;; advance the clock by one “tick”
end
to spray-water [x y]
ask patches in-radius 5 [
if (distancexy x y) <= 5 and silo? = false [
if pcolor = red or on-fire? [
set pcolor blue
set on-fire? false
]
]
]
end