Java StarLogo
2.0
english
`turtle`
breeds [ball ball-creator]
turtles-own [currentdepth hatchtwo]

to ball-setup ;place the ball-creator
  setxy 0 screen-half-height
  seth 180 
  setc black
end

to drop-ball
  if breed = ball-creator
    [hatch [sety screen-half-height
            setbreed ball
            setc yellow
            seth 180 
            fd 1]]
end

to fall
  if breed = ball
    [if ((color-at 0 -1) = yellow) or 
        ((pc-at 0 -1) = green) ;stop balls at the bar
            [stop] 
     if (pc-at 0 -1) = red ;turn at red squares
       [ifelse left-right > random 100 
         [setx xcor + 1]
         [setx xcor - 1]] 
     wait (10 - speed) / 500 
     fd 1]
end


`observer`
to setup 
  ask-turtles [die]
  ask-patches [if pc = yellow [setpc black]]
  create-ball-creator 1
  ask-ball-creator [ball-setup]
  add-bar
end

to add-bar
  ask-patches [if ycor = (0 - screen-half-height) 
    [setpc green]]
end

to remove-bar
  ask-patches [if ycor = (0 - screen-half-height) 
    [setpc black]]
end

to start
  startfallbutton
  startdrop-ballbutton
end

to stopit
  stopfallbutton
  stopdrop-ballbutton
end


`information`
For use with the "Adventures in Modeling" workbook. For more information on this project, see: 
http://education.mit.edu/starlogo/projects/gaussian.html


`interface`
SLCanvas
top-left 15 278

SLButton
turtle-or-observer? observer
top-left 19 35
width-height 71 30
name "button1"
line-to-run "setup"
forever? false
button-number 2
show-name? false
whichip 8

SLButton
turtle-or-observer? observer
top-left 101 36
width-height 71 30
name "stopbutton"
line-to-run "stopit"
forever? false
button-number 7
show-name? false
whichip 9

SLButton
turtle-or-observer? observer
top-left 193 136
width-height 71 30
name "button8"
line-to-run "add-bar"
forever? false
button-number 9
show-name? false
whichip 10

SLButton
turtle-or-observer? observer
top-left 193 36
width-height 71 30
name "button7"
line-to-run "remove-bar"
forever? false
button-number 8
show-name? false
whichip 11

SLButton
turtle-or-observer? observer
top-left 59 36
width-height 71 30
name "startbutton"
line-to-run "start"
forever? false
button-number 6
show-name? false
whichip 12

SLSlider
top-left 59 136
width-height 90 25
name "slider0"
variable "left-right"
min-value 0
max-value 100
current-value 50
slider-number 0
show-name? false

SLSlider
top-left 101 136
width-height 90 25
name "slider1"
variable "speed"
min-value 0
max-value 10
current-value 10
slider-number 1
show-name? false

SLButton
turtle-or-observer? turtle
top-left 151 36
width-height 71 30
name "fallbutton"
line-to-run "fall"
forever? true
button-number 10
show-name? false
whichip 13

SLButton
turtle-or-observer? turtle
top-left 151 136
width-height 71 30
name "drop-ballbutton"
line-to-run "drop-ball"
forever? true
button-number 11
show-name? false
whichip 14


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

`template`
null

`settings`
patch-size 4
num-shapes 256
screen-half-width 37
screen-half-height 52
interface-window-xcor 298
interface-window-ycor 86
interface-window-size 611 440
output-window-xcor 0
output-window-ycor 0
output-window-width 300
output-window-height 219
info-window-xcor 0
info-window-ycor 0
info-window-width 500
info-window-height 419
control-center-xcor 16
control-center-ycor 67
control-center-width 390
control-center-height 514
turtle-command-center-height 160
observer-command-center-height 164

`string table`
H4sIAAAAAAAAAGNgYGAAABzfRCEEAAAAAAAABA==

`symbol table`
H4sIAAAAAAAAAGNgYGAAABzfRCEEAAAAAAAABA==

`double table`
H4sIAAAAAAAAAGNgYGB1cGtgAAEHbyjNAAH7P0BoBz0IDQAtP1LTLAAAAAAAACw=

`list table`
H4sIAAAAAAAAAF2OQQ6AIBAD20UPauLF+EOf6NN8AFso0XgoO4HNFAALgDnyYE9k
qInOAg5WzGtm+3Hxzu09eZsv3ns9Ha2D525/Gf1mfniy8/K/6L6cfOxDBVlieZbI
AAAAAAAAyA==

`bytecodes`
H4sIAAAAAAAAALVUS07DQAz15EvSz4S2A0ECUUFXSL0AK8SSNQdoSoKEVEjVpkjc
Ee6EM/F8mlDBhpEaO5737DcTu9BbLD+q4qnMi+3iDj7r9QUAHPxtUe3W6N6AXg49
UjQu/q4DivWBTRgAa2AsOaW4RzF8TLyGwx3iqj2HLAZTn3yP+PgeklVLckOKMxPn
DSjM8ny+zDboTlrCh8CEa0SeMxTK/i5WFmA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