p5-rps-python-spec

Due Wednesday 4/21 at 8:00p.m. (accepted until 11:59 p.m.)

Overview

Note: This project is an re-implementation of our P2 RPS in Python!

In this project, you will be implemeting a rock-paper-scissors game! Rock-paper-scissors is a hand game played between two people, in which each player simultaneously forms one of three shapes with an outstretched hand. These shapes are “rock” (a simple fist), “paper” (a flat hand), and “scissors” (a fist with the index and middle fingers extended, forming a V).

A player who plays rock will beat another player who has chosen scissors, but will lose to one who has played paper; a play of paper will lose to a play of scissors. If both players choose the same shape, the game is tied.

See the image below for a visual representation of the rules of rock-paper-scissors:

rps

Objectives

Warning

Beware the autograder’s ability to detect cheating, see Honor Code for further information.

Honor Code

All students in the class are presumed to be decent and honorable, and all students in the class are bound by the College of Engineering Honor Code.

Any violation of the honor policies appropriate to each piece of course work will be reported to the Honor Council, and if guilt is established penalties may be imposed by the Honor Council and Faculty Committee on Discipline. Such penalties can include, but are not limited to, letter grade deductions or expulsion from the University.

Also note that on all cases forwarded to the Engineering Honor Council the LSA Dean of Academic Affairs is also notified. Furthermore, the LSA rule is that students involved in honor violations cannot withdraw from nor drop the course.

We run every submission against every other submission and determine similarities. All projects that are “too similar” are forwarded to the Engineering Honor Council. This happened to numerous students last semester. Also know that it takes months to get a resolution from the Honor Council. Discussion of the project will NOT be an issue. Sharing code between students will likely cause the cheating detector to identify both programs as “too similar”. We also search the web for solutions that may be posted online and add these into the mix of those checked for similarities. Searching the web, by the way, is something that we are very good at.

Also note that on all cases forwarded to the Engineering Honor Council the LSA Dean of Academic Affairs is also notified. Furthermore, the LSA rule is students involved in honor violations cannot withdraw from nor drop the course.

Grading

Working with a Partner

Distribution Code

For this project, you’ll first download “distribution code” written by us, and add your own lines of code to it. You can download it either from the Projects page of the course’s website or by clicking here on starter_files.zip. After downloading and unzipping it, you’ll find these files:

Note

Stubbing functions means adding the minimal necessary code to make a function execute. Be sure to remove our stubs when you write your own implementation of the functions.

Problem Statement

Your task for this project is to create a program for playing a game of rock-paper-scissors between two players. The game will consist of exactly three rounds of rock-paper-scissors. A player will need to win more of the three rounds than their opponent to win the game. The game will result in a tie if no player wins more rounds than the other player. For example: if Player 1 wins the first round while rounds 2 and 3 both result in a draw, Player 1 would win the game since they have won more rounds than Player 2.

Important

So that we can automate the testing of your code, the output messages for the rock-paper-scissors game must be exactly the same as presented in this specification and the function RMEs. Making sure they are exact is critical to passing the autograder. Check the Sample Output below for the exact prompts. To avoid spelling errors, simply copy/paste the appropriate prompt into your code. Note that a spelling error will cause you to fail almost every test case from the autograder.

Here is an example of what the execution of your final application will look like:


    ----------------------------------------
                   EECS 183
              Rock-Paper-Scissors
    ----------------------------------------

    Player 1, enter your name: Rana Makki

    Player 2, enter your name: David Cao



    Menu Options
    ------------
    1) Play rock, paper, scissors
    2) Play rock, paper, scissors, lizard, spock
    3) Quit

    Choice --> 1

    Rana Makki, enter your move: r

    David Cao, enter your move: p

    David Cao wins the round!

    Rana Makki, enter your move: r

    David Cao, enter your move: r

    This round is a draw!

    Rana Makki, enter your move: p

    David Cao, enter your move: s

    David Cao wins the round!

    Congratulations David Cao!
    You won EECS 183 Rock-Paper-Scissors!


    Menu Options
    ------------
    1) Play rock, paper, scissors
    2) Play rock, paper, scissors, lizard, spock
    3) Quit

    Choice --> 3


    ----------------------------------------
               Thanks for playing
              Rock-Paper-Scissors!
    ----------------------------------------

