In: Computer Science
Deal or No Deal
Assignment
Have you watched the gameshow Deal or No Deal? We are going to
design a smaller version of it.
Parameters
• We’ll have 25 differing dollar amounts from $1 to
$1,000,000. (Let’s use 25, not 26; drop the 1 cent value in the
original game values.) Each dollar amount is randomly placed in one
of 25 briefcases, and none of the game players know the
locations.
• We’ll only implement 1 Round with 4 states:
1. Player makes guess of Prize briefcase
2. Player opens N other briefcases
3. Banker makes an offer to buy back Prize
briefcase
4. Player responds – and wins or looses
Board Presentation
Show the 25 briefcases as a 5x5 grid. (You can hardcode the 25 and
5x5 – these parameters don’t change.) Each cell of the grid
represents a briefcase. The contents of the cell can display 1 of 2
things: either a closed briefcase or an opened briefcase. If
closed, then just show the briefcase number; if opened then display
the dollar amount inside.
Also show the remaining Cash Values still in play. I used a 2-row
table where the values opened have a grey background. The other
values are in the closed briefcases and one is the Prize
Briefcase.
Rules of Play
There are 2 participants: The Player and The Banker. The Player
wants to make as much money as possible, and The Banker wants to
keep as much money as possible.
We’ll only do 1 Round. So, we’ll have 4 steps or 4 States to our
game.
1. Initialize: This is the setup for the board and
initializing the State Variables (hiddens).
2. Prize Briefcase selection: The player first picks
their prize briefcase. In the picture above, the player selected
Case #17. That selection must be stored in a State Variable for the
entire game – so the game can “remember” it. (The dollar amount
contents of the Prize Briefcase is not displayed, of course, so
keep the case “closed.”)
3. Open N other briefcases: Now the player picks N
other briefcases to open. For our miniature game with only one
round, N=6. After the user selects 6 briefcases, they are opened
and the dollar contents displayed to everyone.
4. Accept or reject The Offer from the Banker: The game
pauses. The Banker now makes an offer by buy back the Prize
Briefcase from the player –with unknown contents to all. The Banker
doesn’t know contents of the Prize Briefcase but doesn’t want it to
be big. So, the Banker offers a price somewhere in the middle of
the range of the remaining dollar amounts.
The Player can accept or reject the offer from The Banker. In our
game, either way, this is the end of the game. In the real game, if
the offer is not selected, then the next round continues with N=N-1
briefcases opened until there is only 2 left.
State Variables
I had 3 State Variables.
• $state – this is an integer. It goes from 0 to
3.
• $caseCash – this is a 1-D array of length 25. Each
cell is a briefcase. The value of the array is the cash in the
briefcase.
• $caseState – this is also a 1-D array of length 25.
Each cell is a briefcase. The value is a string representing the
status of the briefcase. There are 3 options: closed, opened, or
the 1 Prize Briefcase. In my game:
o A dot ‘.’means the briefcase is closed. o An ‘o’
means that the briefcase is opened.
o The string ‘prize’ means that The Player has selected
that briefcase for their prize at the end.
The Banker
The job of The Banker is to “save” money. He knows The Player will
get the cash in the Prize Briefcase. The Banker’s job is to “buy”
the Briefcase back from The Player, hopefully for less money than
is in the Prize Briefcase. Neither party know the contents of the
Prize Briefcase, so both parties are gambling.
A very simple algorithm for The Banker is simply to take the
average() of all the unopened, remaining briefcases. The Average
will be right in the middle. That makes it a 50% chance that The
Banker does better and a 50% chance that The Player does better.
You are free to make The Offer using any function you want. Have
fun.