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`
Gaussian  

This project simulates a classic science-museum exhibit in which balls are dropped through a triangular bed of nails. When a ball hits a nail, it moves either to the left or to the right, based on the "left-right" slider. At the bottom of the nails, the balls form a Gaussian distribution.  

Click the "setup" button to setup the triangular array of nails. Click the "go" button to start the balls dropping through the nails. There is a "bar" at the bottom of the screen to stop the balls from falling. Click the "remove-bar" button to remove the  bar. The balls will continue to fall, "wrapping" back to the top  of the screen and falling through the array of nails again. Click "add-bar" to re-insert the bar at the bottom of the screen.  

When a ball hits a nail, it moves left or right based on the "left-right" slider. The higher the value of the "left-right" slider, the greater chance the ball has of shifting right when it hits a nail. When "left-right" is set at 50, the ball has an equal chance of shifting to the left or to the right, and the resulting Gaussian distribution is typical of a random walk.


`interface`
SLCanvas
top-left 4 282

SLSlider
top-left 37 135
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 90 135
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? observer
top-left 59 36
width-height 71 30
name "startbutton"
line-to-run "start"
forever? false
button-number 6
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? turtle
top-left 151 36
width-height 71 30
name "fallbutton"
line-to-run "fall"
forever? true
button-number 10
show-name? false
whichip 10

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 11

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 12

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 13

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 14


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

`template`
null

`settings`
patch-size 4
num-shapes 256
screen-half-width 37
screen-half-height 52
interface-window-xcor 218
interface-window-ycor 91
interface-window-size 618 430
output-window-xcor 0
output-window-ycor 0
output-window-width 300
output-window-height 219
info-window-xcor 117
info-window-ycor 71
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`
H4sIAAAAAAAAAGNgYGB1cGtgAAEHbyjNAAH7P0BoBz0IDQAtP1LTLAAAAAAAACw=

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

`bytecodes`
H4sIAAAAAAAAALVUS07DQAz15EvSz4S2A0ECUUFXSL0AK8SSNQdoSoKEVEjVpkjc
Ee6EM/F8mlDBhpFaO5737DeOJ9BbLD+q4qnMi+3iDj7r9QUAHPxtUe3W6N6AXg79
pWhc/F0HFOsDmzAA1sBYckpxj2L4N/EaDneIq/YcshhMffI94uNzSFYtyQ0pzkyc
N6Awy/P5MtugO2kJHwITrhF5zlAo+7tYWYBBvCley/fiH2s42Psq21QYi0x6ddSZ
lWKmKC4E26pcvxzi+BbHJ44H8TJbrebqPQ86vFo+iMBwRWremUgojw9RvinX8zoZ
bl2YLGL6w0iMyXJKb0kTV/vp1Vjosnhc0W+6lTqme1JGAN5zo+DxFwUPpmJrANmJ
qytJvPSVwgCHPCI/lPssuTSXgoNRJDFHZCOLF1s6zijWAzZTTceLlGCdRBAGfaH2
BhhHI2huOvtDOWt6n7stPZxsIutJrHw+Rh+BPKbnkemy7m4Iw/tdVZVvt9OpGk51
OV2wll+fm1tYmkoF9jrggQbT+4talz80BKkp0NSRptoT2OYHB/ljzd+71IrodLQm
mmA+M373W0Roq2V0x/y901jYb38BTImIBQAAAAAFiA==

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

`patch world`
[encoded data, 27040 characters]
BwFT6B3d2AMAAAPY3Q==

`turtle world`
H4sIAAAAAAAAAE3VBZScZwGF4Xunu0mahlKstFAg0CItpFCBFm1wKO4O2exOs4El
CZsJ26LB3V1b3N3d3d2huLtref7Jnpzu6ZPMnLPZJt987/1z8JbJnuXJ0njj7snc
ZLxlc/Z/nZk1S+Md2yaLXm/O7Nb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