Development Cycle with Functions

In Project 1, you had to divide the program into pieces so you could test each part individually. In Project 2 and later, the program is already divided into functions in the starter code which you can use as the parts to work on. You should write, test, and debug one function at a time. See Lecture 5 for a recap of how to implement the iterative development cycle for functions.

The functions in a program call each other, and it is easiest to start with the functions that do not call any other functions. For example, in this project, getMove() will call isMoveGood(), so it makes sense to complete isMoveGood() before getMove(). We will be able to test isMoveGood() before we write the code that actually uses it in our program.

The order you write the functions will be different than the order they will appear in rps.py. We provide a suggested order for writing your functions in the Suggested Timeline.

Solution Overview

Note

Even though we are going over what happens in startRPS() early in the specification, this does NOT mean you should begin your implementation with startRPS(). Actually, you should write startRPS() last.

----------------------------------------
               EECS 183
          Rock-Paper-Scissors
----------------------------------------
----------------------------------------
               EECS 183
          Rock-Paper-Scissors
----------------------------------------

Player 1, enter your name:

Once Player 1’s name is entered, the program will prompt Player 2 for their name:

----------------------------------------
               EECS 183
          Rock-Paper-Scissors
----------------------------------------

Player 1, enter your name: Rana Makki
Player 2, enter your name:

Note that “Rana Makki” in the sample output above is user-entered text, and therefore is not included in the output prompt. Also note that player names can contain whitespace.

Important

For the functions you will implement, write their definitions below startRPS(), as indicated in rps.py.

printInitialHeader()

printMenu()

printErrorMessage()

printCloser()

getName()

getMenuChoice()

isMoveGood()

Important

Note that for this project you can assume user input will always be of the data type expected (which is string for moves). In other words, as the programmer, you only need to check that values entered are valid moves - you do not need to worry about users entering int, float, string,boolean or any combination of these.

getMove()

There are two types of messages that could be printed depending on the characters that users input for their moves:

----------------------------------------
               EECS 183
          Rock-Paper-Scissors
----------------------------------------

Player 1, enter your name: Rana Makki
Player 2, enter your name: David Cao
Rana Makki, enter your move: r
David Cao, enter your move: p
David Cao wins the round!
----------------------------------------
               EECS 183
          Rock-Paper-Scissors
----------------------------------------

Player 1, enter your name: Rana Makki
Player 2, enter your name: David Cao
Rana Makki, enter your move: r
David Cao, enter your move: a

ERROR: Illegal move given, using default
This round is a draw!

Note that in the above example, the round resulted in a tie because the default move value (‘r’) was used for David Cao once he entered invalid input.

isRoundWinner()

annouceRoundWinner()

doRound()

annouceWinner()

doGame()

Putting it Together: writing startRPS()

Function Table

Function Other functions it should call
getName() printErrorMessage()
getMenuChoice() printMenu()
isMoveGood() Does not utilize any other functions
getMove() printErrorMessage(), isMoveGood()
isRoundWinner() Does not utilize any other functions
announceRoundWinner() Does not utilize any other functions
doRound() getMove(), isRoundWinner()
announceWinner() Does not utilize any other functions
doGame() doRound(), announceRoundWinner()
startRPS() printInitialHeader(), getName(), getMenuChoice(), doGame(), announceWinner(), printCloser()

Here is an example of how to read the table:

Suggested Timeline

Note: It’s common to not completely understand the project after reading through the spec. This is okay! You can start working on the project without fully understanding the spec. In fact, working on the project will likely help you better understand the spec.

As an approximate timeline, you will be on track if by:

Working in Python

Getting Started

Note

This project must be completed using Python version 3

Important

