amalmodel 10

No preview image

1 collaborator

Default-person amal zaher (Author)

Tags

(This model has yet to be categorized with any tags)
Model group uhaifa-modeling-11 | Visible to everyone | Changeable by everyone
Model was written in NetLogo 4.1.2 • Viewed 254 times • Downloaded 21 times • Run 0 times
Download the 'amalmodel 10' modelDownload this modelEmbed this model

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


WHAT IS IT?

This section could give a general understanding of what the model is trying to show or explain.

HOW IT WORKS

This section could explain what rules the agents use to create the overall behavior of the model.

HOW TO USE IT

This section could explain how to use the model, including a description of each of the items in the interface tab.

THINGS TO NOTICE

This section could give some ideas of things for the user to notice while running the model.

THINGS TO TRY

This section could give some ideas of things for the user to try to do (move sliders, switches, etc.) with the model.

EXTENDING THE MODEL

This section could give some ideas of things to add or change in the procedures tab to make the model more complicated, detailed, accurate, etc.

NETLOGO FEATURES

This section could point out any especially interesting or unusual features of NetLogo that the model makes use of, particularly in the Procedures tab. It might also point out places where workarounds were needed because of missing features.

RELATED MODELS

This section could give the names of models in the NetLogo Models Library or elsewhere which are of related interest.

CREDITS AND REFERENCES

This section could contain a reference to the model's URL on the web if it has one, as well as any other necessary credits or references.

Comments and Questions

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

Click to Run Model

globals [hours minutes seconds]  ; used to keep track of the time

to setup

   ca
   clear-output

   set hours 0
   set minutes 0
   set seconds 0
   
   crt 60
      ask turtles [
   
      ;; creates the 60 tick marks highlighting the hours with different shapes 
   
      set heading 6 * who
      set color blue
      if (who mod 5 = 0)       
         [
          set color red 
          set size 2 
          set shape "circle"
         ]
      fd 15
   ]
   
   
   ;; Set the second hand - will be referred to later as turtle 60
   crt 1 [
      set heading 0
      set color blue
      set size 16
      set shape "arrow"
      ]
   
   ;; Set the minute hand - will be referred to later as turtle 61
   crt 1 [
      set heading 0
      set color red
      set size 12
      set shape "arrow"
      ]
   
   ;; Set the hour hand - will be referred to later as turtle 62   
   crt 1 [
      set heading 0
      set color yellow
      set size 8
      set shape "arrow"
      ]
      
      reset-timer  ; this command is needed to use the timer command later
end 

to set_clock
 
 ;; This function simply positions the hands according to sliders on the interface screen
 
   ask turtle 60 [ 
       set heading second * 6
       set seconds second
       ]
       
   ask turtle 61 [
       set heading (minute * 6 + second / 10)
       set minutes minute
       ]
       
   ask turtle 62 [
       set heading (hour * 30 + minute / 2 + second / 120)
       set hours hour
       ]
end 

to go 

let val 0
  

set val round timer     ; at the beginning of each second will set the variable val
                        ; to be equal to the time value. Then it will enter the while loop
                        ; and highlight the turtle the second hand is pointing toward.
                        ; after a second has passed the value of timer is different than
                        ; the value of 'val' and will exit the while loop, reset the display
                        ; and update the position of the hands, the monitors, and then repeat

while [ val = round timer ] [  

       ask turtle (seconds mod 60) [ 
        
       ifelse (who mod 5 = 0)    ; a simple block of code to highlight the turtle
          [                      ; the second hand is pointing toward
           set size 3
           set color yellow
          ]  [
           set size 2
           set color yellow
           ]
           
        ]
        ]

    ask turtle (seconds mod 60) [ 
        
       ifelse (who mod 5 = 0)
          [
           set color red
           set size 2
          ]
          
          [
           set color blue
           set size 1
           ]
     ]
     
;; Updates the hands and the monitors each second

   ask turtle 60 [ 
       set heading heading + 6   ;; each tick moves the seconds hand 6 degrees
       set seconds (seconds + 1) mod 60  ;; and one second and reset after 60
       if (seconds mod 60 = 0) [set minutes (minutes + 1) mod 60]  ;; at 60 seconds, incriment the minutes
       if (seconds mod 60 = 0 and minutes mod 60 = 0) [set hours (hours + 1) mod 24] ;; at 60 minutes, incriment the hours
       ]
       
   ask turtle 61 [
       set heading heading + .1  ;; update the heading of the minute hand each second
       ]
       
   ask turtle 62 [
       set heading heading + (.1 / 12)  ;; update the heading of the hours hand each second
       ]
end 

There is only one version of this model, created almost 13 years ago by amal zaher.

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.