CS 206 -- Assignment 2
3 Card Poker
This assignment will build on the deck shuffler to create a program
that simulates some of the aspects of playing 3 card poker. For
this assignment, you will need to create at least the following classes
with at least the following public methods:
- Card
- String getSuit() -- returns "spade", ...
- int getValue() -- returns 1..14
- int getSuitValue(), returns 1for diamond, 2 for clubs, 3 for
hearts, 4 for spades
- Deck
- Card nextCard() -- returns the next card in the deck
- void reset() -- puts all the cards back on the deck
- void shuffle() -- permutes the order of the cards in the deck
- Dealer
- void addPlayer(Player) -- adds a player to the game (up to some
preset max number of players)
- void Deal() -- reset the deck, shuffle, and deal cards to all
players
- Player
- void getCard() -- get a card from the dealer
- void dropCards() -- forget about the cards in your hand, in
preparation for the next game
- int evaluateHand() -- return the highest score from among the
three cards being held. As a scoring function, you could use:
- for 1 of a kind: 5*card.getValue()+card.getSuitValue()
- for 2 of a kind: 100+5*card.getValue()+card.getSuitValue()
- for 3 of a kind: 200+5*card.getValue()+card.getSuitValue()
Once you have all of this working, set up a system to get the
probability of winning for each 3 card hand. You can do this by
playing a lot of games (e.g., 10000) and recording, for each hand,
whether that hand was winner or loser in that game. Note that the
probability of a hand being a winner is a function both of its score
and the number of players.
Hand in:
- the program as described on the course website
- a graph showing the probability of winning with a given hand for
some specific number of players.
Due:
Feb 15, 2005