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

CPSC 231: Assignment 3

 

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/. Also you can find a sample executable called 'rps' in UNIX under the path: /home/231/assignments/assignment3.

 

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. Each time that the game is run (but not re-run, see feature #8) it displays an introduction to game with a brief description of the rules.
 
  1. When the player quits the game it displays a brief conclusion/signoff message.
 
  1. Displays a menu of allowable gestures when each player to selects their gesture.
 
  1. Reads each player's selected gesture in the form of a single lower case character.
 
  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.
 
  1. Upper or lower case input is allowed  (e.g., 'R' or 'r'). This can be done with a pre-created Pascal function (rather than writing the code for it yourself).
 
  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.
 
  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.
 
  1. The game tracks and displays the number of wins and loses for each player.
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.
 
  1. The game allows for two computer-controlled opponents that play each other.

 

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 you need to include a file called 'README' which includes 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.  Also it should list the features of the assignment that have been implemented in your program.

 
  1. The programming assignments require a two part submission: a) A paper submission of your README file and Pascal program into the assignment drop boxes (second floor Math Sciences) b) An electronic submission (again of your README file and your Pascal program) as an email attachment (don't cut and paste it into the email body!) to the following people (failing to include everyone listed below may result in your assignment not being marked for credit so before submitting your assignment double check!) Make sure that the subject line of the email contains the exact text (don't add or delete anything to it or you will lose marks - mail filters work by looking for specific words in the subject line): CPSC 231 Assignment X. Both parts are necessary. Electronically submitting the assignment allows your marker to compile and 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.  A typescript of your execution is not needed for the programming assignments (this assignment onwards).

X = The appropriate assignment number (e.g., for Assignment 2 the subject would be titled "CPSC 231 Assignment 2")

 
  1. The course instructor at the following email address: tamj@cpsc.ucalgary.ca
 
  1. Your tutorial instructor, the email addresses for the TA's can be found on the main course web page.
 
  1. Yourself. Sending the assignment to yourself provides one last "double check" that you submitted your assignment properly (e.g., you sent it to all the right people, you attached all the important files to the submission etc...you should actually open the file attachments and check the files rather than just looking at the email). When you receive the submitted assignment you can check one last time to make sure that you fulfilled all the requirements. If you forgot something then you can resend your assignment with a note to mark only the latest submission (but try not to resubmit your assignment too many times please).
To help make sure that you haven't missed anything here is a checklist of items to be used in marking.
   

 

Academic Misconduct and collaboration

Assignments must reflect individual work.  Each student must demonstrate that he or she can complete the assignment on their own so you cannot copy the work of other students nor can students work in groups.  Any suspected cases of cheating must be forwarded by me onto the Department Head, which may be passed on further to the Office of the Dean of Science and the Department of Student Services and result in penalties such as failing the course or even expulsion from the university.

A few questions and answers to help clarify things:

Q: What exactly constitutes cheating in this course? 
A: It is probably similar to what you have seen in other courses.  Cheating has occurred if you hand in someone else's work as if it were your own (without crediting the other person).   Furthermore if a student knowingly provides a copy of his or her assignment to another student  then both students are guilty of academic misconduct (the first student helped the second student to cheat).


Q: What happens if you include someone else's code in your assignment submission and you do credit the other person clearly and properly e.g., You use the code from the text book and you include the following citation:  The function listed below displays the list of email contacts for the user and it was taken from the book Pascal Programming & Problem Solving, 4th Edition, Leestma/Nyhoff . 
A: This will not constitute cheating but since someone else did the work for that section of your assignment you won't get credit for it e.g., if you were supposed to get a marks for writing the code to display a list but instead you copied someone else's code (and credited this person) rather than writing it yourself then you wouldn't get credit for the work.
 

Q: What is the difference between getting help from someone vs. cheating?
A: If you describe the process to someone using plain English then you should be okay because then the person still must figure out how to implement your generic ideas in a programming language (both of you are handing in separate submissions). This is because the person must understand the problem sufficiently to solve it on their own. If you simply give your code to a friend then this is not okay, even if your friend says that he or she will only use your solution as a 'guide' in order figure out the answer and 'promises' that he or she won't just copy it into their own program. This is because the person probably will not understand or the solution so he or she has learned nothing.

Okay Not okay
To write a loop that counts from one to ten the following steps must be completed. First a loop control (a variable that stores the values from one to ten) must be initialized to the starting value (in this case it's the number one). Next a check must be performed to ensure that the control includes but does not exceed the last value in the sequence (in this case it's the number ten). Within the body of the loop the current value of the loop control should be displayed onscreen so that the program actually 'counts' out the values onscreen. Finally the loop control must be updated with each pass through the body of the loop.
  i := 1;
  while (i <= 10) do
  begin 
       writeln ('i=', i);
       i := i + 1;
 end;

 

Q: The code that you gave us in lecture or tutorial would be really handy for our assignments, are we allowed to use it and get credit for the work? (You should pay especially close attention to this last point with the assignments in the later part of the term).
A: Yes, unless you are told otherwise you can make use of my sample code (I usually give the TA's the examples to cover in tutorial). Just make sure that you clearly indicate where you got it from in your program documentation as well as indicating which parts of the program come from class. Don't just include it in your code without citing the source (in this case it's me) because you will be claiming that this work is yours when it isn't so you will be guilty of academic misconduct.
 

Q: How do we credit some else's code?
A: Typically each logical block (function, procedure, loop, branch) that you did not write yourself must clearly indicate the source e.g., "The following procedure called "displayMaze" for displaying the contents of the array came from lecture notes by James Tam.

This list of questions only includes things that I thought up as I writing the assignment specifications, if you ever unsure if a particular situation constitutes cheating or not then it is up to you to ask me.