Be sure to add your name, your uniqname and a small description of the program to the header comments.

Executing a Python file

When executing your python file, you should see something like the following message:

Testing

Testing Overview

Note

For this project, we will not check differences in whitespace; "hello world" and "helloworld" are considered to be equivalent. This applies to all whitespace, including new lines. This will not be the case in future projects.

Testing getName() and getMenuChoice()

Implementing Test Functions for Submission

How to Submit

Note

For this project, we will not check differences in whitespace; "hello " and "hello" are considered to be equivalent. This will not be the case in future projects.

Where to Begin

Style Checklist

Note

For this project, we will not grade style!

To maximize your style points, be sure to follow this non-exhaustive checklist:

Sample Output

Here are a few examples of the way your program output should look, wherein underlined text represents some user’s input.

Note

The following sample runs do not inlcude the menu selection detailed in Running the Program.

Sample Run 1.

----------------------------------------
               EECS 183
          Rock-Paper-Scissors
----------------------------------------

Player 1, enter your name: Rana Makki
Player 2, enter your name: David Cao


Menu Options
------------
1) Play rock, paper, scissors
2) Play rock, paper, scissors, lizard, spock
3) Quit

Choice --> 1

Rana Makki, enter your move: r
David Cao, enter your move: p
David Cao wins the round!

Rana Makki, enter your move: r
David Cao, enter your move: r
This round is a draw!

Rana Makki, enter your move: p
David Cao, enter your move: s
David Cao wins the round!

Congratulations David Cao!
You won EECS 183 Rock-Paper-Scissors!


Menu Options
------------
1) Play rock, paper, scissors
2) Play rock, paper, scissors, lizard, spock
3) Quit

Choice --> 3


----------------------------------------
           Thanks for playing
          Rock-Paper-Scissors!
----------------------------------------

Sample Run 2.

----------------------------------------
               EECS 183
          Rock-Paper-Scissors
----------------------------------------

Player 1, enter your name: Rana Makki
Player 2, enter your name: David Cao


Menu Options
------------
1) Play rock, paper, scissors
2) Play rock, paper, scissors, lizard, spock
3) Quit

Choice --> 4

Invalid menu choice


Menu Options
------------
1) Play rock, paper, scissors
2) Play rock, paper, scissors, lizard, spock
3) Quit

Choice --> 2

Under Construction
No winner!


Menu Options
------------
1) Play rock, paper, scissors
2) Play rock, paper, scissors, lizard, spock
3) Quit

Choice --> 3


----------------------------------------
           Thanks for playing
          Rock-Paper-Scissors!
----------------------------------------

Sample Run 3.

----------------------------------------
               EECS 183
          Rock-Paper-Scissors
----------------------------------------

Player 1, enter your name:
ERROR: Illegal name given, using default

Player 2, enter your name:
ERROR: Illegal name given, using default



Menu Options
------------
1) Play rock, paper, scissors
2) Play rock, paper, scissors, lizard, spock
3) Quit

Choice --> 1

Rocky, enter your move: R
Creed, enter your move: p
Creed wins the round!

Rocky, enter your move: s
Creed, enter your move: S
This round is a draw!

Rocky, enter your move: S
Creed, enter your move: P
Rocky wins the round!

No winner!


Menu Options
------------
1) Play rock, paper, scissors
2) Play rock, paper, scissors, lizard, spock
3) Quit

Choice --> 1

Rocky, enter your move: S
Creed, enter your move: p
Rocky wins the round!

Rocky, enter your move: r
Creed, enter your move: A
ERROR: Illegal move given, using default
This round is a draw!

Rocky, enter your move: S
Creed, enter your move: P
Rocky wins the round!

Congratulations Rocky!
You won EECS 183 Rock-Paper-Scissors!


Menu Options
------------
1) Play rock, paper, scissors
2) Play rock, paper, scissors, lizard, spock
3) Quit

Choice --> 3


----------------------------------------
           Thanks for playing
          Rock-Paper-Scissors!
----------------------------------------