/*precondition:robot has displaced 4 balls into its scoring area, it's either facing forward or backwards, outside 
of the scoring area
 postcondition: robot is turned in correct direction to begin its long journey , we return a number that tells
 us whether we're headed clockwise or counterclockwise */

/*returns -1 for clockwise, 1 for counter clockwise--following angle measurement convention */


/*function test*/
/*void main() {
	float c;
	int facing_dir;*/
	/*calibrate_IR();*/
/*
	start_press();
	rf_team=21;
	rf_enable();
	start_machine();
	facing_dir=orient();
	get_bot_num();
*/	
	/*printf("Me:(%d, %d) Op:(%d, %d)\n", my_x(botID), my_y(botID), opp_x(botID), opp_y(botID));*/
/*	start_press();

	printf("Winner: %d\n", rf_vote_winner); 
	start_press();
	c=losing_vote_dir();
	printf("C= %f \n", c);	
	start_press();

}*/

/*collect balls that are on the losing vote direction */
float losing_vote_dir() {
		if( rf_vote_winner==0 && my_start_side() ==1 ) {
		  /*red is winning, we're on white side, go clockwise to collect green balls*/
		printf("red win, start side: white\n"); 
		start_press();
			return -1.0;
		}
		/*red is winning, we're on black side*/
		else if (rf_vote_winner==0 && my_start_side()==0) {
				printf("red win, start side: BLACK\n"); 
		start_press();
			return 1.0;   /*counterclockwise*/
		}
		/*green is winning, we're on white side*/
		else if (rf_vote_winner==1 && my_start_side()==1) {
				printf("green win, start side: white\n");
			start_press(); 
			return 1.0;  /*go counterclockwise to collect red*/
		}
			/*green is winning, we're on black side*/
		else if (rf_vote_winner==1 && my_start_side()==0) {
				printf("green win, start side: black\n");
				start_press(); 
			return -1.0;  
		}
		else {
			printf("Error!\n");
			return 1.0; /*pick arbitrary direction*/
		}

}

/*function to decide whether robot should go in clockwise or counterclockwise direction, depending on rf coordinate of other robot*/
/*if other robot isn't starting -rf coordinate pretty close to zero, we'll go in direction of currently winning vote)*/
float decide_clockwise_or_cclockwise() 
{

	/*are we on black side or white side???*/
	/*get my coordinates, get my opponents coordinates, decide which direction to go in*/
	/*case 1 & 2: i'm on the white side: */

	int margin; /*opponent robot has to be margin rf coord away from start before we decide to go in opp direction of it */
	margin = 300;
/*	if (my_y(botID)<=0 && opp_x(botID)<=-margin) {
		return 1.0;		
	}
	else if (my_y(botID)<=0 && opp_x(botID)>margin) {
		return -1.0;
	}
	
	
	else if (my_y(botID)>0 && opp_x(botID)<=-margin) {
		return -1.0;  
	}
	else if (my_y(botID)>0 && opp_x(botID)>margin) {
		return 1.0;  
	}
*/
			/*red is winning, we're on white side, go counter clockwise*/
	/*else {*/

		if( rf_vote_winner==0 && my_y(botID)<=0 ) {  /*red is winning,*/ 
			return 1.0;
		}
		/*red is winning, we're on black side*/
		else if (rf_vote_winner==0 && my_y(botID)>0) {
			return -1.0;   /*clockwise*/
		}
		/*green is winning, we're on white side*/
		else if (rf_vote_winner==1 && my_y(botID)<=0) {
			return -1.0;
		}
			/*green is winning, we're on black side*/
		else if (rf_vote_winner==1 && my_y(botID)>0) {
			return 1.0;   /*clockwise*/
		}
		else {
			printf("Error!\n");
			return 1.0; /*pick arbitrary direction*/
		}
		
	
	/*}*/

}












