By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,184 Members | 1,500 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,184 IT Pros & Developers. It's quick & easy.

Help with Poker Hand Evaluation.

P: n/a
I am looking for some help!

I am currently developing a new game for an online community. The
game is called Pokino which ishalf bingo and half poker. Wierd eh?!

Anyway...

The final part of the program needs to evaluate two 5 card poker hands
and determine which one out of the two hands wins. I thought rather
than create a new class of my own I would see if there was anything
already available. I have searched high and low but can't find
anything!!

I am using Cards.dll so each card is represented by an integer value
ranging from 0-51.

If anybody knows of any resources that may help me or can come up with
a quick and easy way to do this it would be much appreciated.

Thanks in advance,

Tom Miller.
IT Development Analyst.
Jun 27 '08 #1
Share this Question
Share on Google+
9 Replies


P: n/a
Did you develop Cards.dll? I know when I was designing my own
Cards.dll I created the cards in two parts: Card Value and Card
Suit. When I had to do a War application for class I could simply
take the card value against the other card value and determine the
winner. For that particular assignment our professor also had one
suit beating another so I could just take the value of the suit (Spade
= 1, Heart = 2, Club = 3, Diamond = 4) and pit them against each
other.

All that being said I would define a Card object and simply shuffle
those around in an array to build your deck.

Jun 27 '08 #2

P: n/a
On 16 Apr, 14:38, "cfps.Christian" <ge0193...@otc.eduwrote:
Did you develop Cards.dll? *I know when I was designing my own
Cards.dll I created the cards in two parts: *Card Value and Card
Suit. *When I had to do a War application for class I could simply
take the card value against the other card value and determine the
winner. *For that particular assignment our professor also had one
suit beating another so I could just take the value of the suit (Spade
= 1, Heart = 2, Club = 3, Diamond = 4) and pit them against each
other.

All that being said I would define a Card object and simply shuffle
those around in an array to build your deck.
I use cards.dll that is part of Windows. The same dll that is used in
Solitaire and such like....

enum rank
ace
two
three
etc etc...
end enum

enum suit
heart
spades
clubs
diamonds
end enum

The cards are represented as follows:-
card = rank + suit * 4
Jun 27 '08 #3

P: n/a

<te******@gmail.comwrote in message
news:fc**********************************@d45g2000 hsc.googlegroups.com...
>I use cards.dll that is part of Windows. The same dll that is used in
Solitaire and such like....

enum rank
ace
two
three
etc etc...
end enum

enum suit
heart
spades
clubs
diamonds
end enum

The cards are represented as follows:-
card = rank + suit * 4
You would be better served to extend that class and add a method that
returns the split up rank and suit for a poker-style game, since ranking
poker hands is easier that way. Also what if you want to add Jokers to the
deck or handle wild cards? The OP didn't specify, but doesn't sound
possible with cards.dll.
Jun 27 '08 #4

P: n/a
On 16 Apr, 15:14, "Mike C#" <x...@xyz.comwrote:
<teeja...@gmail.comwrote in message

news:fc**********************************@d45g2000 hsc.googlegroups.com...


I use cards.dll that is part of Windows. *The same dll that is used in
Solitaire and such like....
enum rank
ace
two
three
etc etc...
end enum
enum suit
heart
spades
clubs
diamonds
end enum
The cards are represented as follows:-
card = rank + suit * 4

You would be better served to extend that class and add a method that
returns the split up rank and suit for a poker-style game, since ranking
poker hands is easier that way. Also what if you want to add Jokers to the
deck or handle wild cards? *The OP didn't specify, but doesn't sound
possible with cards.dll.- Hide quoted text -

- Show quoted text -
I decided at the outset that I wasn't going to add functionality to
deal with jokers/wild cards.
So create a method that would determine both rank and suit as seperate
objects/variables and use those to determine the poker hand?
Jun 27 '08 #5

P: n/a
"cfps.Christian" <ge*******@otc.eduwrote in news:a8b28587-c5d9-4d09-855b-
88**********@b1g2000hsg.googlegroups.com:
Did you develop Cards.dll?
Card.dll is included with Windows.

--
sp**********@rogers.com (Do not e-mail)
Jun 27 '08 #6

P: n/a
te******@gmail.com wrote:
>
I decided at the outset that I wasn't going to add functionality to
deal with jokers/wild cards.
So create a method that would determine both rank and suit as seperate
objects/variables and use those to determine the poker hand?
It doesn't seem like a difficult thing to write the code for evaluating hands,
if you like programming. :)

