All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.lotspiech.poker.Hand

java.lang.Object
   |
   +----com.lotspiech.poker.BunchOfCards
           |
           +----com.lotspiech.poker.Hand

public class Hand
extends BunchOfCards
This class represents a hand of poker. It contains the logic for calculating the expected counts from a given hand, with a given remaining deck. It also can display a hand of cards. However, Hand does not have a sense of the order of the cards. For that, the HandWithDiscard subclass is used.

Copyright 2001, 2002 by Jeffrey B. Lotspiech. This program is open source; it is licensed under the Common Public License Version 0.5.

Author:
Jeffrey B. Lotspiech
See Also:
Deck, BunchOfCards, Card, HandWithDiscard

Variable Index

 o chances
 o COPYRIGHT
 o draw
 o MAX_HAND
 o otherPairs
 o singleton
 o wildCount
 o wildDraw

Constructor Index

 o Hand()
 o Hand(Card[])
Any number of cards may be a "hand".

Method Index

 o addArray(int[], int[])
This method was created in VisualAge.
 o addChances()
 o calculateChances(Deck)
This routine calculates all possible outcomes from a given hand, and a given (remaining) deck.
 o countDraw(Deck)
 o flush(Deck)
 o fourOfAKind(Deck)
 o fullHouse(Deck)
 o getChances(String, int, int)
You must execute "calculateChances" before calling this.
 o getCounts(String)
This method was created in VisualAge.
 o main(String[])
Testing program; arguments are the cards in the hand, e.g.
 o multiplyArray(int[], int)
This method was created in VisualAge.
 o noPair(Deck)
 o onePair(Deck)
 o showTotals()
 o straight(Deck)
 o straightByHighCard(Deck)
 o straightFlush(Deck)
 o straightFlushByHighCard(Deck)
 o subtractArray(int[], int[])
This method was created in VisualAge.
 o threeOfAKind(Deck)
 o twoPair(Deck)
 o wildFiveOfAKind(Deck)
 o wildFlush(Deck, int)
 o wildFourDeuces(Deck)
This calculates four wild ranked cards (no jokers); the word "deuces" here a bit of a misnomer if deuces aren't the wild rank.
 o wildFourOfAKind(Deck)
 o wildFullHouse(Deck)
 o wildOnePair(Deck)
This method was created by a SmartGuide.
 o wildStraight(Deck, int)
 o wildStraightByHighCard(Deck, int)
 o wildStraightFlush(Deck, int)
 o wildStraightFlushByHighCard(Deck, int)
In normal straight flush calculation, we are concerned about how high an SF we can make.
 o wildThreeOfAKind(Deck)
This method was created by a SmartGuide.

Variables

 o COPYRIGHT
 private static final String COPYRIGHT
 o MAX_HAND
 private static final int MAX_HAND
 o draw
 private int draw
 o chances
 private Dictionary chances
 o wildCount
 private int wildCount[]
 o wildDraw
 private int wildDraw[]
 o singleton
 private SingletonCalculator singleton
 o otherPairs
 protected int otherPairs[]

Constructors

 o Hand
 public Hand()
 o Hand
 public Hand(Card cards[])
Any number of cards may be a "hand".

Methods

 o addArray
 private static int[] addArray(int a[],
                               int b[])
This method was created in VisualAge.

Parameters:
a - int[]
b - int[]
Returns:
int[]
 o addChances
 private int addChances() throws Exception
 o calculateChances
 public void calculateChances(Deck deck) throws Exception
This routine calculates all possible outcomes from a given hand, and a given (remaining) deck. In general, the order in which the hands are calculated are important. More common hands need the results from rarer hands. For example, three of a kind needs to know the full house chances, so it can remove them.

 o countDraw
 public int countDraw(Deck deck)
 o flush
 private int[] flush(Deck deck)
 o fourOfAKind
 private int[] fourOfAKind(Deck deck)
 o fullHouse
 private int[] fullHouse(Deck deck)
 o getChances
 public int getChances(String name,
                       int begin,
                       int len)
You must execute "calculateChances" before calling this.

Returns:
The number of chances of a given type of hand.
 o getCounts
 private int[] getCounts(String name)
This method was created in VisualAge.

Parameters:
name - java.lang.String
Returns:
int[]
 o main
 public static void main(String args[]) throws Exception
Testing program; arguments are the cards in the hand, e.g. "AS", "4D", etc.

Parameters:
args - "[ cards1 ] [ less [ cards2 ]] [ -deuces ] [ -joker ]"
 o multiplyArray
 private static int[] multiplyArray(int a[],
                                    int m)
This method was created in VisualAge.

Parameters:
a - int[]
m - int
Returns:
int[]
 o noPair
 private int[] noPair(Deck deck) throws Exception
 o onePair
 private int[] onePair(Deck deck)
 o showTotals
 public String showTotals()
 o straight
 private int[] straight(Deck deck)
 o straightByHighCard
 private int[] straightByHighCard(Deck deck)
 o straightFlush
 private int[] straightFlush(Deck deck)
 o straightFlushByHighCard
 private int[] straightFlushByHighCard(Deck deck)
 o subtractArray
 private static int[] subtractArray(int a[],
                                    int b[])
This method was created in VisualAge.

Parameters:
a - int[]
b - int[]
 o threeOfAKind
 private int[] threeOfAKind(Deck deck)
 o twoPair
 private int[] twoPair(Deck deck)
 o wildFiveOfAKind
 private int[] wildFiveOfAKind(Deck deck)
 o wildFlush
 private int[] wildFlush(Deck deck,
                         int wild)
 o wildFourDeuces
 private int[] wildFourDeuces(Deck deck)
This calculates four wild ranked cards (no jokers); the word "deuces" here a bit of a misnomer if deuces aren't the wild rank.

 o wildFourOfAKind
 private int[] wildFourOfAKind(Deck deck)
 o wildFullHouse
 private int[] wildFullHouse(Deck deck)
 o wildOnePair
 private int[] wildOnePair(Deck deck)
This method was created by a SmartGuide.

Parameters:
deck - com.lotspiech.poker.Deck
Returns:
int[]
 o wildStraight
 private int[] wildStraight(Deck deck,
                            int wild)
 o wildStraightByHighCard
 private int[] wildStraightByHighCard(Deck deck,
                                      int wild)
 o wildStraightFlush
 private int[] wildStraightFlush(Deck deck,
                                 int wild)
 o wildStraightFlushByHighCard
 private int[] wildStraightFlushByHighCard(Deck deck,
                                           int wild)
In normal straight flush calculation, we are concerned about how high an SF we can make. However, for the purpose of taking SFs out of other hands (flushes and fours of a kind), we are interested in we are interested in the highest actual card in the hand.

Parameters:
deck - The deck containing remaining cards.
wild - The number of wild cards.
 o wildThreeOfAKind
 private int[] wildThreeOfAKind(Deck deck)
This method was created by a SmartGuide.

Parameters:
deck - com.lotspiech.poker.Deck
Returns:
int[]

All Packages  Class Hierarchy  This Package  Previous  Next  Index