Java StarLogo
2.0
english
`turtle`
to go 
  fd 1
  check-color
end

to check-color             ;move based patch color
   if pc-ahead = red [
    ifelse not who = 0     ;only turtle 0 responds to red zones
       [wait Red_Zone / 1000]
       [wait car2_Speed / 1000]
    ]
  if pc-ahead = green [lt 90]       ;turn at corners
  if pc-ahead = blue [rt 90]
  
  if pc-ahead = yellow 
    [ifelse who = 0          ;speed based on slider
       [wait car2_Speed / 1000]
       [wait car1_Speed / 1000]] 
   if pc-ahead = orange 
    [ifelse who = 0          ;turtle 0 uses second lane, when there is one
       [rt 90]
       [fd 1]] 
end


`observer`
to setup          ;create and place the two "car" turtles
  ct
  crt 2 
  ask-turtles
   [if who = 0 [setc 5]
    if who = 1 [setc 40]
    setxy -14 -1 
    seth 0]
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: Yellow Brick Road  
This project introduces a real-world metaphor for the check-patches procedure. The creators of this project changed check-patches to check-color. As the turtles (or "cars" in this  model) check-color, they adjust their speeds according to the color of the patch ahead of them. The car speeds are controlled using the sliders "car1_Speed" and "car2_Speed". Notice that only one car pays attention to the Red_Zone.   

By adjusting the sliders you can manipulate the speed of the cars on the track. What would this project look like if there were many more cars? How could you change the project to include intersections? Can you think of a way to let the cars choose whether to turn right or left?


`interface`
SLCanvas
top-left 23 223

SLSlider
top-left 105 9
width-height 90 25
name "slider1"
variable "car1_Speed"
min-value 10
max-value 500
current-value 95
slider-number 0
show-name? false

SLButton
turtle-or-observer? observer
top-left 22 39
width-height 60 30
name "somebutton"
line-to-run "setup"
forever? false
button-number 2
show-name? false
whichip 3

SLButton
turtle-or-observer? turtle
top-left 22 101
width-height 60 30
name "go button"
line-to-run "go"
forever? true
button-number 1
show-name? false
whichip 4

SLSlider
top-left 69 54
width-height 90 25
name "slider3"
variable "Red_Zone"
min-value 9
max-value 600
current-value 9
slider-number 2
show-name? false

SLSlider
top-left 105 101
width-height 90 25
name "slider2"
variable "car2_Speed"
min-value 10
max-value 500
current-value 62
slider-number 1
show-name? false


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

`template`
null

`settings`
patch-size 8
num-shapes 256
screen-half-width 24
screen-half-height 23
interface-window-xcor 329
interface-window-ycor 70
interface-window-size 635 425
output-window-xcor 0
output-window-ycor 0
output-window-width 300
output-window-height 219
info-window-xcor 170
info-window-ycor 253
info-window-width 500
info-window-height 419
control-center-xcor 0
control-center-ycor 85
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`
H4sIAAAAAAAAAGNgYGA/oMMABvs/QGgHPSjt3QChoxwgtBuUbwmRBwBDc7JOPAAA
AAAAADw=

`list table`
H4sIAAAAAAAAAGNgYGBhYGDgYGRgYAJiBiBmBWJGINZgAvKZIGwQANEgphxUHSMT
Qg+QZn4B0QemYfLMQDoKic+CxmeFsRH6UPSzQdlRULsZAPns+mewAAAAAAAAsA==

`bytecodes`
H4sIAAAAAAAAAIVT206DQBCd5VYLlaUVLKU2NtUXH/wBn4xf0ohEE40YSx/8BP9N
/8mBnYVZSuw8MMNwzs45kwWC7eNXVeTlU7Hb3sNPHb8A4IK7K6r9B5Y30MbGBhBU
pw6AVReXIJKY+gJENKe+Qz18SSIApIK0GNYewDoGVvVcyh5+86geYZ0q3BX2ZA3C
o55LfPqdXq01mTQUGqZCqoOD/KXIX2/z8q38xO73IVkbi8PWUCd8eWBIRCv6dtKa
EtfQmhERqpa+Em/gPIYbmThp95aiOWOmyx9YaIDmsx53QvmUccMBrkTuoseNKE8Z
d8a4GdvHGetrvTHzmPyzi3OGmx/ZRUp5wTRlbPaMaVoO+LzofBr9lbo4/ZnNxbEg
fNhXVfl+t17rH8WlS2aEWxODFtvc0DEN0gTRwZshnib+AYrYsneeAwAAAAADng==

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

`patch world`
[encoded data, 7475 characters]
DvuxD8phP/ZBOezHPiiH/dgH5cv7/weoB0YyXSABAAABIF0=

`turtle world`
H4sIAAAAAAAAAGPgSygpLSrJSVUoLkksSU1wYICD+QxsOal56SUZQLYFA2tSUWpq
CpCpwsBVkJNfUp6Zkp5aAuSbMLCD+AWpeUCOHgNrcn5OfhGQKcPAUpkMZvEwcIMN
RzKNA6g8Jb88rwDIM2JgLc5ILEgFMrUYWCogelgYmMsz8sHuYCvOgKo0ZmDPSE1M
ycxLB3JEYO78DwRAignEPqADEdv/gQEFOIgwYAJGIGSAYJz6XHDrAwBZw+/pOwEA
AAAAATs=

