menu 1 [escape] menu 2 [change+10] menu 3 [change-10] global [card some ping change] to detect-obstacle if (switch 7) [go-backwards go-random-direction] if (switch 9) [go-forwards go-random-direction] if ((sensor 1) < (ping - change)) [go-backwards go-random-direction] end to go-straight a, thatway on b, thatway on end to go-backwards setsome random 20 a, rd onfor some b, rd onfor some end to go-forwards setsome random 20 a, thatway onfor some b, thatway onfor some end to go-random-direction setcard (random 20) + 10 a, onfor card b, off end to escape initialize loop[ go-straight detect-obstacle ] end to initialize a, setpower 4 b, setpower 4 setping (sensor 1) setchange 40 end to change+10 setchange change + 10 end to change-10 setchange change - 10 end