Description
PART 2: ROCK, PAPER, SCISSORS, LIZARD, SPOCK!
- A series of automated tests will run against your code. The results of these tests will appear on the right side of the screen, along with with your program's output and the expected output of the program for a given input.
- Important note: This program requires you to generate random numbers. If you generated your random numbers in a slightly different way that me you may get a different output from your program. That's OK, as long as your program meets the criteria of the assignment (the graders will be grading these manually). If you did watch to match my output you would need to generate the computer's choice using a random number between 1 and 5, where 1 = Rock, 2 = Paper, 3 = Scissors, 4 = Lizard and 5 = Spock (in that order)
For this program you will be building a Python version of the game "Rock Paper Scissors Lizard Spock" which was popularized by the TV show "The Big Bang Theory" - here's a quick video that introduces you to the game:
In this game the two players will select from one of 5 different choices - Rock, Paper, Scissors, Lizard or Spock. Each choice has the ability to win over two other choices. For example, Paper covers Rock, and Paper also "disproves" Spock. Each choice is also vulnerable against two other choices. For example, Scissors cuts Paper, and Lizard eats Paper. All of the possible combinations for the game can be seen in this diagram, and are reprinted in text form below:
- Scissors cuts Paper
- Paper covers Rock
- Rock crushes Lizard
- Lizard poisons Spock
- Spock smashes Scissors
- Scissors decapitates Lizard
- Lizard eats paper
- Paper disproves Spock
- Spock vaporizes Rock
- Rock crushes Scissors
Your task is to build a fully functional version of this game that allows the user to play a "tournament" of games against the computer. The user will indicate how many wins will be necessary to win the tournament at the beginning of the program.
Next, the game will continually let the user know the overall score and will prompt them to enter in one of the possible moves (Rock, Paper, Scissors, Lizard or Spock) - if the user supplies an invalid move the program should alert them and then re-iterate, ignoring the incorrect command and resetting the current round.
Finally, the computer should randomly select a move and the moves should be evaluated against one another. The game should "announce" the move using the descriptions presented in the graphic above (i.e. "Lizard eats Paper"). The game should keep track how many rounds have been played, which player wins each round, along with how many "ties" have been detected in the game. When the desired # of wins has been reached the program should end. At that point you should display a summary of the moves played by each player. Here's a sample running of the program:
Let's Play Rock, Paper, Scissors, Lizard, Spock! How many wins is required to end the tournament? 0 Invalid, try again How many wins is required to end the tournament? 3 OK, here we go ------------------------------------- Round #1 You have won 0 rounds The computer has won 0 rounds There have been 0 ties so far ------------------------------------- (R)ock, (P)aper, (S)cissors, (L)izard or Sp(O)ck: pikachu This is an invalid choice, please try again. ------------------------------------- Round #1 You have won 0 rounds The computer has won 0 rounds There have been 0 ties so far ------------------------------------- (R)ock, (P)aper, (S)cissors, (L)izard or Sp(O)ck: AARDVARK This is an invalid choice, please try again. ------------------------------------- Round #1 You have won 0 rounds The computer has won 0 rounds There have been 0 ties so far ------------------------------------- (R)ock, (P)aper, (S)cissors, (L)izard or Sp(O)ck: r The computer has selected Spock Spock vaporizes Rock! Computer wins! ------------------------------------- Round #2 You have won 0 rounds The computer has won 1 rounds There have been 0 ties so far ------------------------------------- (R)ock, (P)aper, (S)cissors, (L)izard or Sp(O)ck: P The computer has selected Spock Paper disproves Spock! User wins! ------------------------------------- Round #3 You have won 1 rounds The computer has won 1 rounds There have been 0 ties so far ------------------------------------- (R)ock, (P)aper, (S)cissors, (L)izard or Sp(O)ck: S The computer has selected Scissors The round has ended in a tie! No points awarded! ------------------------------------- Round #4 You have won 1 rounds The computer has won 1 rounds There have been 1 ties so far ------------------------------------- (R)ock, (P)aper, (S)cissors, (L)izard or Sp(O)ck: O The computer has selected Scissors Spock smashes Scissors! User wins! ------------------------------------- Round #5 You have won 2 rounds The computer has won 1 rounds There have been 1 ties so far ------------------------------------- (R)ock, (P)aper, (S)cissors, (L)izard or Sp(O)ck: r The computer has selected Scissors Rock crushes Scissors! User wins! User wins the game! Game summary: - Rock was played 2 times (User=2; Computer=0) - Paper was played 1 times (User=1; Computer=0) - Scissors was played 4 times (User=1; Computer=3) - Lizard was played 0 times (User=0; Computer=0) - Spock was played 3 times (User=1; Computer=2)
Here are some hints on your program:
- Get the game to work one time before adding a loop to control the overall tournament.
- Ensure that the user's input is case insensitive (i.e. "R" and "r" both count for "Rock")
- Don't place any loops inside of other loops - that isn't required for this question.
- This most likely won't be a short program. Make sure you make good use out of if / elif / else and nested statements to control the flow of your program.