0% found this document useful (0 votes)
144 views4 pages

Cis 1500: Assignment 2: Weighing: 15% Due: Friday, October 17, 2014, 11:55 PM

The document describes an assignment to write a program to play Rock, Paper, Scissors. The program must prompt the user for the number of games and their choice for each game. It should generate the computer's random choice, determine the winner, and display the final scores. As an extra, the program can be extended to the Rock, Paper, Scissors, Lizard, Spock version. The document provides example output and details requirements for submission.

Uploaded by

Kevin Chai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
144 views4 pages

Cis 1500: Assignment 2: Weighing: 15% Due: Friday, October 17, 2014, 11:55 PM

The document describes an assignment to write a program to play Rock, Paper, Scissors. The program must prompt the user for the number of games and their choice for each game. It should generate the computer's random choice, determine the winner, and display the final scores. As an extra, the program can be extended to the Rock, Paper, Scissors, Lizard, Spock version. The document provides example output and details requirements for submission.

Uploaded by

Kevin Chai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

CIS*1500: ASSIGNMENT 2

Weighing: 15%
Due: Friday, October 17, 2014, 11:55 PM
Rock, Paper, Scissors
Raj Koothrappali: I'll tell you what. How about we go rock-paper-scissors?
Sheldon Cooper: Ooh, I don't think so. Anecdotal evidence suggests that in the game
of rock-paper-scissors, players familiar with each other will tie 75 to 80% of the time
due to the limited number of outcomes. I suggest rock-paper-scissors-lizard-Spock.
Raj Koothrappali: What?
Sheldon Cooper: It's very simple. Scissors cuts paper. Paper covers rock. Rock crushes
lizard. Lizard poisons Spock. Spock smashes scissors. Scissors decapitates lizard. Lizard
eats paper. Paper disproves Spock. Spock vaporizes rock. And as it always has, rock
crushes scissors.
Rock-Paper-Scissors (RPS) is a hand game which involves making a motion three times
with your fists, and then either show a flat hand (paper), clenched fist (rock), or two
fingers extended and separated (scissors). Depending on the results, the game is a tie
(both show the same), or one person wins. The objective is to select a gesture which
defeats that of the opponent. Gestures are resolved as follows:
Rock blunts or breaks scissors: rock defeats scissors.
Scissors cut paper: scissors defeats paper.
Paper covers, sands or captures rock: paper defeats rock.
If both players choose the same gesture, the game is tied.
Task
Write a program to play a game of Rock, Paper, Scissors.
Make sure your program is readable, including appropriate comments, and
incorporates aspects of usability in the text prompts to the user.
Your program should perform the following:
1. Prompt the player for the number of games they wish to play.
2. Use a loop to allow the program to run a number of games requested by the player.
3. Within each game, prompt the player for their choice of rock, paper or scissors. Use
numeric values 1, 2, and 3 to allow the user to choose a gesture.
4. Use the code below (integrating it into your program) to generate the computers
gesture: 1, 2, or 3. Note that you must generate a new random value for x each for
each game.

In the header section: In the main part of the program:
#include <stdlib.h>
#include <time.h>
int x;
srand(time(NULL));
x = (rand() % 3) + 1;
How does this code work? Basically the function rand() generates a random number
and then performs mod 3, i.e. it returns the remainder when the random number is
divided by 3 - so the remainder will be 0, 1, or 2. A value of 1 is added to this number
to give 1, 2, or 3.
Decide who wins, the player or the computer, and print out an appropriate message -
indicate who the winner is, or if the game becomes tied.
Your program should count the number of wins for the player, and the computer, and
the number of ties, and display these statistics at the end.
Note: Your program should use decision statements, and loops.
Test Program Execution
An example of a program with these features is shown running below (user inputs are
bolded):
This program allows you to play Rock, Paper, Scissors
How many games do you want? 2
Game number 1
3=Rock, 2=Scissors, 1=Paper
What's your choice? 1
My choice is paper
Tie game - no winner
Game number 2
3=Rock, 2=Scissors, 1=Paper
What's your choice? 3
My choice is scissors
You win!!
Here is the final score
I have won 0 game(s),
you have won 1 game(s)
and 1 games ended in a tie
Thanks for playing!
Extras
By completely the above task correctly, you have the potential to earn up to 90% of the
grade for this assignment. By going beyond the material given and completely the
extra section, you have the potential of earning another 10%.
Extend the program to play rock-paper-scissors-lizard-spock.
Program expectations
All files are inside your A2 folder.
The assignment is called a2.c
The .c file has the required header (see the policies document).
Source code has the proper style (e.g. indentation).
A plain text file called README is in the root folder. It contains
information about running and using your program as well as any known limitations
of the program. (See policies document)
You may not use any global variables, or goto statements in this program!
Your program should use decision statements, and loops.
Deliverables:
Things you must hand in (via git):
1. Your A2 file with all required .c files and a README file
1.1.Remember to git add every file
1.2.Use git commit and git push frequently as you work on the assignment (see the
GIT FAQ for help)
1.3.Submitting your work is as simple as doing one last git commit and git push.
We use the most recent version of your repository as your submission.
2. No submission is required on Bucky.
Musts: How to get more than ZERO
Submit your assignment before the due date!
Your code must compile on a Raspberry Pi that is running the CIS*1500 customized
operating system.
Your code must compile, with no errors or warnings, with gcc using the flags
-std=c99 -Wall -pedantic.
Your program must run without crashing or causing a segmentation fault.
Your program must play the game, and show the outcome.
Marks breakdown
Refer to the rubric for this assignment.

You might also like