Handy Logo Code for Billy the Bully's Aggression

to bully

launch [warn]

launch [chase-kid]

launch [attack-kid]

end

 

to warn

loop [irsend 10]

end

 

to chase-kid

ifelse not (or (sees-kid? left-sensor) (sees-kid? right-sensor))

[ab, onfor 20 a, onfor 5 chase-kid]

[follow-kid]

 

end

 

to attack-kid

loop [if and (sees-kid? inner-sensor1) (sees-kid? inner-sensor2) [hit]]

end

 

to hit

repeat 4 [c, onfor 3

rd

onfor 2

rd]

end

to sees-kid? :sensor-value

output (:sensor-value < 210)

end

 

to turn-left

b, on thisway

end

 

to turn-right

a, on thisway

end

 

to stop-left-turn

b, off

end

 

to stop-right-turn

a, off

end

 

to left-sensor

output sensor 1

end

 

to right-sensor

output sensor 2

end

 

to inner-sensor1

output sensor 3

end

 

to inner-sensor2

output sensor 4

end

 

to follow-kid

loop [ifelse sees-kid? left-sensor

[turn-left] [stop-left-turn]

ifelse sees-kid? right-sensor

[turn-right] [stop-right-turn]]

end