Java StarLogo
2.0
english
`turtle`
to check-color          ;turn and wait based on patch color and sliders
  if pc-ahead = red [rt 180  if (who = 0) [wait laziness]]
  if pc-ahead = green [lt 90 if (who = 0) [wait laziness]]
  if pc-ahead = blue [rt 90 if (who = 0) [wait laziness]]
  if pc-ahead = yellow 
      [ifelse who = 0 
        [wait 2 / hare-speed]
        [wait 2 / tortise-speed]]
end


`observer`
to setup           ;create the hare (grey) and tortoise (green)
  ask-turtles [die] 
  crt 2
  ask-turtles [
              ifelse who = 0
                 [setc grey 
                  setxy -16 18 seth 180]
                 [setc 52
                  setxy -14 18 seth 180]
              ]
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 3: Tortoise Hare  
This project is another example of turtles (in this case, one "tortoise" and one "hare") responding to their environment. Click the "setup" button and then the "go" button to watch the tortoise and the hare race around the track. The tortoise moves based on the "tortoise-speed" slider. The hare moves based on the "hare-speed" slider, but sometimes stops and waits based on the "laziness" slider.  

Can you make the hare win every time? What about the tortoise? Try changing the shape of the race course. Now who wins?


`interface`
SLCanvas
top-left 7 230

SLSlider
top-left 118 13
width-height 89 25
name "slider1"
variable "hare-speed"
min-value 0
max-value 25
current-value 20
slider-number 0
show-name? false

SLSlider
top-left 118 118
width-height 89 25
name "slider2"
variable "tortise-speed"
min-value 0
max-value 10
current-value 6
slider-number 1
show-name? false

SLSlider
top-left 161 67
width-height 89 25
name "slider3"
variable "laziness"
min-value 0
max-value 10
current-value 6
slider-number 2
show-name? false

SLButton
turtle-or-observer? turtle
top-left 26 111
width-height 104 32
name "go"
line-to-run "fd 1 check-color"
forever? true
button-number 3
show-name? true
whichip 2

SLButton
turtle-or-observer? observer
top-left 26 11
width-height 86 32
name "button1"
line-to-run "setup"
forever? false
button-number 2
show-name? false
whichip 3


`turtle shapes`
[encoded data, 5330 characters]
qqqqqqqaoR8DO5wb3dkOFQAAFQ7Z

`template`
null

`settings`
patch-size 8
num-shapes 256
screen-half-width 23
screen-half-height 22
interface-window-xcor 388
interface-window-ycor 131
interface-window-size 628 410
output-window-xcor 0
output-window-ycor 0
output-window-width 300
output-window-height 219
info-window-xcor 205
info-window-ycor 435
info-window-width 500
info-window-height 419
control-center-xcor 122
control-center-ycor 173
control-center-width 232
control-center-height 399
turtle-command-center-height 150
observer-command-center-height 150

`string table`
H4sIAAAAAAAAAGNgYGAAABzfRCEEAAAAAAAABA==

`symbol table`
H4sIAAAAAAAAAGNgYGAAABzfRCEEAAAAAAAABA==

`double table`
H4sIAAAAAAAAAGNgYGA7YMAABgd0ILSDHpT2boDQUQ4Q2g3CBwDTfhYQNAAAAAAA
ADQ=

`list table`
H4sIAAAAAAAAAGNgYGBhYGDgYmRgYAJiBiBmZYLQQkC8BYhNgHxGGB8oJQVVx8gE
0bMFymdCEmcG0lFYxFlwiLOiiYFoMBNKMwAAj6A4a6gAAAAAAACo

`bytecodes`
H4sIAAAAAAAAAIVTXU+DMBS9pYBsTECljvm0qK8me96T8ZcsItFkxhrHHvYf9T/Z
jlN6UZI1gdOe9t5zDh+Ubp4PbVPrl2a3eaRvO36IKKRo17T7TzNdUT8C3CoD0lx3
MZHAXhVi/5aEKsELEsUc/AycWagCcwk0tcr1isy86voP6mJWdwZMWN3E1+XS+8tt
Q6K0fmvq7UOt3/WXWR58KMHRGC6z3qg3zwyrBQsYsjNRH0DcWxNTmAk8uiAI4bWS
ES0b6IZpTUe00hNa7uGdM61sRCv/k6sY0bo4oXUJvGJaJevDsyjGJ+CugfOjjiik
1xqcq4CL/+fci7ee8s54+rRvW/2xXi5fdfdABs2sl9nxg/IEoUmM9AFlfRP3V0So
GQxDyl9EJcKbUgMAAAAAA1I=

`observer world`
H4sIAAAAAAAAAGMQSMhPKk4tKkstUiguSSxJTXBggAMrBq6CnPyS8syU9NQSIJ+F
gS0nNS+9JAPI5mBgB8kVpOaBlXKDNSPJQgAjCAMA+OWZc2QAAAAA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