I would not worry about speed, and do it in a very methodical way. For instance,
you could have a separate procedure for each kind of hand: IsFlush, IsStraight,
IsFour, IsFullHouse, IsThree, etc. The first thing when comparing two hands is
to see if one is a higher rank of hand than the other.

If they are the same rank, i.e. both are TwoPair, then you need to compare card
values in each hand. I would use a separate procedure for comparing two flushes,
two straights, two TwoPair hands, etc.

If you break it down, you can write very clean tests for each possibility, and
get a very reliable evaluator. No matter how elaborate the code looks, it will
be very fast in use, so don't worry about that.
Jun 27 '08 #7

P: n/a
On 16 Apr, 16:06, "Steve Gerrard" <mynameh...@comcast.netwrote:
teeja...@gmail.com wrote:
I decided at the outset that I wasn't going to add functionality to
deal with jokers/wild cards.
So create a method that would determine both rank and suit as seperate
objects/variables and use those to determine the poker hand?

It doesn't seem like a difficult thing to write the code for evaluating hands,
if you like programming. :)

I would not worry about speed, and do it in a very methodical way. For instance,
you could have a separate procedure for each kind of hand: IsFlush, IsStraight,
IsFour, IsFullHouse, IsThree, etc. The first thing when comparing two hands is
to see if one is a higher rank of hand than the other.

If they are the same rank, i.e. both are TwoPair, then you need to compare card
values in each hand. I would use a separate procedure for comparing two flushes,
two straights, two TwoPair hands, etc.

If you break it down, you can write very clean tests for each possibility, and
get a very reliable evaluator. No matter how elaborate the code looks, it will
be very fast in use, so don't worry about that.
Thanks mate!
Jun 27 '08 #8

P: n/a

"Steve Gerrard" <my********@comcast.netwrote in message
news:Je******************************@comcast.com. ..
te******@gmail.com wrote:
>>
I decided at the outset that I wasn't going to add functionality to
deal with jokers/wild cards.
So create a method that would determine both rank and suit as seperate
objects/variables and use those to determine the poker hand?

It doesn't seem like a difficult thing to write the code for evaluating
hands, if you like programming. :)

I would not worry about speed, and do it in a very methodical way. For
instance, you could have a separate procedure for each kind of hand:
IsFlush, IsStraight, IsFour, IsFullHouse, IsThree, etc. The first thing
when comparing two hands is to see if one is a higher rank of hand than
the other.

If they are the same rank, i.e. both are TwoPair, then you need to compare
card values in each hand. I would use a separate procedure for comparing
two flushes, two straights, two TwoPair hands, etc.

If you break it down, you can write very clean tests for each possibility,
and get a very reliable evaluator. No matter how elaborate the code looks,
it will be very fast in use, so don't worry about that.
I would advise going even a small step further and creating a generic
GetHandScore routine to call all of those hands and assign a rank to each
hand. So a Royal Flush would be worth 10,000 points, Straight Flush = 9,000
points, Four of a Kind = 8,000 points, and so on down the line. You could
also add a GetHighCard routine to determine the high card in your straight,
flush, full house, etc., in case two players both have a straight or full
house. Then determining who won is simply a matter of comparing the scores
returned by GetHandScore, and comparing GetHighCard in case of a
GetHandScore tie. Like Steve pointed out, this isn't that difficult. The
lower level comparisons you need to do would be easier if you split up the
rank and value of each card, which was why I mentioned that before.
Jun 27 '08 #9

P: n/a
Go to PSC, here:
http://www.planet-source-code.com/vb...60163&lngWId=1

for a program I wrote (or highly modified, I forget) which deals and
evaluates poker hands.

Mike

On Wed, 16 Apr 2008 06:31:48 -0700 (PDT), in
microsoft.public.dotnet.languages.vb "te******@gmail.com"
<te******@gmail.comwrote:
>I am looking for some help!

I am currently developing a new game for an online community. The
game is called Pokino which ishalf bingo and half poker. Wierd eh?!

Anyway...

The final part of the program needs to evaluate two 5 card poker hands
and determine which one out of the two hands wins. I thought rather
than create a new class of my own I would see if there was anything
already available. I have searched high and low but can't find
anything!!

I am using Cards.dll so each card is represented by an integer value
ranging from 0-51.

If anybody knows of any resources that may help me or can come up with
a quick and easy way to do this it would be much appreciated.

Thanks in advance,

Tom Miller.
IT Development Analyst.
Jun 27 '08 #10

This discussion thread is closed

Replies have been disabled for this discussion.