GAUSSIAN SOURCE CODE

Back to Gaussian

Turtle Procedures Observer Procedures
turtles-own 
[currentdepth hatchtwo] 
breeds 
[ball ball-creator] 

to ball-setup
setxy 0 screen-half-height
seth 180
setc black
end
to drop-ball 

if breed = ball-creator 
     [hatch 
[sety screen-half-height 
        set breed 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]
if (pc-at 0 -1) = red
[ifelse left-right > random 100
[setx xcor + 1]
[setx xcor - 1]]
wait (10-speed) / 500
fd 1]
end

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]]
to start
fallbutton
drop-ballbutton
end