Make Way for Kate's Ducklings

 

Mama Duck Code

 

Handy Board Code

global [NOSE]
; "thisway" = forward, "thatway" = backward

; "MommaWalk" is the final code

to MommaWalk
loop [
setNOSE 255
Wings on
print "Serpentine
Serpentine
setNOSE 0
Squawk
print "Squawk wait 20
]
end


;"Serpentine" is the basic walk.

to Serpentine
forever[
repeat 2 [ SemicircleLeft SemicircleRight ]
print "next wait 10
repeat 2 [ SemicircleRight SemicircleLeft ]
print "last wait 10
]
every ((random 11) + 10) [ Nod ((random 10) + 5)]
waituntil [ not NOSE ] stoprules LeftRight off
end


;"Squawk" is response to running head-on into something

to Squawk
launch [ ; stop, back up, turn left
LeftRight off
LeftRight thatway onfor 15
Right thisway on
Left thatway on
wait 10
LeftRight off
]
launch [ ; head nods back and forth 3x for 0.5s.
repeat 3 [ Nod (5) ]
]
end


;"Nod :num" takes an integer input and moves the head either left or right (also randomly determined) for time "num"

to Nod :num
;if (:num > 8)
; [Neck rd] ;will switch direction head nods half the time.
Neck thisway onfor :num
Neck thatway onfor :num
end


to SemicircleLeft
repeat 5 [ fwd 5 turnLeft 7 ]
end

to SemicircleRight
repeat 5 [ fwd 5 turnRight 7 ]
end

to turnRight :t
Left thisway onfor :t
end

to turnLeft :t
Right thisway onfor :t
end

to fwd :t
LeftRight thisway onfor :t
end

to Nose
output sensor 0
end

to LeftRight
ab,
end

to Left
a,
end

to Right
b,
end

to Neck
c,
end

to Wings
d,
end

 

Cricket Code

to emit
loop [send 1]
end

 

 

Back