#### Archived

This topic is now archived and is closed to further replies.

# Determining Poker Hands

This topic is 5619 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I''m making a little dos poker game. I''m running into a problem with the function that determines if the hand is a winning hand or not, and what kind of win it is. My card class has data members that hold which suit and value the card is, so how do I make a function that will determine which kind of hand the player has. (IE: Royal Flush, Straight Flush, Four of a Kind, Full House, Flush, Straight, Three of a Kind, Two Pair, Pair) I can check for the suits being equal to eachother easy enough, but when I try to find a way to determine how many seperate pairs there are, or how many of the same card are in each hand, I get some problems. Any help for this is appreciated =)

##### Share on other sites
A particular hand consists of one or more combinations. Search from high to low, using a different function to check for each combination. The first function that returns true, along with the "rank" of the hand (the number of the highest card involved in the combination). If it finds the combo, use it. If it doesn''t, go to the next checking function. Nota bene: Royal flushes do not require a checker; they''re simply straight flushes to the ace.

How appropriate. You fight like a cow.

##### Share on other sites
Yes, I understand the order and such to call those functions, but the problem is coming up with the algorithm that will detect pairs or the three/four of a kind.

##### Share on other sites
Sort the cards by rank, high to low. Iterate through them, keeping in mind what the last card you saw was. if the current card matches, that''s a pair.

How appropriate. You fight like a cow.

1. 1
Rutin
37
2. 2
3. 3
4. 4
5. 5

• 11
• 10
• 13
• 101
• 11
• ### Forum Statistics

• Total Topics
632975
• Total Posts
3009666
• ### Who's Online (See full list)

There are no registered users currently online

×