Make Way for Kate's Ducklings

 

Baby Duck Code

 

Cricket Code

;; a, left
;; b, right

to baby-duck
when [newir? ] [find]
loop [walk]
end

to walk
loop [
forward
if switcha [hit]
turn
if switcha [hit]
]
end

to find
sing1
a, thisway on
b, thatway on
wait 10
ab, thisway on
wait 20
ab, off
end


to hit
sing2
ab, thatway
onfor 10
b, thisway
ab, onfor 7
ab, thisway
end

to sing1
beep
end

to sing2
beep
end

to forward
number
a, thisway on
b, thisway on
wait num
ab, off
end

to turn
choose
number
ifelse (dir)
[ a, thisway on b, thatway on]
[ a, thatway on b, thisway on]
wait (num)
ab, off
end

global [num chose dir]

to number
setnum (random)
ifelse ( num < 1000)
[setnum (num / 100)]
[setnum (num / 1000)]
end

to choose
setchose (random)
ifelse (chose < 16384)
[setdir 0]
[setdir 1]
end

to hit?
loop [when [switcha] [beep] ]
end

 

 

Back