There are many, many variations of the game called Poker. The game we will be simulating (Texas Hold 'Em) is just one of the variations. All variations of poker rely on the same set of "hand rankings" to determine who wins.
A "poker hand" consists of exactly 5 cards. Even though some games (like Texas Hold 'Em) involve players controlling more than 5 cards, the poker hands themselves are always exactly 5 cards. The names of the different hand rankings appear below. Click on one to see its definition.
The rankings below are listed from lowest to highest:
If your hand is so bad that it doesn't qualify for any of the rankings listed above, then there is an even lower ranking:
During a poker game, if the cards you are holding satisfy the description of more than one different ranking, the hand is evaluated as the best rank you can find. For example, consider the hand below:
Even though I see a pair of tens, I wouldn't call this hand "a pair". Even though I see a set of three four's, I wouldn't call this hand "Three of a Kind". I would call this hand a "Full House", because that is the highest rank that it qualifies for. However, while implementing the methods in the "PokerHandEvaluator" class, we will violate this convention. (For more information, read the section labeled "important" in the description of the PokerHandEvaluator class.)
In a poker game where each player controls more than 5 cards, the "hand ranking" for a player is found by considering all 5-card subsets of the cards he controls -- you evaluate his hand by determining which 5-card subset has the highest rank.
Example 1:
Suppose I am in control of the following seven cards:
What would my "hand ranking" be? If you said "Three of a Kind", you didn't consider the 5-card subset below:
That's a straight, isn't it? The "hand ranking" of the player with the seven cards pictured above would be "straight", because the highest ranking subset of 5 cards is a straight.
Example 2:
What is the hand ranking of the player who controls the seven cards below:
Did you see the straight that time? That's great, but I hope you also saw the even better 5-card subset below:
That's a flush! The player with the seven cards shown above has a "flush".