Java StarLogo
2.0
english
`turtle`
to go1 ;the code for the pattern-1 button
  if who < 10 
    [rt 1 
     hatch [setc who / 30 
            repeat 36 [fd 4 rt 10] 
            die]]
end

to go2 ;the code for the pattern-2 button
  if who < 20 
     [ifelse (who mod 2) = 0 
        [rt 1 
         hatch [setc who / 20 
                repeat 36 [fd 4 rt 10] 
                die]]
         [lt 1 
          hatch [setc who / 20 
                 repeat 36 [fd 4 lt 10] 
                 die]]]
end

to go3 ;the code for the pattern-3 button
  if who < 40 
    [ifelse (who mod 2) = 0 
       [rt 2 fd 1  
        hatch [setc 100 + (who / 50) 
               repeat 20 [fd 1 rt 10] 
               die]]
       [lt 2 fd 1 
        hatch [setc 100 + (who / 50) 
               repeat 20 [fd 1 lt 10] 
               die]]]
end

to go4 ;the code for the pattern-4 button
  fd 4 rt 10 
end

to go5 ;the code for the pattern-5 button
  ifelse (who mod 2) = 0
    [fd 4 rt 10] 
    [fd 4 lt 10] 
end

to turtle-setup1 ;part of the code for the create-flower button
  rt 15
  repeat petals ;repeat based on slider petals
     [repeat 36 
       [repeat 3 
          [hatch [setc who seth ycor * 3] 
           fd 1] 
        rt 10] 
      rt (360 / petals)]
end

to turtle-setup3 ;part of the code for the create-clover button
  fd 20
  repeat who [fd 1 rt 5]  
  setc who 
end

to none ;a dummy procedure to put in the buttons which act as text
end


`observer`
to setup1 ;the setup procedure for the create-flower button
  ca
  crt 1 
  ask-turtles [turtle-setup1]
end

to setup2 ;the setup procedure for the create-2-rings button
  ca 
  crt 20 ask-turtles [fd 30 rt 180]
  crt 20 ask-turtles [fd 10]
end

to setup3 ;the setup procedure for the create-clover button
  ca
  crt 360
  ask-turtles [turtle-setup3]
end


`information`
For use with the Adventures in Modeling book,  by Vanessa Colella, Eric Klopfer, and Mitchel Resnick published by Teachers College Press, 2001.  

For more information, see  
<http://education.mit.edu/starlogo/adventures>  

Challenge 2: Return of the Painted Turtles  
The buttons next to the Graphics Canvas are divided into four different categories. The first category is Basic Commands. The buttons and sliders in  this category perform simple StarLogo commands. The second category is Setup Patterns. The buttons and sliders in this category arrange the turtles in more complex configurations.  The third category is Action. 

The five buttons in this category move the turtles according to collections of simple commands called procedures. You can experiment with these buttons to learn  more about what they do. 

For example, you can try the following exploration:   
-Press the "clear all" button to begin.   
-Create 20 turtles by setting the "number" slider to 20 and then pressing the "create number" button.   
-Put the turtles' pens down using the "pen down" button.   
-Press the "pattern-1" button.  

Try combining the patterns from the Action category with some of the buttons in the Basic Commands category.  You can also create your own buttons under the Custom Buttons category.


`interface`
SLCanvas
top-left 29 242

SLTextWidget
top-left 220 60
width-height 98 25
textwidth 94
linenums 1
words "SETUP PATTERNS"
drawBorder true
textwidget-number 2

SLTextWidget
top-left 316 94
width-height 43 25
textwidth 39
linenums 1
words "ACTION"
drawBorder true
textwidget-number 3

SLTextWidget
top-left 2 60
width-height 99 25
textwidth 95
linenums 1
words "BASIC COMMANDS"
drawBorder true
textwidget-number 1

SLButton
turtle-or-observer? turtle
top-left 190 15
width-height 75 25
name "wander"
line-to-run "fd 1 rt 2"
forever? true
button-number 12
show-name? true
whichip 11

SLButton
turtle-or-observer? observer
top-left 285 125
width-height 85 25
name "create-clover"
line-to-run "setup3"
forever? false
button-number 6
show-name? true
whichip 12

