A01/rpc.c
// play [rounds] rounds for rock paper scissors
// @param int AI score tracker
// @param int player score tracker
// @params number of rounds
play [rounds] rounds for rock paper scissors
play [ rounds ] rounds for rock paper scissors
int playRound(int aiScore, int playerScore, int rounds) {
	srand(time(NULL));
	char userChoice[50]; 
	for (int i = 0; i < rounds; i++) {
		printf("Which do you choose? rock, paper, or scissors? ");
		scanf("%s", userChoice);
                printf("Round %d\n", i);
		int r = rand() % 3; 
		if (r == 0){
			printf("AI chose rock.\n");
			if (strcmp(userChoice, "paper") == 0) {
				printf("Paper bashes rock.\n");
				playerScore++;
			} else if (strcmp(userChoice, "scissors") == 0) {
				printf("Rock bashes scissors.\n");
				aiScore++;
			} else if (strcmp(userChoice, "rock") == 0) {
				printf("Tie.\n");
			} else {
				printf("You entered an invalid choice: %s", userChoice);
			}
		}
		if (r == 1){
			printf("AI chose paper.\n");
			if (strcmp(userChoice, "scissors") == 0) {
				printf("Scissors cut  paper.\n");
				playerScore++;
			} else if (strcmp(userChoice, "rock") == 0) {
				printf("Paper covers  rock.\n");
				aiScore++;
			} else if (strcmp(userChoice, "paper") == 0) {
				printf("Tie.\n");
			} else {
				printf("You entered an invalid choice: %s", userChoice);
			}
		}
		if (r == 2){
			printf("AI chose scissors.\n");
			if (strcmp(userChoice, "rock") == 0) {
				printf("Rock bashes scissors.\n");
				playerScore++;
			} else if (strcmp(userChoice, "paper") == 0) {
				printf("Scissors cut paper.\n");
				aiScore++;
			} else if (strcmp(userChoice, "scissors") == 0) {
				printf("Tie.\n");
			} else {
				printf("You entered an invalid choice: %s\n", userChoice);
			}
		}
		printScore(aiScore, playerScore);
	}
	printWinner(aiScore, playerScore);
}
int playRound ( int aiScore , int playerScore , int rounds ) { srand ( time ( NULL ) ) ; char userChoice [ 50 ] ; for ( int i = 0 ; i < rounds ; i ++ ) { printf ( " " ) ; scanf ( " " , userChoice ) ; printf ( " \n " , i ) ; int r = rand ( ) % 3 ; if ( r == 0 ) { printf ( " \n " ) ; if ( strcmp ( userChoice , " " ) == 0 ) { printf ( " \n " ) ; playerScore ++ ; } else if ( strcmp ( userChoice , " " ) == 0 ) { printf ( " \n " ) ; aiScore ++ ; } else if ( strcmp ( userChoice , " " ) == 0 ) { printf ( " \n " ) ; } else { printf ( " " , userChoice ) ; } } if ( r == 1 ) { printf ( " \n " ) ; if ( strcmp ( userChoice , " " ) == 0 ) { printf ( " \n " ) ; playerScore ++ ; } else if ( strcmp ( userChoice , " " ) == 0 ) { printf ( " \n " ) ; aiScore ++ ; } else if ( strcmp ( userChoice , " " ) == 0 ) { printf ( " \n " ) ; } else { printf ( " " , userChoice ) ; } } if ( r == 2 ) { printf ( " \n " ) ; if ( strcmp ( userChoice , " " ) == 0 ) { printf ( " \n " ) ; playerScore ++ ; } else if ( strcmp ( userChoice , " " ) == 0 ) { printf ( " \n " ) ; aiScore ++ ; } else if ( strcmp ( userChoice , " " ) == 0 ) { printf ( " \n " ) ; } else { printf ( " \n " , userChoice ) ; } } printScore ( aiScore , playerScore ) ; } printWinner ( aiScore , playerScore ) ; }
play [rounds] rounds for rock paper scissors
play [ rounds ] rounds for rock paper scissors
// user choice (r,p,s) // reading string //generates 0, 1, or 2 // 0 = rock // If user chooses paper, wins // If user chooses, scissors, looses // If user chooses rock, tie // 1  = paper // If user chooses scissors, wins // If user chooses rock, looses // If user chooses paper, tie // 2 = scissors // If user chooses rockr, wins // If user chooses paper, looses // If user chooses scissors, tie