Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Part 1 : Extended \\Rock, Paper, Scissors\" Game in C Write a C program for a te

ID: 3616784 • Letter: P

Question

Part 1 : Extended Rock, Paper, Scissors" Game in C
Write a C program for a text-based extended variant of the Rock,Paper, Scissors" game
called: Rock, Paper, Scissors, Lizard, Spock" (by S. Kass and K.Bryla, 1).
Description
The game is played by two players: a human and the computer. Nearlyeveryone is familiar
with the traditional rules of the Rock, Paper, Scissors" game, butthis version increases the
number of possible outcomes. The rules to choose the winner are (ineach rule the left item
wins over the right item):
. Scissors cut Paper.
. Paper covers Rock.
. Rock crushes Lizard.
. Lizard poisons Spock.
. Spock smashes Scissors.
. Scissors decapitates Lizard.
. Lizard eats Paper.
. Paper disproves Spock.
. Spock vaporises Rock.
. Rock crushes Scissors.
Just as in the regular version of the game, there is a tie if bothplayers choose the same
item. The choices of each player (human and computer) should beoutput to the screen
along with the outcome of the game (win, tie or loss). When thehuman player chooses
to end the game, the program should output some game statistics:the number of times
the game ended in a win, tie or a loss for the human player, thenumber of games played
and the length of the win or loss streak (ex: if the human has onetwo games in a row: 2
game winning streak, then as soon as the human loses it becomes: 1game losing streak, etc).
Your program can use integer values to represent the entities Rock,Paper, Scissors,
Lizard, or Spock, but the choices should be presented in the outputas strings (see example
run). The human player can pick his/her choice by typing in anumber but you must display
a menu with the number and item assignment for every round (seeexample run).
1http://www.samkass.com/theories/RPSSL.html

Functions
The following functions MUST be in your program and MUST have thesame names (al-
though you can have more functions if necessary):
. main()
{ This function should set up the necessary variables, print awelcome message, the
rules of play, instructions and call the other functions listedbelow in the proper
order.
{ once the human player decides to quit, it should print out:
1. Number of wins, ties and losses for the human player.
2. Total number of rounds played.
3. Current streak (X{game winning streak, X{game tieing streak orX{game
losing streak).
. computerPick()
{ This function should return an integer value representing theitem that the com-
puter picked. The choice of the computer should be random. You canuse the
rand() and srand() functions to randomize the choice.
. humanPick()
{ This function should print the item menu and prompt the user forhis/her pick.
It should return an integer value representing the item that thehuman picked or
a choice to end the game.
. findWinner()
{ This function should take the two players' choices and return 1if the human
player won, 0 if there is a tie, or -1 if the computer won.
. NOTE: All the functions above (except main()) should be in aseparate .c file and
the declarations for those functions should be found in a .hfile.
Notes
. NO global variables should be used in your program. Constants or#define directives
are allowed if necessary.
. Your program should follow the specifications given here. See themarking scheme for
Example Run
Here is a sample output:
lambda01:»> ./RPSLS
Welcome to the Rock-Paper-Scissors-Lizard-Spock Game!
1:Rock, 2:Paper, 3:Scissors, 4:Lizard, 5:Spock or 0:Quit? 1
Human: Rock, Computer: Lizard => You Win!
1:Rock, 2:Paper, 3:Scissors, 4:Lizard, 5:Spock or 0:Quit? 4
Human: Lizard, Computer: Scissors => You Lose!
1:Rock, 2:Paper, 3:Scissors, 4:Lizard, 5:Spock or 0:Quit? 3
Human: Scissors, Computer: Rock => You Lose!
1:Rock, 2:Paper, 3:Scissors, 4:Lizard, 5:Spock or 0:Quit? 1
Human: Rock, Computer: Rock => You Tie!
1:Rock, 2:Paper, 3:Scissors, 4:Lizard, 5:Spock or 0:Quit? 5
Human: Spock, Computer: Rock => You Win!
1:Rock, 2:Paper, 3:Scissors, 4:Lizard, 5:Spock or 0:Quit? 2
Human: Paper, Computer: Spock => You Win!
1:Rock, 2:Paper, 3:Scissors, 4:Lizard, 5:Spock or 0:Quit? 0
Wins: 3, Ties: 1, Losses: 2, Rounds played: 6, 2-game winningstreak.
1. Source code (at least two .c and two .h files). Make sure to usecomments, inden-
tation, structure, meaningful variable names etc. in yourprogram.
2. Makefile: you should have ONE Makefile for both Parts 1 and2.
. make game: should compile the game in Part 1 and name theexecutable RPSLS.
. make bit: should compile the bit manipulation program from Part 2and name
the executable bit.
. make all: should compile both bit and RPSLS.

Explanation / Answer

please rate - thanks #include #include #include int getcomputermove(); int getusermove(); void updatescores(int,int, int*,int*,int*,int*); void conclusion(int,int,int,int,int); int main() { srand(time(0)); intcomputer=0,human=0,round=0,streak=-1,count=0,a,b,prev=-1; charmoves[5][9]={"Rock","Paper","Scissors","Lizard","Spock"}; char streaktype[3][5]={"win","lose","tie"}; printf("Welcome to the Rock-Paper-Scissors-Lizard-SpockGame! "); for (round=0; ;round++)         {a=getusermove();          if(a==0)              {conclusion(human,computer,streak,count,round);                 getch();                return 0;                }         b=getcomputermove();          printf("Human: %s,Computer: %s => You ",moves[a-1],moves[b-1]);         updatescores(a,b,&computer,&human,&streak,&count);         printf("%s ",streaktype[streak]);                        } } int getusermove() {int a;     printf("1:Rock, 2:Paper, 3:Scissors, 4:Lizard,5:Spock or 0:Quit? ");     scanf("%d",&a);     while(a5)      {printf("invalid entry ");      scanf("%d",&a);      } return a; } int getcomputermove() {int move=rand()%5+1; return move ; } void updatescores(int a,int b,int *c,int *h,int *streak, int*count) {int beats[5][2]={3,4, 1,5, 2,4, 5,2,  3,1}; int i,j,win=0; if(a==b)                           //tie      {win=1;     if(*streak==2)               //streak 0, win, 1, loss, 2 tie          *count=*count+1;       else          {*streak=2;           *count=1;            }            } else     {for(i=0;i