Calculating Strength of Poker Hand

Started by
20 comments, last by Daddy-O 19 years, 7 months ago
any straight flush beats 4 of a kind
Advertisement
Damn! This is tough! Determining what the hand is from an array of cards is a lot more difficult than I thought it would be. It's gonna be even harder when the best 5 have to be picked from 7.

Anyways, thanx for all the useful suggestions guys!
Just picking the best one isn't hard. Just make functions that checks for the different kinds of hands. First check for a royal, then for a straight flush, four of a kind, and so on, downwards. Once you've found the kind of hand, you break.
After that, it's simply a matter of storing the highcard, and for two pairs, the lower pair aswell.
I thought you needed this for some sort of poker AI, which is why i gave the whole rundown upthere.
Here are a few links that might be of interest:

Hold’Em Showdown by Steve Brecher

Some links and sources

Doug Mair's Poker tools

No no no no! :)
Hi,

what your are doing is artificial intelligence.

What i can advise you to do create an evaluation function with some parameters.

like F(a,b,c,d) = a * Number of pairs + b * number of Aces ....

and do a RRHC algorithm to find the optimum (a,b,c,d) value that match the best evaluation function.
RRHC = Random-Restart Hill-Climbing.

I used this method for a project to develop à tetris AI.

I search the space of solution for a maximum.
You need to play for example 10 games to do the average of the score. But for this you need first an opponent with another alogorithm. It can be a simple one.

IN my project i did a distributed version of teh learning algoritm because i had to play 100 games of 10 000-15 000 lines to have a value, which took a lot of time.
It took me 2 weeks with somes computers to find a good value.

I found the following links :
see for the evaluation function for tetris.

and for the learning algorithm.


the harder thing is to design the evaluation function because it will take you a lot of time to find maximum extrema. Yes carefull, with such function the space of soltion is very big and there are a lot of local maxima.

hope that helps (and hope that's clear)

neyna
Quote:Original post by Neyna
what your are doing is artificial intelligence.


He's not, really, even though that's what I thought at first.
I think he's just trying to decide the winning hand at a hold'em showdown.
Errr

So you want a sytem that maps each poker hand into a real number, so that you can, in the end, compare who was better?

Well... we all know that the hand types do have a certain kind of order in their strength... pair / two pairs / three of a kind / straight / flush / four of a kind / five of a kind / royal flush

(I might have made an error somewhere, but the idea remains)

Anyway, a good idea for your algorithm is to start from the best one, and go for the worst one. Something like this:

int ValueOfHand( Hand& hand ) {
if( IsRoyalFlush(hand) ) return 5;
if( IsFiveOfAKind(hand) ) return 4;
if( IsFourOfAKind(hand) ) return 3;
if( Flush(hand) ) return 2;
...
}

and so on... it should be obvious why this works.

Then there are, of course, some exceptions... for example, if two players have the same kind of hand (for example, a pair), the one with higher pair wins. Luckily, these are just special cases for each hand type.

- Mikko
Quote:Original post by uutee
Well... we all know that the hand types do have a certain kind of order in their strength... pair / two pairs / three of a kind / straight / flush / four of a kind / five of a kind / royal flush


Five of a kind? If we ever play poker, remind me to check your shirtsleeves ;)
Quote:Original post by tok_junior
Quote:Original post by uutee
Well... we all know that the hand types do have a certain kind of order in their strength... pair / two pairs / three of a kind / straight / flush / four of a kind / five of a kind / royal flush


Five of a kind? If we ever play poker, remind me to check your shirtsleeves ;)


He means playing with wildcards I think ;)
No no no no! :)
Probably, but you're not playing with wildcards if you're playing with standard international poker-rules :)

This topic is closed to new replies.

Advertisement