SLSlider
top-left 65 120
width-height 90 25
name "slider2"
variable "steps"
min-value 0
max-value 20
current-value 1
slider-number 1
show-name? false

SLSlider
top-left 95 120
width-height 90 25
name "slider3"
variable "degrees"
min-value 1
max-value 90
current-value 45
slider-number 2
show-name? false

SLSlider
top-left 35 120
width-height 90 25
name "slider1"
variable "number"
min-value 1
max-value 50
current-value 20
slider-number 0
show-name? false

SLButton
turtle-or-observer? turtle
top-left 160 125
width-height 75 25
name "pen up"
line-to-run "pu"
forever? false
button-number 10
show-name? true
whichip 13

SLSlider
top-left 285 15
width-height 90 25
name "slider4"
variable "petals"
min-value 1
max-value 10
current-value 4
slider-number 3
show-name? false

SLButton
turtle-or-observer? turtle
top-left 190 125
width-height 75 25
name "change-color"
line-to-run "setc random 140"
forever? false
button-number 9
show-name? true
whichip 14

SLButton
turtle-or-observer? observer
top-left 130 125
width-height 77 25
name "clear graphics"
line-to-run "cg"
forever? false
button-number 11
show-name? true
whichip 15

SLButton
turtle-or-observer? turtle
top-left 160 15
width-height 75 25
name "pen down"
line-to-run "pd"
forever? false
button-number 13
show-name? true
whichip 16

SLButton
turtle-or-observer? observer
top-left 255 125
width-height 85 25
name "create-2-rings"
line-to-run "setup2"
forever? false
button-number 7
show-name? true
whichip 17

SLTextWidget
top-left 439 60
width-height 102 25
textwidth 98
linenums 1
words "CUSTOM BUTTONS"
drawBorder true
textwidget-number 4

SLButton
turtle-or-observer? turtle
top-left 95 10
width-height 92 25
name "turn right degrees"
line-to-run "rt degrees"
forever? false
button-number 15
show-name? true
whichip 18

SLButton
turtle-or-observer? turtle
top-left 65 10
width-height 90 25
name "forward steps"
line-to-run "fd steps"
forever? false
button-number 16
show-name? true
whichip 19

SLButton
turtle-or-observer? turtle
top-left 381 126
width-height 85 25
name "pattern-4"
line-to-run "go4"
forever? true
button-number 2
show-name? true
whichip 20

SLButton
turtle-or-observer? turtle
top-left 410 70
width-height 85 25
name "pattern-5"
line-to-run "go5"
forever? true
button-number 1
show-name? true
whichip 21

SLButton
turtle-or-observer? observer
top-left 255 16
width-height 85 25
name "create-flower"
line-to-run "setup1"
forever? false
button-number 8
show-name? true
whichip 22

SLButton
turtle-or-observer? turtle
top-left 351 16
width-height 85 25
name "pattern-1"
line-to-run "go1"
forever? true
button-number 5
show-name? true
whichip 23

SLButton
turtle-or-observer? observer
top-left 130 15
width-height 75 25
name "clear all"
line-to-run "ca"
forever? false
button-number 14
show-name? true
whichip 24

SLButton
turtle-or-observer? observer
top-left 34 10
width-height 90 25
name "create number"
line-to-run "crt number"
forever? false
button-number 17
show-name? true
whichip 25

SLButton
turtle-or-observer? turtle
top-left 350 127
width-height 85 25
name "pattern-3"
line-to-run "go3"
forever? true
button-number 4
show-name? true
whichip 26

SLButton
turtle-or-observer? turtle
top-left 381 16
width-height 85 25
name "pattern-2"
line-to-run "go2"
forever? true
button-number 3
show-name? true
whichip 27


`turtle shapes`
[encoded data, 5200 characters]
DhUAABUO2Q==

`template`
null

