int our_color; float orient() { while(!lightrdy) {defer();} our_color=detect_our_color(); if(leftlight!=our_color) return 1.8; /* Right */ else if(rightlight!=our_color) { turn_dist(1,7,0.); return 2.1; /* Up */ } else if(backlight!=our_color) { drive_dist(0,12,0.); stop(); turn_dist(1,17,0.); return 2.9; /* Left */ } else { turn_dist(0,6,0.); return 2.0; /* Down */ } } int detect_our_color() { return((rightlight+leftlight+backlight)>1); }