start: if !Sense Ahead Home && !Sense LeftAhead Home && !Sense RightAhead Home then (* point 1 *) goto start_tracer_right else Turn Left; if Sense Ahead Marker _xxxxx1 then goto start_tracer_left else Turn Left; if !Sense Ahead Home && !Sense LeftAhead Home && !Sense RightAhead Home then (* point 2 *) goto start_tracer_right else Turn Left; if Sense Ahead Marker _xxxxx1 then goto start_tracer_left else Turn Left; if !Sense Ahead Home && !Sense LeftAhead Home && !Sense RightAhead Home then (* point 3 *) goto start_tracer_right else Turn Left; Drop; if Sense Ahead Marker _xxxxx1 then goto start_tracer_left else (* we are now facing southeast! *) if !Sense Ahead Home && !Sense LeftAhead Home && !Sense RightAhead Home then (* dock *) Mark _x1xxxx; Move; Move; goto seek_food else Drop; if Sense Ahead Marker _x1xxxx then (* VIP *) Mark _xx1xxx; Move; Move; goto seek_food else Drop; if Sense Ahead Marker _xx1xxx || Sense LeftAhead Marker _xx1xxx || Sense RightAhead Marker _xx1xxx then goto guardian else Turn Left; if Sense LeftAhead Marker _xx1xxx then goto guardian else Turn Right; Turn Right; if Sense RightAhead Marker _xx1xxx then goto guardian else (* we are now facing southwest! *) goto seek_food guardian: Drop; goto guardian start_tracer_right: Mark _xxxxx1; Move; goto tracer_right tracer_right: (* keeps _objects_ to the right *) if Sense Here Home then goto seek_food else Mark _xxxxx1; if Sense Ahead Rock || Sense LeftAhead Rock || Sense RightAhead Rock then goto right_follow else if Sense Ahead Marker _xxxxx1 then goto erase_two else Move; goto tracer_right right_follow: Mark _xxxxx1; if Sense Ahead Rock || Sense LeftAhead Rock then Turn Left; goto right_follow else if !Sense RightAhead Rock then Turn Right; goto right_follow else if Sense Ahead Marker _xxxxx1 then if Sense Ahead Friend then identify: Mark _xxxx1x; Drop; Drop; Drop; Drop; Drop; Drop; Drop; Drop; Drop; Drop; Drop; Drop; Drop; Drop; Drop; Drop; Drop; Drop; Drop; Drop; if Sense Ahead Marker _xxxx1x then Drop; Drop; Drop; Drop; Drop; Drop; Drop; Drop; Drop; Drop; Drop; Drop; Drop; Drop; Drop; Drop; Drop; Drop; Drop; Drop; Turn Left; Turn Left; Mark _xxxx0x; goto tracer_right else goto erase_two else goto erase_two else Move; goto right_follow start_tracer_left: Turn Right; Move; goto tracer_left tracer_left: (* keeps _objects_ to the left *) if Sense Here Home then goto seek_food else Mark _xxxxx1; if Sense Ahead Rock || Sense LeftAhead Rock || Sense RightAhead Rock then goto left_follow else if Sense Ahead Marker _xxxxx1 then goto erase_two else Move; goto tracer_left left_follow: Mark _xxxxx1; if Sense Ahead Rock || Sense RightAhead Rock then Turn Right; goto left_follow else if !Sense LeftAhead Rock then Turn Left; goto left_follow else if Sense Ahead Marker _xxxxx1 then if Sense Ahead Friend then identify: Mark _xxxx1x; Drop; Drop; Drop; Drop; Drop; Drop; Drop; Drop; Drop; Drop; Drop; Drop; Drop; Drop; Drop; Drop; Drop; Drop; Drop; Drop; if Sense Ahead Marker _xxxx1x then Drop; Drop; Drop; Drop; Drop; Drop; Drop; Drop; Drop; Drop; Drop; Drop; Drop; Drop; Drop; Drop; Drop; Drop; Drop; Drop; Turn Right; Turn Right; Mark _xxxx0x; goto tracer_left else goto erase_two else goto erase_two else Move; goto left_follow erase_two: (* well, except if we see rock *) if Sense LeftAhead Rock || Sense Ahead Rock || Sense RightAhead Rock then goto seek_food else Turn Left; Turn Left; Turn Left; Mark _xxxxx0; ahead: if Sense Ahead Marker _xxxxx1 then repeat: Move onfail repeat; Mark _xxxxx0; goto seek_food else if Sense LeftAhead Marker _xxxxx1 then Turn Left; goto ahead else if Sense RightAhead Marker _xxxxx1 then Turn Right; goto ahead else goto seek_food (* wander around until we find something *) seek_food: if !Sense Here Home && (Sense LeftAhead Home || Sense Ahead Home || Sense RightAhead Home) then Turn Left; Turn Left; Turn Left; Move; Move; goto seek_food else if Sense Here Food && !Sense Here Home then PickUp; goto got_food else if Sense Ahead Food && !(Sense Ahead Home || Sense Ahead Friend || Sense Ahead Foe) then Move onfail seek_food; PickUp; goto got_food else if Sense LeftAhead Food && !(Sense LeftAhead Home || Sense LeftAhead Friend || Sense LeftAhead Foe) then Turn Left; Move onfail seek_food; PickUp; goto got_food else if Sense RightAhead Food && !Sense RightAhead Home then Turn Right; Move onfail seek_food; PickUp; goto got_food else if Flip 3 && !(Sense Ahead Rock || Sense Ahead Friend || Sense Ahead Foe) && (Sense Here Home || !Sense Ahead Home) then Move; (* Mark _1xxxxx; *) (* if this were a real emergency... *) goto seek_food else if Flip 2 then Turn Left; goto seek_food else Turn Right; goto seek_food got_food: Turn Left; Turn Left; goto have_food (* wander back to base *) have_food: if Sense LeftAhead Home then Turn Left; Turn Left; goto holding_pattern else if Sense Ahead Home then Turn Left; goto holding_pattern else if Sense RightAhead Home then goto holding_pattern else if Sense LeftAhead Marker _xxxxx1 then Turn Left; Turn Left; goto follow_tracer else if Sense Ahead Marker _xxxxx1 then Turn Left; goto follow_tracer else if Sense RightAhead Marker _xxxxx1 then goto follow_tracer else if Flip 3 && !(Sense LeftAhead Foe && Sense RightAhead Foe) then Move; goto have_food else if Flip 2 then Turn Left; goto have_food else Turn Right; goto have_food holding_pattern: (* invariant: home on right *) if Sense RightAhead Marker _x11xxx then (* dock in use *) goto holding_pattern else if Sense RightAhead Marker _x10xxx then (* dock not in use *) Turn Right; Move onfail dock_access_denied; Mark _xx1xxx; Turn Right; Move onfail unauthorized_access; Drop; (* deposit to VIP *) Turn Right; Turn Right; Turn Right; repeat: Move onfail repeat; Turn Right; Mark _xx0xxx; repeat: Move onfail repeat; Move; goto seek_food else repeat: Move onfail repeat; if Sense RightAhead Home then goto holding_pattern else Turn Right; goto holding_pattern dock_access_denied: (* wave off *) Turn Left; Turn Left; Turn Left; Move; Turn Left; Move; goto have_food unauthorized_access: (* bolter *) Turn Left; Turn Left; Mark _xx0xxx; repeat: Move onfail repeat; Turn Right; goto holding_pattern follow_tracer: if Sense LeftAhead Home then Turn Left; Turn Left; goto holding_pattern else if Sense Ahead Home then Turn Left; goto holding_pattern else if Sense RightAhead Home then goto holding_pattern else if Sense LeftAhead Marker _xxxxx1 then Turn Left; Turn Left; goto follow_tracer else if Sense Ahead Marker _xxxxx1 then Turn Left; goto follow_tracer else if Sense RightAhead Marker _xxxxx1 then Move; goto follow_tracer else Turn Right; goto follow_tracer (* vim: sw=2 et *)