Lecture notes for the Introduction to Computer Science I by James Tam Return to the course web page

CPSC 231: Assignment 4 (Worth 3%)

Grading Scales

Grade out of 24 Letter
53 - 54 A+
51 - 52 A
48 - 50 A-
44 - 47 B+
40 - 43 B
36 - 39 B-
32 - 35 C+
28 - 31 C
24 - 27 C-
18 - 23 D+
12 - 17 D
6 - 11 D-
0 - 5 F

 

New concepts to be applied for this assignment

 

The Rock-Paper-Scissors game

This is a simple two player game where each player is allowed one of three possible hand gestures: rock, paper or scissors. Players are supposed to select their gesture at the same time and the gesture selected determines the outcome:

Player 1 Player 2 Outcome of the game
Rock Rock Tie
Rock Paper Paper covers rock (player 2 wins)
Rock Scissors Rock blunts the scissors (player 1 wins)
Paper Rock Paper covers rock (player 1 wins)
Paper Paper Tie
Paper Scissors Scissors cuts paper (player 2 wins)
Scissors Rock Rock blunts the scissors (player 2 wins)
Scissors Paper Scissors cuts paper (player 1 wins)
Scissors Scissors Tie

If a player tries to cheat (e.g., delays the selection of their gesture) then that player has committed a foul and is given a "forced rock" for their gesture regardless of the gesture selected.  You can go the following url to try a web based version of the game: http://www.playrps.com/.

 

Features to be implemented (you will also be graded on other criteria such as coding style and providing program documentation as listed in the marking guide):

Version with two people playing the game
 
  1. The first time that game is run it displays an introduction to game with a brief description of the rules: 1 mark
 
  1. When the player quits the game it displays a brief conclusion/signoff message: 1 mark
 
  1. Displays a menu of allowable gestures when each player to selects their gesture: 1 mark
 
  1. Reads each player's selected gesture in the form of a single lower case character: 1 mark
 
  1. The game can check if a foul has occurred (in this case the player has not entered 'r', 'p' or 's' for their selected gesture and will give the fouling player the rock gesture for that round: 4 marks
 
  1. Upper or lower case input is allowed  (e.g., 'R' or 'r'): 4 marks
 
  1. Compares the gestures for the players and can correctly determine and display onscreen: which player is the winner, which player is the loser or if there is a tie: 12 marks
 
  1. After a turn has been played (the player's select their respective gesture and the game determines the outcome), the program will ask the player if he or she wishes to play again and play another turn if this is the case or end the game and display a signoff message otherwise: 4 marks
Versions that include a computer-controlled opponent: In all the versions below the program will prompt the player to enter in the number of players (0, 1, 2). If another value is entered then the game will default to two computer players.
 
  1. The game allows for one computer-controlled opponent which has an equal probability of selecting each gesture: 2 marks
 
  1. The game allows for two computer-controlled opponents that play each other: 2 marks

 

Submission requirements

In addition to having fulfill the generic assignment requirements, the requirements specific to this assignment include:

  1. Include a README file in your submission:  For this assignment your README file must include your contact information: your name, university identification number and UNIX login name so that your marker knows whose assignment that he or she is marking.   For this assignment you should also list the features of the game that you actually implemented.

  2. Assignments (source code/'dot-p' file and the README file) must be electronically submitted.  In addition a paper print out of the source code and README must be handed into the assignment drop box (located on the second floor of the Math Sciences building) for the tutorial that you are registered in.  Electronically submitting the assignment allows your marker to run the code in order to quickly determine what features were implemented.  Providing a paper printout makes it easier for your marker to read and flip through your source code.  Unless you are told otherwise you are to email your source code and readme file to your TA and to me.  Make sure that include the following information in the subject line: "CPSC 231 Assignment X" where 'X' stands for the assignment number that you are submitting e.g., "CPSC 231 Assignment 3".

  3. As a reminder, you are not allowed to work in groups for this class.   Copying the work of another student will be regarded as academic misconduct (cheating).  For additional details about what is and is not okay for this class please refer to the following link.

To help make sure that you haven't missed anything here is a checklist of items to be used in marking.  A sample executable 'rps' can be found in UNIX under the directory: /home/231/tamj/assignments/assignment4.