# Blinky Clock

Model was written in NetLogo 5.3.1
•
Viewed 134 times
•
Downloaded 14 times
•
Run 0 times

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)

## Comments and Questions

Please start the discussion about this model!
(You'll first need to log in.)

Click to Run Model

breed [cubes cube] globals[ realtime time h1 h2 m1 m2 s1 s2 time0 group0 group1 group2 group3 wigcount wigcheck wigtrip hc1 hc2 mc1 mc2 ] to setup ca set-default-shape cubes "cylinder" set group0 patches with [pxcor = 0] set group1 patches with [pxcor >= 2 and pxcor <= 4] set group2 patches with [pxcor >= 6 and pxcor <= 8] set group3 patches with [pxcor >= 10 and pxcor <= 12] set time0 [0 0 0 0] clock keeptime end to clock set realtime date-and-time set h1 read-from-string item 0 realtime set h2 read-from-string item 1 realtime set m1 read-from-string item 3 realtime set m2 read-from-string item 4 realtime set s1 read-from-string item 6 realtime set s2 read-from-string item 7 realtime set time (list h1 h2 m1 m2 s1 s2) end to go set time0 time clock if time0 != time[keeptime] end to keeptime wiggle hour1 hour2 min1 min2 show time end to wiggle set wigtrip 0 if wigcount >= wigcheck[ set hc1 0 set hc2 0 set mc1 0 set mc2 0 set wigcount 0 ] end to hour1 let subgroup group0 with [count cubes-here > 0] let subcount count subgroup ifelse subcount != item 0 time[ if subcount < item 0 time[ask n-of (item 0 time - count subgroup) group0 with [count cubes-here = 0] [sprout-cubes 1 [set color 105]]] if subcount > item 0 time[ask group0 with [count cubes-here > 0] [ask cubes-here [die]]] ] [if subcount > 0 and hc1 = 0 and wigtrip = 0 [ ask one-of group0 with [count cubes-here > 0] [ask cubes-here [move-to one-of group0 with [count cubes-here = 0]]] set hc1 1 set wigcount wigcount + 1 set wigtrip 1 ] ] end to hour2 let subgroup group1 with [count cubes-here > 0] let subcount count subgroup ifelse subcount != item 1 time[ if subcount < item 1 time[ask n-of (item 1 time - count subgroup) group1 with [count cubes-here = 0] [sprout-cubes 1 [set color 65]]] if subcount > item 1 time[ask group1 with [count cubes-here > 0] [ask cubes-here [die]]] ] [if subcount > 0 and subcount < 9 and hc2 = 0 and wigtrip = 0 [ ask one-of group1 with [count cubes-here > 0] [ask cubes-here [move-to one-of group1 with [count cubes-here = 0]]] set hc2 1 set wigcount wigcount + 1 set wigtrip 1 ] ] end to min1 let subgroup group2 with [count cubes-here > 0] let subcount count subgroup ifelse subcount != item 2 time[ if subcount < item 2 time[ask n-of (item 2 time - count subgroup) group2 with [count cubes-here = 0] [sprout-cubes 1 [set color 45]]] if subcount > item 2 time[ask group2 with [count cubes-here > 0] [ask cubes-here [die]]] ] [if subcount > 0 and mc1 = 0 and wigtrip = 0 [ ask one-of group2 with [count cubes-here > 0] [ask cubes-here [move-to one-of group2 with [count cubes-here = 0]]] set mc1 1 set wigcount wigcount + 1 set wigtrip 1 ] ] end to min2 let subgroup group3 with [count cubes-here > 0] let subcount count subgroup ifelse subcount != item 3 time[ if subcount < item 3 time[ask n-of (item 3 time - count subgroup) group3 with [count cubes-here = 0] [sprout-cubes 1 [set color 15]]] if subcount > item 3 time[ask group3 with [count cubes-here > 0] [ask cubes-here [die]]] recount ] [if subcount > 0 and subcount < 9 and mc2 = 0 and wigtrip = 0 [ ask one-of group3 with [count cubes-here > 0] [ask cubes-here [move-to one-of group3 with [count cubes-here = 0]]] set mc2 1 set wigcount wigcount + 1 set wigtrip 1 ] ] end to recount set wigcheck 0 if (count group0 with [count cubes-here > 0]) > 0 [set wigcheck wigcheck + 1] if (count group1 with [count cubes-here > 0]) > 0 and (count group1 with [count cubes-here > 0]) < 9 [set wigcheck wigcheck + 1] if (count group2 with [count cubes-here > 0]) > 0 [set wigcheck wigcheck + 1] if (count group3 with [count cubes-here > 0]) > 0 and (count group3 with [count cubes-here > 0]) < 9 [set wigcheck wigcheck + 1] end

There are 2 versions of this model.

## Attached files

File | Type | Description | Last updated | |
---|---|---|---|---|

Blinky Clock.png | preview | Preview for 'Blinky Clock' | over 3 years ago, by Marcus Snell | Download |

This model does not have any ancestors.

This model does not have any descendants.