void main() { ir_transmit_off(); calibrate(); /* IN calibrat.c */ start_machine(26); /* start_process(heinz());*/ down(); orient(); lights_on(); start_process(stall()); /* Drive Forward toward the first ball */ pid_df = start_process(drive_forward()); sleep(1.0); while(!mine(fm, threshold_ctr)); /*Stop when it hits wall*/ while(!(digital(9) || digital(10) || stalled)); stop_going_forward(); /* Attempt to grab the ball*/ hold(); sleep(0.5); back_up_little(); sleep(0.5); /* If there's no ball, put down the ramp to avoid squishage */ if (!got_ball()) down(); /* Drive back to the line */ bk(1); pid_db = start_process(drive_backward()); while(!(mine(light_port[1], threshold[1]) || mine(light_port[2], threshold[2]) || stalled)); stop_going_backward(); if (got_balls()) { pid_db = start_process(drive_backward()); sleep(2.3); stop_going_backward(); shoot(); down(); /* now drive back towards line and commence with TL90 */ pid_df = start_process(drive_forward()); sleep(1.0); while(!(mine(light_port[1], threshold[1]) || mine(light_port[2], threshold[2]) || stalled)); stop_going_forward(); } while (1) { /* Turn Left 90 degrees toward the other ball and MARCH!!! */ tl90(); pid_df = start_process(drive_forward()); /* STOP when it crushes into the wall hopefully with the big huge slimy green ball*/ while(!(digital(9) || digital(10) || stalled)); stop_going_forward(); /* Attempt to grab the ball */ hold(); sleep(0.5); back_up_more(); sleep(0.5); /* If rejected, put down the ramp */ if (!got_ball()) down(); /* Moon the oppoenent, run away*/ tr90(); pid_df = start_process(drive_forward()); while(!(digital(9) || digital(10) || stalled)); stop_going_forward(); /* Give a better mooning */ pid_db = start_process(drive_backward()); while(!(mine(light_port[1], threshold[1]) || mine(light_port[2], threshold[2]) || stalled)); stop_going_backward(); /* if we don't have much time, stop what we are doing and execute endgame strategy */ if (seconds() > 50.0) { endgame_strategy(ENEMY_TERRITORY); } if (got_balls()) { pid_db = start_process(drive_backward()); sleep(2.3); stop_going_backward(); shoot(); down(); /* now drive back towards line and commence with TL90 */ pid_df = start_process(drive_forward()); sleep(1.0); while(!(mine(light_port[1], threshold[1]) || mine(light_port[2], threshold[2]) || stalled)); stop_going_forward(); } /* If you still got hold of the ball */ /* if (got_balls()) {*/ /* Poop bomb */ /* can_i_shoot(ENEMY_TERRITORY);*/ /* flush */ /* down(); }*/ /* Show them your cheek */ tr90(); /* We got them now! */ pid_df = start_process(drive_forward()); while(!(digital(9) || digital(10) || stalled)); stop_going_forward(); /* If you are lucky enough to get more balls on one night */ hold(); sleep(1.0); back_up_more(); /* Had enough for one night? */ if (!got_ball()) down(); /* Give them another good look at the hole, and then tease 'em*/ tl90(); pid_df = start_process(drive_forward()); while(!(digital(9) || digital(10) || stalled)); stop_going_forward(); /* if we don't have much time, stop what we are doing and execute endgame strategy */ if (seconds() > 50.0) { endgame_strategy(OUR_SIDE); } if (got_balls()) { pid_db = start_process(drive_backward()); sleep(2.3); stop_going_backward(); shoot(); down(); /* now drive back towards line and commence with TL90 */ pid_df = start_process(drive_forward()); sleep(1.0); while(!(mine(light_port[1], threshold[1]) || mine(light_port[2], threshold[2]) || stalled)); stop_going_forward(); } /* OH GOD YOU ARE WILD TONIGHT!!!! */ /* if (got_balls()) */ /* {*/ /* Let it go, dude */ /* can_i_shoot(OUR_SIDE);*/ /* Put your hands away*/ /* down();*/ /* }*/ } } void endgame_strategy(int side) { if (where_ir() == SOUTH && (analog(2) > 30)) { if (side == ENEMY_TERRITORY) tr90(); else tl90(); shoot(); } else { pid_db = start_process(drive_backward()); while (!stalled); if (!(mine(light_port[3], threshold[3]) || mine(light_port[4], threshold[4]))) shoot(); } }