CS 11 Fall 2005 -- 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 raise Romcambeau to a new level (or lower it, 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, the project will be split into two portions, each with its own due date:

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 excerpted transcript of a full match:

(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

Scott F. Kaplan
Last modified: Thu Sep 22 11:29:05 EDT 2005