I would like to know the numbers of all turtles died in my pseudo model. How can I do that? I would appreciate very much a simply and fast running solution for that problem, like count dead turtles
.
I was thinking of a routine like this (but do not know how to implement it):
if turtle is dead % checking all turtles if dead or alive
set death_count death_count + 1 % set counter
tick % go one step ahead in model
This is my code sample (without any check so far):
breed [ humans human ]
humans-own [ age ]
to setup
ca
create-humans(random 100)
[
setxy random-xcor random-ycor
set age (random 51)
]
reset-ticks
end
to death
ask humans [
if floor (ticks mod 1) = 0 [
set age age + 1 ]
if age > 85 [ die ]
]
end
to go
death
tick
if ticks > 20 [ stop ]
end
I'm afraid you have to keep track of it yourself in a global variable. So, add
globals [ number-dead ]
to the top of your model. Then, change death
like so:
to death
ask humans [
if floor (ticks mod 1) = 0 [
set age age + 1 ]
if age > 85 [
set number-dead number-dead + 1
die
]
]
end
Then number-dead
will always be equal to the number of turtles that have died.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With