PDA

View Full Version : Sleeper: Poker discussion / odds



mvidas
04-15-2005, 08:20 AM
Hi Everyone,

Over on EE, Darren / UINVDJM asked a question about a poker simulator ( http://www.experts-exchange.com/Q_21381293.html ). I posted a file (attached here now), and I got the scoring all set, but I'm still a bit confused on how to calculate the odds.

I know how to calculate the odds of getting, say, a 3 or an 8 when you have 4,5,6,7 showing, as it is just normal math odds, but should I loop through every combination of cards, then calculate the odds of getting each possible outcome? How would I use that information to determine the odds of winning? I couldn't just look for the maximum odds, as a player could already have a pair and the loop would say the odds of a pair are 100%.

Can anyone think of a good algorithm for determining this? I don't need the code, as I can do that myself, I just can't think of a good method to determine the total odds.

Also, feel free to go through the code on the attached file, I'd love it if someone can find a way to improve it, even if just a little!

Matt

Killian
04-15-2005, 08:48 AM
Hi there,

this was a bit of a pet project of mine a couple of years back that I never got back to. I got a basic game together (yours is better btw) but my interest was more in trying to simulate some basic AI for computer players that would consider the odds for each potential hand, the players character (defined in a data sheet), past performance (recorded/updated in another datasheet) and stack at the current table in order for them to place a bet/pass/fold.
Unfortunately, what notes and test code I have are in a disorganized sprawl across various computers/archive directories/post-it notes so I'll try and get a handle on what I've got. I just know I've got some odds algorithms somewhere... :think:

Jacob Hilderbrand
04-15-2005, 08:54 AM
To find the odds of any possible hand (given what the player has) you would need to have several calculations. But you can narrow it done based on what they do have.

So are we playing draw poker? If so, the player can discard 0-4 cards. I would setup a macro for each amount of cards they can draw.

So lets say they discard 1 card. What are the odds of getting a pair?

First check if they have a pair = 100%

If they do not have a pair, then they have 4 different numbered cards so the odds of getting a pair are 12/(52-5) Where 5 is the cards they already have drawn. And 4 is the number of cards the could get for a pair.

Then what are the odds of getting three of a kind?

First check if they have it already = 100%

Then check if they have a pair already.

If they have one pair then the odds would be 2/(52-5).

And so on.

mvidas
04-15-2005, 09:06 AM
Jake, actually it is hold-em poker, where each player gets 2 cards, and there are 5 'community' cards that you have to pick the best hand of 5 of the 7 available. The five community cards are dealt by first putting 3 down, then betting, then the 4th, and betting again, and then finally the last. I'm actually trying to figure out who has the best odds of winning overall, when only 2, 5, or 6 of the 7 are shown.

Killian,
I haven't even begun to think of AI yet :) I may have spent a couple hours getting it to look nice and calculate the best hand a player has, but there really isn't any point to this as it would only really serve a purpose if some people were around the same computer, and looked away as each player looked at their hand. Any notes you may happen to find would be great, but you don't need to go out of your way to look for them. :)

Jacob Hilderbrand
04-15-2005, 09:31 AM
Ok, in that case you may want to setup a macro for each rank of hand. I can help you out with the calculations if you need it.

Killian
04-15-2005, 11:23 AM
One factor with the logic here is that there are other hands on the table, i.e.
if there's 4, 5, 6 & 7 on the table and you have a 3, you're looking for an 8 on the river for a straight - that's 4 cards out of the 46 left in the deck.
If there's a second player, there's also a 4 in 46 chance on either of his hole cards being an 8. That figure affects the probability value for the remaining deck.
If the are five other players... well you get the idea.
Each of these probabilities, and that of the diminished deck need to be factored in.
I remember one conclusion I reached when I was looking at this: Probability mathematics makes my brain hurt. :think:

Another thing occurred to me...
in the same scenario, of the 46 cards left, there are only 3 3's, 3 4's etc but 4 of the others, so the probability of hitting one of the others is a little higher.
I don't have time to look right now, but I remember finding a couple of websites that had some of this worked out (to lots of decimal places!)

Jacob Hilderbrand
04-15-2005, 11:23 AM
Well that depends, do we really need to consider what the other players have in their hand? Since theoretically we should not even know that.

I mean if I have an Ace and want a pair as far as I know the odds are 3/(remaining deck cards). Now if three aces are already held by other players, my chance of making a pair is 0%, but I would not know that.

brettdj
04-15-2005, 07:26 PM
Well that depends, do we really need to consider what the other players have in their hand? Since theoretically we should not even know that.

I mean if I have an Ace and want a pair as far as I know the odds are 3/(remaining deck cards). Now if three aces are already held by other players, my chance of making a pair is 0%, but I would not know that.
Thats correct.

If I have an ace in my two cards then my odds of ending up with 1 ace after the five community cards are


= 47/50*46/49*45/48*44/47*43/46
simplifies to

(45*44*43)/(50*49*48)
= 72.4%

This is more easily done as
=COMBIN(3,0)*COMBIN(47,5)/COMBIN(50,5)
ie, how many combinations (order unimportnat) can I pick none of the remaining three aces, and 5 of the remaining 47 none aces.

Odds of ending up with two aces

=COMBIN(3,2)*COMBIN(47,4)/COMBIN(50,5)
= 25.3%

Three aces

=COMBIN(3,2)*COMBIN(47,3)/COMBIN(50,5)
= 2.3%

Four aces

=COMBIN(3,3)*COMBIN(47,2)/COMBIN(50,5)
= 0.1%

Cheers

Dave

Killian
04-18-2005, 06:08 AM
Matt,
I turned up an exellent reference for the odds calculations (this is why post-it notes and scaps of paper will never go out of style)
http://teamfu.freeshell.org/poker_odds.html

Conchie
04-19-2005, 03:29 AM
My brain hurts! :)