Due: At midnight, May 7, 2008. Work turned in after that time will not be accepted for grading.
The possible poker hands and their probabilities are described below: -------------------------------------------------------------------- a. No pairs [5 different face values, not in sequence, not all cards in the same suit] Prob(5 different face values, not in sequence, not in same suit) = 0.501177 ---------------------------------------------------------------------- b. One pair [two of one face value, and 3 cards of different face values, no matching the pair] Prob(1 pair) = 0.422569 ---------------------------------------------------------------------- c. Two pairs [one pair of each two different face values and a card of a third face value] Prob(2 pairs) = .0475390 ---------------------------------------------------------------------- d. Three of a Kind [exactly 3 cards of one face value and 2 different cards] Prob(Three of a kind) = .02112845 ---------------------------------------------------------------------- e. Straight [5 cards in sequence, but not all of same suit. Ace high or low] Prob(straight) = .0039246 ---------------------------------------------------------------------- f. Flush [5 cards of the same suit but not in sequence, not including the straight flush and royal flush below] Prob(Flush) = .0019654 ---------------------------------------------------------------------- g. Full house [3 cards of one face value and 2 cards of another face value] Prob(Full house) = .00144058 ---------------------------------------------------------------------- h. four of a kind [four cards of one face value and one other card] Prob(Four of a kind) = .00024009 ---------------------------------------------------------------------- i. straight flush [five cards in sequence and of the same suit, but not ace king queen jack ten] Prob(Straight flush) = .00001385 ---------------------------------------------------------------------- j. Royal Flush [ace, king, queen, jack, ten in the same suit] Prob(Royal flush) = .000001539 ---------------------------------------------------------------------If you want to know how these probilities are computed, see:
You should start with the Card.java, Deck.java, Hand.java, PokerHand.java classes (see weeks 10-11 assignments). You should add new methods to PokerHand like isPair(), isTwoPairs(), isThreeOfKind(), etc. to test for possible poker hands. Add as many of these methods as you can. If you cannot add all of them, at least add isPair() and several others. You may need additional methods depending on your design.
You should decide on the payoffs in light the probabilities given above. For example, if machine pays 1-to-1 for a pair, machine would be ahead (probability for a pair is less then 0.5).
To start out, construct a deck and shuffle it. Deal a hand consisting of the first five cards of the deck. Replace as many cards as requested by the player; replacement cards should come in sequence from the 6th-10th cards of the deck. After one play, you can shuffle the deck again and start over.
You can decide how the replacement of the cards and the user interface in general should operate. To give you an idea, here is a possible run.
Let's play poker. Your current hand is: 1 : 2 of Diamonds 2 : 9 of Diamonds 3 : 4 of Hearts 4 : 10 of Clubs 5 : 4 of Diamonds Enter the numbers of the cards you wish to discard. Entering the number of a discarded card retrieves it. Enter 0 to stop discarding. 1 1 : 2 of Diamonds DISCARDED 2 : 9 of Diamonds 3 : 4 of Hearts 4 : 10 of Clubs 5 : 4 of Diamonds Select another card or 0 to complete the discard. 2 1 : 2 of Diamonds DISCARDED 2 : 9 of Diamonds DISCARDED 3 : 4 of Hearts 4 : 10 of Clubs 5 : 4 of Diamonds Select another card or 0 to complete the discard. 4 1 : 2 of Diamonds DISCARDED 2 : 9 of Diamonds DISCARDED 3 : 4 of Hearts 4 : 10 of Clubs DISCARDED 5 : 4 of Diamonds Select another card or 0 to complete the discard. 0 Your final hand is: 1 : 6 of Spades 2 : King of Hearts 3 : 4 of Hearts 4 : 10 of Diamonds 5 : 4 of Diamonds You have a pair. You now have $21. Do you want to play again [y/n]? y ..... etc...Good Luck.