BehaviourComposer: ignore everything before this.
CLOCK updates parameters you can use to schedule behaviours according to a real-world notion of time e.g. go to work at 6pm each weekday evening.
Begin NetLogo code:
set the-minute the-minute + 1 set the-minutes-from-start the-minutes-from-start + 1 if the-minute = 60 [ set the-hour the-hour + 1 set the-minute 0 ] if the-hour = 24 [ set the-hour 0 set the-days-from-start the-days-from-start + 1 set the-day-in-year the-day-in-year + 1 set the-weekday the-weekday + 1 ] if the-day-in-year = 366 [ set the-day-in-year 0 set the-years-from-start the-year-from-start + 1 ] if the-weekday = 7 [ set the-weekday 0 ] if the-weekday = 0 [ set the-weekday-text "monday" ] if the-weekday = 1 [ set the-weekday-text "tuesday" ] if the-weekday = 2 [ set the-weekday-text "wednesday" ] if the-weekday = 3 [ set the-weekday-text "thursday" ] if the-weekday = 4 [ set the-weekday-text "friday" ] if the-weekday = 5 [ set the-weekday-text "saturday" ] if the-weekday = 6 [ set the-weekday-text "sunday" ] ifelse the-weekday = 5 or the-weekday = 6 [ set the-weekend? true ] [ set the-weekend? false ]
End NetLogo code
The behaviour simply increments
The behaviour includes the following list of time-related parameters:
You may want to copy this behaviour and comment-out some sections to improve performance.
Don't forget to add the 'do repeatedly' enhancement to keep your clock running each tick!
You may want to copy this micro-behaviour and change the code:
You can use CREATE-MONITOR micro-behaviour to display the clock parameters e.g. the-hour.
Implemented by Howard Noble, November 2011
BehaviourComposer: ignore everything after this.