COMP 142 Project 1: Rock-Paper-Scissors-Lizard-Spock

You will write a program that simulates the two-player game Rock-paper-scissors-lizard-Spock. This game is an extension of the traditional rock-paper-scissors (RPS) game with two additional choices: a lizard and Spock.

The game was popularized on The Big Bang Theory, though it was invented earlier as a way to reduce the probability of a tie in a regular rock-paper-scissors game.

Here's a brief introduction to the "regular" rock-paper-scissors game. RPS is two-player game that is played only with the hands. Each player mentally chooses one of "rock," "paper," or "scissors," and simultaneously the two players show (or, "throw") a hand symbol illustrating their choice. Rock uses a closed fist, paper uses an open hand with the fingers together, and scissors uses a fist with the pointer and middle finger extended.

Each one of the three hand gestures defeats one other gesture, and is defeated by one other gesture: rock crushes (beats) scissors, scissors cuts (beats) paper, and paper covers (beats) rock. If both players choose the same gesture, then the game is repeated. The game can be played until the first winner is determined or in repeated rounds.

Rock-paper-scissors-lizard-Spock (RPSLS) introduces two new gestures: lizard (all fingers touching the thumb) and Spock (fingers extended with a v-shape between the middle and ring figure). The new rules are as follows (in each rule, the first gesture beats the second)

Note that this rule set is an extension of the classic RPS rules. The rule set still permits a fair game: every gesture defeats two other gestures and loses to two other gestures (see the diagram). And while the possibility of tying still exists, the probability of ties is lower.

The goal of your project is to create a two player game of RPSLS. At the beginning of the game, you should ask the players how many points it will take to declare the winner of RPSLS. Your program will allow the players to play multiple rounds of RPSLS until one of them reaches the critical number of points. The winner of each round receives one point. Although ties are not as common, your program must be able to handle ties by allowing the users to go again until you can announce a proper winner of that round. You must adhere to good programming techniques and style while making sure your code is efficient. You should spend a significant amount of time thinking about what chunks of code will be reused and how you can take advantage of this when you write your program.

Here is a checklist of things that your program should include:

Language

If you took CS141, you should write this program in Python. If you took APCS and skipped CS141, you may use Java, since presumably you are familiar with that language. If you do not know Python or Java, talk to the instructor.

Coding style

Program- and function-level comments

These guidelines apply to this program and all future programs.

About the pledge

Because we are writing complex programs, it is not uncommon to get stuck. However, as the syllabus states, all homework assignments you complete outside of class must be entirely your own work, with the exception of help from the instructor, tutors, or other people while respecting the "Rules for Completing Assignments Independently" (see the syllabus).

I'm asking everyone to please include the honor pledge in the comments at the top of your programs indicating you have conformed to the request to work individually. (See the example above for the text to include.)

Testing your program

You should test your program thoroughly to make sure it works. Your program should gracefully handle situations where numbers are typed incorrectly for the number of points to win, or the gesture to throw.

Sample interaction

Welcome to Rock, Paper, Scissors, Lizard, Spock!

How many points does it take to win? 2
Please enter Player 1's name: Alice
Please enter Player 2's name: Bob

ROUND 1
Enter (0) Rock, (1) Paper, (2) Scissors, (3) Lizard, (4) Spock

Alice, enter your throw: 4
Bob, enter your throw: 0

Spock defeats Rock
Alice defeats Bob

Here's the score: Alice (1), Bob (0) 

ROUND 2
Enter (0) Rock, (1) Paper, (2) Scissors, (3) Lizard, (4) Spock

Alice, enter your throw: 3
Bob, Enter your throw: 2

Scissors defeats Lizard
Bob defeats Alice

Here's the score: Alice (1), Bob (1) 

ROUND 3
Enter (0) Rock, (1) Paper, (2) Scissors, (3) Lizard, (4) Spock

Alice, enter your throw: 5
Incorrect choice
Alice, enter your throw: 3
Bob, Enter your throw: 3

It's a tie, both players will throw again.

Alice, enter your throw: 4
Bob, Enter your throw: 2

Spock defeats Scissors
Alice defeats Bob

Here's the score: Alice (2), Bob (1) 

FINAL RESULTS
Alice wins by a score of 2 to 1!

What to turn in

Through Moodle, turn in your code as a file called rpsls_yourLastName_yourFirstName.py.

Challenge Problems

From time to time, I will offer "challenge problems" on assignments. These problems are designed to have little (but some) impact on your grade whether you do them or not. You should think of these problems as opportunities to work on something interesting and optional, rather than a way to raise your grade through "extra credit."

Policy on challenge problems:

Challenge problem for this assignment: