powered by NetLogo
view/download model file: Mod3turtlesREMAINDER3.nlogo
When you divide an integer by 3, there are 3 possible remainders: 0, 1 and 2 - extending the idea of EVEN and ODD turtles to create 3 groups of turtles.
We use ifelse (remainder who 3 = 0) and then inside the FALSE block [ FALSE BLOCK ] we use ifelse (remainder who 3 = 1) so that the THREE groups of turtles can be distinguished and commanded to do different things.
Play around with it. Try different numbers of turtles. Add new features to it, such as an interesting SHAPE instead of the default shape for the turtles who are divisible by 3, i.e. the turtles that have a WHO number of 3, or 6 or 9, or 12, or 15, or ... etc.
Change the ask-concurrent turtles to ask turtles. Be prepared to be very patient, and perhaps you should try this with only 3 or 6 or 9 turtles. It will be SLOW, very SLOW, like turtles like to go, so SLOW when you do ask turtles instead of ask-concurrent turtles!
Try making a slider for the timeDelay so you can decrease or increase the delays, i.e. the places where it says wait 0.2 or wait 2 or wait 4.
Could you make 4 groups of turtles? ifelse (remainder who 4 = 0)? Remainder when you divide by 4 is 0 or 1 or 2 or 3. FOUR GROUPS!
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.
;; Thursday, February 4th, 2010 hands-on class ;; Using the CS department's laptop cart computers. TO threeTypes ca cro howMany ask-concurrent turtles [ pd ifelse (remainder who 3 = 0) [ fd 4 set pen-size 3 set size 3 wait 1 fd 4 ] [ set pen-size 2 ifelse (remainder who 3 = 1) [ set shape "airplane" set size 3.5 fd 3 wait 2 repeat 4 [ pu fd 1 pd fd 1 ] ] [ set shape "fish" wait 3 set size 2 swim ] ] ] end TO swim rt 30 repeat 15 [ fd 0.6 wait 0.1 lt 60 fd 0.6 rt 60 ] lt 30 END