`settings`
patch-size 4
num-shapes 256
screen-half-width 50
screen-half-height 50
interface-window-xcor 318
interface-window-ycor 63
interface-window-size 716 530
output-window-xcor 0
output-window-ycor 0
output-window-width 300
output-window-height 219
info-window-xcor 194
info-window-ycor 257
info-window-width 500
info-window-height 419
control-center-xcor 11
control-center-ycor 123
control-center-width 285
control-center-height 415
turtle-command-center-height 150
observer-command-center-height 150

`string table`
H4sIAAAAAAAAAGNgYGAAABzfRCEEAAAAAAAABA==

`symbol table`
H4sIAAAAAAAAAGNgYGAAABzfRCEEAAAAAAAABA==

`double table`
H4sIAAAAAAAAAGNgYGAAABzfRCEEAAAAAAAABA==

`list table`
H4sIAAAAAAAAAHWQOw6DMBBEZ01AChKKLFFTpaDOmSh8GI7DARmzs8IFKcb7e/uR
AWQAZhRtz2emFuqQP3rdCu1QY3O+Ml/qJWYSn+ogMXPLPOWIZtq16UviNuon3tT/
twavxcyhmRe7o/am/VCd7ugk7bBSY3gu5vf6I+C+IXl4+TvuXPzlxZ+LXegbYAEA
AAAAAWA=

`bytecodes`
H4sIAAAAAAAAAJVWy3LaMBSVn0AwMW1qXmlnPAlZsoA0m67abjtddxsHFMOMKzO2
KdN/TP+pkiz0ihzAM4C41j33nHOvDKD7+PS3gst8BcvHr+CFXP8AAB+BX8Jqt53j
dQj4dYNfFluPXABssvAAaJHPttjn4NetT1I98rXGWuDV9RGsFovhtyhga3wjGgtM
ixXgOS6LuXWOUttite/P0NFp0GEDJ82JIVN+34o+cCCrP2BAE0nEmMWupL023ouR
o74Qo4h3JfGeEB9iYiNGamSzmM3IOYQccfjHEXLfpLiF455EaqgJcBoEuJoATxPg
SwJabwtQ6uEJiiaGeh2t3oVWryvVC2qMRsMczTiXGEfG49cR436eYFysGid3k94f
cMMElk/FWVibENjSBLYlgZ0TDI2FUdFENUnhEUg8egYelxqPUOLRP9Nojxj9GSjn
63AGOSg7MjTBJwkPOPipoTOe1I2hxtSWQB3h2JvnbCKYh/XToFftiiqDM/4snBu4
jwWN6aHEnaBBv4+0ox6yz3YtCRtuRbZ0ugj9kTCUUwyE4fykjbWYGBrCpz450h4q
ra1KI/N/ZWwLpXfKoxlDH6TUJTrARTmCNUkdOfTYrgsQft9VVY6+xPE+QStYADqq
SknDhNCSPrOlCwYcZFnApIKzZZb/oViHp7oNpMsjoy8KbyGKd1umZ8A3RAJ0naAU
g+ZZzjD5EPq1ZBrsgaFIyWBSxGmRbNebZVlj31gc+51SfJXvESsf8S1DXdNiVmxQ
WkqirFeirnkS7i+Ki026ruIVTAsIS5X5lM0uDV5KDj7nxT4pVnFZwa0pJ2A5IXgv
RCRVBQs0Y+db+T2V2q90LTDkPxjyW435r7r+nOV7pevK1VBzbqjpnMC57nCSZay5
oobOK0a7309QmxziJfnvQYN9A697Ay/vDC8Xhny3Kf8/dUcl7QkKAAAAAAoJ

`observer world`
H4sIAAAAAAAAAGMQSMhPKk4tKkstUiguSSxJTXBggAMrBq6CnPyS8syU9NQSIJ+F
gS0nNS+9JAPI5mBgB8kVpOaBlXKDNSPJQgAjCAMA+OWZc2QAAAAAAABk

`patch world`
[encoded data, 30095 characters]
sp8+IZf99Am57KdPyGU/fUIu++kT8vb+f5Cftl+d+wQAAAT7nQ==

`turtle world`
[encoded data, 29575 characters]
pEnqxSqBfXax39PsraZqTS6/8RNiGeslAQAAASXr

