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 1: Painted Turtles

The buttons next to the Graphics Canvas are divided into three 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.


`interface`
SLCanvas
top-left 18 268

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

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

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

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

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

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

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

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 12

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

SLButton
turtle-or-observer? turtle
top-left 190 126
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 255 15
width-height 85 25
name "create-flower"
line-to-run "setup1"
forever? false
button-number 8
show-name? true
whichip 15

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

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 16

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

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

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 19

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

SLButton
turtle-or-observer? turtle
top-left 410 69
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 130 125
width-height 77 25
name "clear graphics"
line-to-run "cg"
forever? false
button-number 11
show-name? true
whichip 22

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

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

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

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 26

SLButton
turtle-or-observer? turtle
top-left 380 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 398
interface-window-ycor 326
interface-window-size 693 451
output-window-xcor 0
output-window-ycor 0
output-window-width 300
output-window-height 219
info-window-xcor 333
info-window-ycor 93
info-window-width 554
info-window-height 494
control-center-xcor 100
control-center-ycor 448
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`
H4sIAAAAAAAAAHWQOw6AMAxDnfKRQEKoUmcmBmbOxMBhOA4HxFUd0QEG123ykkYB
EAGYUfSOR6IW6tZ9LHk76X1+W+Ezs1KtmEl8yI3EpJr5ihGN9K2qC+IOahdvqv/N
oeS8Z1/18789N9BnqtEcjaQ/7MxvlJj377QjyEO1M5/JYxdeDg+yZeTiYAEAAAAA
AWA=

`bytecodes`
H4sIAAAAAAAAAJVWy27aQBQdP4HgxLSpeaWVrJQuWYQkm67abquuu41jJgbJtZFt
ivqP7T91XsyLcQBLwHB9z73nnJlrAP2n5z8NTMslrJ++gL/4+gcAeA/8GjbbzR1a
h4Bft+hlsfXYBcDGCw+ADv7sijwHvT76GOrhr7TWAq1ujtTqsBh6iwK2Rjeiiahp
sQYc47KYSzFKb4v1vj9DR69Fhw2crMSGzPh9K3rHC1mDISs0lURMWOxayrVRLqoc
DYQYRbwrifeE+BARGzNSY5vFbEbOweSww9+PkPsqxS0U9yRSI02A0yLA1QR4mgBf
EtB5XYDSD52gaGro19P6XWj9+lK/gNZoNczRjHOxcfh4/Dxi3I8TjItV4+TdJPeH
3DBRyyfiLKRNCOxoAruSwN4JhsbCqGiqmqTwCCQelwYeVxqPUOIxONNoDxv9AJT5
2s8gL8pGhgB8DHhEwQ8tO+NJuzHSmNpSUUc49uqcTQXzkD4NLptt1eRwzp+Fdwbu
E0Fjtm/xSdAg38faqIfss0slIcOtyJamC9MfC0M5xUAYzidtosXEocF86ORIOURa
V5WGz/+1cVsIvVMezaj0Xgpt0QNuURaQktQrhx7LugA337ZNUxaf4xgxKuJqna2a
eAmzCsKaqt5v+Iy5TYJ9MOTAl7LaJdUyrhu4MWEChglAyDG7pFjCCpC5UPSBw+NI
9PmsyCWIeJF0lRQZnKdlXlZq34FPrSDBK4lrWsGkgfOXvNxBhukA/SLujHTMYl6t
i6yWQNYB6KBRmpe/lUb2AeYNx2xgES/LXcG2NuIpoZKy3bCEIU94KxKSpoFVMcej
0tN+Wh3RWfHUhH804DuteMmsHCZVnFXJZrVOa0r01jI0oolJnrOcdhPjYvvrGWo7
jE8W/u9AggODgHuDAO8MAx4MeP8M/MKAd9vw/wGwu3nNCQoAAAAACgk=

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

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

`turtle world`
[encoded data, 23660 characters]
xQAAAADFqw==

