CS 11 Fall 2004 -- Project 1


The Rochambeau Match

Have you ever tried to solve a dispute via Rochambeau (a.k.a. rock-paper-scissors)? Have you lost the game, only to exclaim, "No, wait, best 2 out of 3!". In this project, we're going to take Romcambeau to new heights (or depths, depending on your perspective) by imposing an elaborate scoring scheme.

You may wonder, "What kind of scoring scheme?" It's one with which you may be familiar: tennis scoring. Each rochambeau contest will merely amount to scoring a single point. A certain number of points will win a game, enough games will win a set, and enough sets will win the match.

Your assignment is a write a program that will play a complete, tennis-scored, Rochambeau match against you. The program must make its own rock-paper-scissors selections as it plays against you, and the program must keep score (correctly!).

You should implement the parts of this problem in a specific order given below, in the Your assignment section. So, be sure to read the entire assignment before beginning work.


The scoring system

For consistency, we outline the complete scoring system, including what must occur for a player to win a point, game, set, and match:


Your assignment

Note that a full Rochambeau match, as described above, has many layers and involves a large number of rules. By way of discouraging you from trying to write a program to play a complete match on your first try, I provide some information on the grading of this assignment.

If you implement a program that plays a single Rochambeau point -- that is, repeated rounds until one player wins a round -- then the highest grade you can receive is a B. Since this portion of the program is critical, I strongly recommend that you write, compile, and debug it first.

If you implement a program that plays a single Rochambeau game -- that is, Rochambeau points scored like a tennis game -- then the highest grade you can receive is an A-. Write this part of the program only after you have successfully implemented a point-playing program.

If you successfully implement a Rochambeau set, then your grade will be at most an A, and if you implement a match, your grade will be at most an A+. Thus, you should implement this program from the inside out. By submitting a program that successfully implements some of the inner layers of the game, you will receive substantial credit even though the full assignment has not been completed. Note that you can also not only write each layer, but you can compile and debug it before moving on to the next one, thus ensuring that you've written code that will earn a large portion of the possible credit.

One final requirement: Your program must provide a good interface to the user, presenting useful prompts, robustly responding to invalid inputs, and informing the user of the progress of the game. Here is a sample transcript of a game:

(romulus)[274]~/project-1% java RochambeauMatch
You: 0 sets
Me:  0 sets
You: 0 games
Me:  0 games
You: Love
Me:  Love
(r)ock, (p)aper, or (s)cissors? q
q is not a valid choice, try again
(r)ock, (p)aper, or (s)cissors? p
I chose rock
You chose paper
Paper covers rock!  You win.
You: 15
Me:  Love
(r)ock, (p)aper, or (s)cissors? r
I chose scissors
You chose rock
Rock smashes scissors!  You win.
You: 30
Me:  Love
(r)ock, (p)aper, or (s)cissors? r
I chose rock
You chose rock
It's a tie -- redo!
(r)ock, (p)aper, or (s)cissors? r
I chose paper
You chose rock
Paper covers rock!  I win.
You: 30
Me:  15
(r)ock, (p)aper, or (s)cissors? r
I chose paper
You chose rock
Paper covers rock!  I win.
You: 30
Me:  30
(r)ock, (p)aper, or (s)cissors? r
I chose paper
You chose rock
Paper covers rock!  I win.
You: 30
Me:  40
(r)ock, (p)aper, or (s)cissors? r
I chose paper
You chose rock
Paper covers rock!  I win.
Game: me
You: 0 games
Me:  1 games
You: Love
Me:  Love
(r)ock, (p)aper, or (s)cissors? r
I chose scissors
You chose rock
Rock smashes scissors!  You win.
You: 15
Me:  Love
(r)ock, (p)aper, or (s)cissors? r
I chose rock
You chose rock
It's a tie -- redo!
(r)ock, (p)aper, or (s)cissors? r
I chose rock
You chose rock
It's a tie -- redo!
(r)ock, (p)aper, or (s)cissors? r
I chose paper
You chose rock
Paper covers rock!  I win.
You: 15
Me:  15
(r)ock, (p)aper, or (s)cissors? r
I chose scissors
You chose rock
Rock smashes scissors!  You win.
You: 30
Me:  15
(r)ock, (p)aper, or (s)cissors? r
I chose rock
You chose rock
It's a tie -- redo!
(r)ock, (p)aper, or (s)cissors? r
I chose rock
You chose rock
It's a tie -- redo!
(r)ock, (p)aper, or (s)cissors? r
I chose rock
You chose rock
It's a tie -- redo!
(r)ock, (p)aper, or (s)cissors? r
I chose paper
You chose rock
Paper covers rock!  I win.
You: 30
Me:  30
(r)ock, (p)aper, or (s)cissors? r
I chose rock
You chose rock
It's a tie -- redo!
(r)ock, (p)aper, or (s)cissors? r
I chose scissors
You chose rock
Rock smashes scissors!  You win.
You: 40
Me:  30
(r)ock, (p)aper, or (s)cissors? r
I chose rock
You chose rock
It's a tie -- redo!
(r)ock, (p)aper, or (s)cissors? r
I chose rock
You chose rock
It's a tie -- redo!
(r)ock, (p)aper, or (s)cissors? r
I chose paper
You chose rock
Paper covers rock!  I win.
Deuce
(r)ock, (p)aper, or (s)cissors? r
I chose scissors
You chose rock
Rock smashes scissors!  You win.
Your advantage
(r)ock, (p)aper, or (s)cissors? r
I chose rock
You chose rock
It's a tie -- redo!
(r)ock, (p)aper, or (s)cissors? r
I chose paper
You chose rock
Paper covers rock!  I win.
Deuce
(r)ock, (p)aper, or (s)cissors? r
I chose rock
You chose rock
It's a tie -- redo!
(r)ock, (p)aper, or (s)cissors? r
I chose paper
You chose rock
Paper covers rock!  I win.
My advantage
(r)ock, (p)aper, or (s)cissors? r
I chose rock
You chose rock
It's a tie -- redo!
(r)ock, (p)aper, or (s)cissors? r
I chose paper
You chose rock
Paper covers rock!  I win.
Game: me
You: 0 games
Me:  2 games
You: Love
Me:  Love
  

In fact, it is likely that you could improve on the interface shown above, so take that only as an example of something that is acceptable.


Selecting random values

For the computer to select rock, paper, or scissors, it must, of course, make its own, random selection. There is a method that you can call to obtain a random value, and you would use it like so:

double randomValue = Math.random()

That is, Math.random() is a method that returns a double whose value is between 0.0 and 0.99999... You can use this randomly provided value to drive the computer's random selection at each turn.


Submitting your work

When your work is complete, you should submit it using the cs11-submit command, like so:

cs11-submit project-1 RochambeauMatch.java

This lab has a revised deadline of Friday, October 15th at 11:59 pm!

Scott F. Kaplan
Last modified: Thu Oct 14 09:34:18 EDT 2004