Introduction to problem solving with applications by James Tam Return to the course web page

A3: Programming and problem solving

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. In the actual game players must simultaneously select their gesture. The gesture selected determines the outcome of the game. (You won't be responsible for writing a game that works in real-time however, with the program that you write, each player will make their selection one-at-a-time).

  Player 2: Rock Player 2: Paper Player 2: Scissors
Player 1: Rock Tie Player 2 wins Player 1 wins
Player 1: Paper Player 1 wins Tie Player 2 wins
Player 1: Scissors Player 2 wins Player 1 wins Tie

Much like the real world game if a player tries to cheat (e.g., selects an invalid gesture) then that player has committed a foul and for the game that you will write the fouling player is given a "forced rock" for their gesture.  You can go the following url to try a web based version of the game if you want to get a feel for how the game works: http://www.playrps.com/.

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

Version 1: Two human players

 
  1. A game world is created that contains objects (avatars) representing player 1 and player 2. Player One's avatar resides on the left hand side of the screen and Player Two's avatar resides on the right. Besides differences in position the two avatars should be physically distinct.
 
  1. Each player is prompted to enter their selection (1 = rock, 2 = paper, 3 = scissors).
 
  1. The game can detect invalid gestures (i.e., values outside of the allowable range) and award that player a forced rock gesture.
 
  1. The game communicates (using text) which gesture was selected by which player.
 
  1. Instead of using text the game communicates in a multi-media form (graphical or audio) which gesture was selected by which player.
 
  1. The outcome of the game can be determined (win, lose or tie and in the first two cases the specific winner and loser must be determined and displayed in the form of a text message). (JT's note: this feature will be the most time and labor intensive so it will be worth the most marks).
 
  1. Instead of using text the game communicates in a multi-media form (graphic or audio) the outcome of the game.

Version 2: Has all the features of version 1 but invalid gestures are handled differently.

 
  1. Instead of awarding a force rock when a player selects an invalid gesture the program will continue prompting that player until a valid gesture has been selected.

Version 3: Has completed the feature of version 2 but player 2 is now a computer-controlled opponent.

 
  1. The game will now randomly select the gesture for the second player rather than prompting a player for it.

When you submit your assignment make sure that you include each version of the program that you have completed (a student needs to submit all 3 versions in order to get full marks). Also you need to include a flowchart that completely and accurately reflects the highest version of the program that you completed (e.g., if you completed version 2 then you would submit a flowchart that showed how that version was implemented). To help you visualize how the features are implemented there will be a link to various media files that are sample runs of my solution. [Link]

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 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 work in your assignment submission and you do credit the other person clearly and properly e.g., You use the code from a 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 program 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 (pseudo code) Not okay (instructions from an actual programming language).
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):
       print 'i=',
       i = i + 1

 

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?
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 (group of statements such as a loop, branch) that you did not write yourself must clearly indicate the source e.g., "The following method called "displayMaze" for displaying the contents of the list 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.

Be sure that your assignment fulfills the requirements of the [general submission requirements].

[Marking of this assignment]