Олексій Ігнатенко
to setup
clear-all
reset-ticks
end
to go
tick
end
to go
tick
ask patches [
let num-neighbors-alive count neighbors with [pcolor = white]
if-else (pcolor = white)[
if (num-neighbors-alive < 2 or num-neighbors-alive > 3) [
set pcolor black]
][
if (num-neighbors-alive = 3)[
set pcolor white]
]
]
end
ask patches [
set num-neighbors-alive count neighbors with [pcolor = white]
ifelse (pcolor = white)[
set new-color white
if ((num-neighbors-alive < 2) or (num-neighbors-alive > 3)) [
set new-color black]
][
if (num-neighbors-alive = 3)[
set new-color white]
]
]
ask patches [
set pcolor new-color]
globals [initial-trees]
to setup
clear-all
reset-ticks
ask patches [ if (random 100) < density [ set pcolor green ]
if pxcor = min-pxcor [ set pcolor red] ]
set initial-trees count patches with [pcolor = green]
end
to go
if all? patches [pcolor != red] [ stop ]
ask patches with [pcolor = red] [
ask neighbors4 with [pcolor = green] [set pcolor red ]
set pcolor red - 3.5]
tick
end
to-report fire-patches
report patches with [pcolor = red]
end
ask fire-patches [
ask patches with [pcolor = red] [
ask neighbors4 with [pcolor = green] [
let probability probability-of-spread
let direction towards myself
if (direction = 0 ) [
set probability probability - south-wind-speed ]
if (direction = 90 ) [
set probability probability - west-wind-speed ]
if (direction = 180 ) [
set probability probability + south-wind-speed ]
if (direction = 270 ) [
set probability probability + west-wind-speed ]
if random 100 < probability [ set pcolor red ]]