|
@ -1791,10 +1791,16 @@ void v_play_rockpapersciss(){ |
|
|
int player_choice, computer_choice, player_score = 0, computer_score = 0; |
|
|
int player_choice, computer_choice, player_score = 0, computer_score = 0; |
|
|
srand(time(NULL)); |
|
|
srand(time(NULL)); |
|
|
|
|
|
|
|
|
|
|
|
printf("***************************\n"); |
|
|
|
|
|
printf("Playing Rock,Paper,Scissors!\n"); |
|
|
|
|
|
printf("***************************\n\n"); |
|
|
|
|
|
|
|
|
|
|
|
printf("First to win 3 rounds wins!\n\n"); |
|
|
|
|
|
|
|
|
while (1) |
|
|
while (1) |
|
|
{ |
|
|
{ |
|
|
printf("Enter your choice:\n"); |
|
|
printf("Enter your choice:\n"); |
|
|
printf("1. Rock\n2. Paper\n3. Scissors\n"); |
|
|
|
|
|
|
|
|
printf("1. Rock\n2. Paper\n3. Scissors\n\n"); |
|
|
printf("Your Choice:"); |
|
|
printf("Your Choice:"); |
|
|
scanf("%d", &player_choice); |
|
|
scanf("%d", &player_choice); |
|
|
computer_choice = (rand() % 3) + 1; |
|
|
computer_choice = (rand() % 3) + 1; |
|
@ -1802,16 +1808,16 @@ void v_play_rockpapersciss(){ |
|
|
{ |
|
|
{ |
|
|
if (computer_choice == ROCK) |
|
|
if (computer_choice == ROCK) |
|
|
{ |
|
|
{ |
|
|
printf("Tie! Both picked Rock\n"); |
|
|
|
|
|
|
|
|
printf("\nTie! Both picked Rock\n\n"); |
|
|
} |
|
|
} |
|
|
else if (computer_choice == PAPER) |
|
|
else if (computer_choice == PAPER) |
|
|
{ |
|
|
{ |
|
|
printf("You lose! I picked Paper\n"); |
|
|
|
|
|
|
|
|
printf("\nYou lose! I picked Paper\n\n"); |
|
|
computer_score++; |
|
|
computer_score++; |
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
|
printf("You win! I picked Scissors\n"); |
|
|
|
|
|
|
|
|
printf("\nYou win! I picked Scissors\n\n"); |
|
|
player_score++; |
|
|
player_score++; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -1819,16 +1825,16 @@ void v_play_rockpapersciss(){ |
|
|
{ |
|
|
{ |
|
|
if (computer_choice == ROCK) |
|
|
if (computer_choice == ROCK) |
|
|
{ |
|
|
{ |
|
|
printf("You win! I picked Rock\n"); |
|
|
|
|
|
|
|
|
printf("\nYou win! I picked Rock\n\n"); |
|
|
player_score++; |
|
|
player_score++; |
|
|
} |
|
|
} |
|
|
else if (computer_choice == PAPER) |
|
|
else if (computer_choice == PAPER) |
|
|
{ |
|
|
{ |
|
|
printf("Tie! Both picked Paper\n"); |
|
|
|
|
|
|
|
|
printf("\nTie! Both picked Paper\n\n"); |
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
|
printf("You lose! I picked Scissors\n"); |
|
|
|
|
|
|
|
|
printf("\nYou lose! I picked Scissors\n\n"); |
|
|
computer_score++; |
|
|
computer_score++; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -1836,22 +1842,22 @@ void v_play_rockpapersciss(){ |
|
|
{ |
|
|
{ |
|
|
if (computer_choice == ROCK) |
|
|
if (computer_choice == ROCK) |
|
|
{ |
|
|
{ |
|
|
printf("You lose! I picked Rock\n"); |
|
|
|
|
|
|
|
|
printf("\nYou lose! I picked Rock\n\n"); |
|
|
computer_score++; |
|
|
computer_score++; |
|
|
} |
|
|
} |
|
|
else if (computer_choice == PAPER) |
|
|
else if (computer_choice == PAPER) |
|
|
{ |
|
|
{ |
|
|
printf("You win! I picked Paper\n"); |
|
|
|
|
|
|
|
|
printf("\nYou win! I picked Paper\n\n"); |
|
|
player_score++; |
|
|
player_score++; |
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
|
printf("Tie! Both picked Scissors\n"); |
|
|
|
|
|
|
|
|
printf("\nTie! Both picked Scissors\n\n"); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
|
printf("Invalid choice!\n"); |
|
|
|
|
|
|
|
|
printf("\nInvalid choice!\n\n"); |
|
|
} |
|
|
} |
|
|
if (player_score == 3 || computer_score == 3) |
|
|
if (player_score == 3 || computer_score == 3) |
|
|
{ |
|
|
{ |
|
@ -1860,12 +1866,15 @@ void v_play_rockpapersciss(){ |
|
|
} |
|
|
} |
|
|
if (player_score == 3) |
|
|
if (player_score == 3) |
|
|
{ |
|
|
{ |
|
|
printf("You win the best of three!\n"); |
|
|
|
|
|
|
|
|
printf("You win the best of three!\n\n"); |
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
|
printf("I win the best of three!\n"); |
|
|
|
|
|
|
|
|
printf("I win the best of three!\n\n"); |
|
|
} |
|
|
} |
|
|
|
|
|
printf("******************************************\n"); |
|
|
|
|
|
printf("Thank you for playing Rock,Paper,Scissors!\n"); |
|
|
|
|
|
printf("******************************************\n\n"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|