Reputation: 21
I need to count ticks each car takes from start of trip till end of trip. I am working on showing road bloackade simulation in netlogo. For this trip time of cars is needed to be calculated.
For this I have made following code:
to-report start-journey-time
report min-pxcor
end
to-report end-journey-time
report max-pxcor
end
Upvotes: 0
Views: 36
Reputation: 17678
The current value of the tick counter is access with the reporter ticks
. Note that this is different from tick
, which is used to increment the counter.
So, assuming each car has a variable called journey-time, you can do something like this. When the journey starts: set journey-time ticks
, and when the journey finishes set journey-time ticks - journey-time
. This is not great code since you are using the same variable for both the start time and the duration, but it saves a variable. If you want more readable code, use separate variables.
Upvotes: 1