Reputation: 73
I´m trying to see how many turtles are added and eliminated from the simulation each tick. I want to do something like this:
If (count turtles - count turtles in t-1) > 0
Then
[]
End
The model I´m trying to do that for is the team assembly model from the netlogo´s library.
Upvotes: 0
Views: 70
Reputation: 9620
If you want to keep records, you have to do it explicitly. Often global variables are used for this. E.g.,
globals [laggedCount]
to setup
ca
crt 25
end
to provideExample
set laggedCount count turtles
ask turtles [
if random-float 1 < 0.1 [die]
]
print laggedCount - count turtles
end
In this case, since the relevant code is in a single procedure, you could use a local variable (which is preferable). But to share such information across procedures you will either need to pass it explicitly or use a global variable. Finally, note that you could assign to this global a list to which you repeatedly append, so that you could store the entire history of values during your simulation. (Finally finally, if that's what you want, you could alternatively plot those values during the simulation and export the plot afterwards.)
Upvotes: 1