globals [
decays ;; # of decays during this tick
last-count ;; this is the number of nuclei at the beginning --
] ;; reset each time a red line is drawn on the plot
to setup
clear-all
set-default-shape turtles "circle"
ask n-of number-nuclei patches [
sprout 1 [ set color cyan ]
]
set last-count number-nuclei ;; remember the starting number of nuclei
set decays 0
reset-ticks
end
to go
;; if all the nuclei have decayed then stop the model
if all? turtles [color = blue - 3]
[ stop ]
set decays 0
ask turtles with [color = cyan]
[ if random-float 100.0 < decay-chance
[ set color yellow
set decays decays + 1] ]
display ;; so the user sees the yellow
ask turtles with [color = yellow]
[ set color blue - 3 ]
tick
end
;;;
;;; plotting procedures
;;;
;; this draws a line at the given x-coordinate
to draw-vertical-line [x-val]
set-plot-pen-color red
plot-pen-up
plotxy x-val 0
plot-pen-down
plotxy x-val number-nuclei
end
;; this draws a line at the given y-coordinate
to draw-horizontal-line [y-val]
set-plot-pen-color green
plot-pen-up
plotxy 0 y-val
plot-pen-down
plotxy ticks y-val
end
; Copyright 1997 Uri Wilensky.
; See Info tab for full copyright and license.