Re: Poker - Calculating odds
Moved to Games programming
Re: Poker - Calculating odds
ok i see what your saying, why not after every turn calculat the odds, If the comp has a good hand then he keeps playing. Dont compare with yours, then he would know and would probably win all the time.
I would see what hand the computer has, and if hes got a good one then let him play and maybe if he has no hand at all.... 1 in 10 times he bluffs!
Re: Poker - Calculating odds
I play Hold'em a lot and I use a commercial program called Turbo Texas Hold'em (which I helped test BTW) to practice, and what it does in showdown situations is to complete the dealing of 5000(?) hands in the background and then uses win percent from those hands as the odds. It's not exact but it's probably going to be a lot faster then any code that involves a loop.
Re: Poker - Calculating odds
@ damasterjo
It doesnt compare the computer hand with your hand, it compares the computer hand with all the possible hands that you could have so for example if there was a 4 of hearts, a 5 of hearts, a 6 of diamonds, a jack of hearts and a ten of clubs on the table and the computer had a ten of hearts and a 3 of spades then he would have a pair of tens, but the possibilities of the player winning are high as he/she could have a flush of hearts, a straight, three of a kind, or even just a pair higher than the tens. So it loops through each of the cards the player could have, thats why it takes so long which is causing the problem
Re: Poker - Calculating odds
@MartinLiss
yea i have thought of doing just a kind of partial sample but id rather just find a way of cutting down the numbers without affecting the probabilities by finding a few patterns, like hands with different suits where the possibile outcomes are identical, like this:
Computer: 8 Spades, 8 Hearts
Player: ???, ???
Community: 8 Clubs, 8 Diamonds, J Clubs, ???, ???
obviously here there is a 100% chance of the computer winning but to calculate that it has to go through 148995 combinations... which takes about 13 mins :(
Re: Poker - Calculating odds
When you get up into the thousands of hands I would guess that the real odds differ from the 5000-hand-odds differ only by thousandths of a percent or less. Do you need it to be that accurate?
Re: Poker - Calculating odds
i suppose so, i'll try it out and see how much i can reduce the time by without really affecting the odds... i will be posting the code when ive got it sorted out and the code tidied up. :)
Re: Poker - Calculating odds
I don't think you need to run through 5,000 hands to find the odds you can calculate them.
For example if you are dealt down 2 hearts and there is 2 on the board after the flop, so that is a total of 4 out of 13 hearts. There are 9 hearts left with 47 cards left, so then you know the odds of hitting a flush. You can repeat the odds for every type of hands, some, for instance a Royal Flush can be eliminated. That is how I would have the computer decide the betting. Maybe all he has are pocket 2's with 3 over cards on the board. You are on the river and there isn't a 2 up what are the odds? What is the oppent betting? Is it worth the call? Are the implied odds high enough?
I would also have settings for the computer so that some of the AI is aggressive and some are really tight, to get variety in the game.
FYI get any discrete math book and it will help you calculate the odds.
Re: Poker - Calculating odds
Yea this is exactly what i was looking for, does anyone have any examples of how to calculate poker odds the way <213>>_Longhorn has mentioned? i dont have a lot of spare time at the moment but ill start trying to figure it out this evening probably.
Re: Poker - Calculating odds
I started some Pseudo code for the odds, but then realized it is more involved. At a high level this is how you figure out the odds of a poker hand.
Figure out what cards can make a hand, and divided that by the total number of cards left in the deck.
For example, if you are dealt AA down what are the odds pre-flop of hitting a 3 of a kind? Since you have only seen 2 cards there are 50 possible left. Even though other people maybe at the table you don't know there cards and the next card could be any of the 50 left. There are 2 cards left you can catch out of that 50 to make a 3 of a kind, AA, so the odds are 2 / 50 or 1/25 or 4%. If the flop comes and no Ace is on the board then the odds are 2 / 47 possible left or 4.2%. If none comes on the turn, then the odds of you getting that Ace on the river are 2 / 48 or 4.2 % again. That will hold the same for any pocket pair the chance of hitting a set, or 3 of a kind, is about 4%.
Going on a flush example, lets say you were dealt the A3 of hearts. The flop comes there is the 10H and 6H. That means out of the 13 hearts there are 4 gone, the A, 3, 6, 10 with the 2, 4, 5, 7, 8, 9, J, Q, K or 9 left. What are the odds of hitting the flop on the turn? There are 47 cards gone, and 9 can give you a flush or 9 / 47 or 19 %, the turn comes as a 3 clubs, what are the odds of hitting the flush on the river? 9 / 46 or 19.5%. Preflop the odds of hitting a flush are 11 /50 or 22%. Lets assume a player has the KH then you odds fall to 8 /47 or 17% after the flop. If somebody has the Q of hearts and the King is also gone then your odds are 7 / 47 15%. You could then have the program play WHAT-IFs
Is this what you were looking for? I don't know how to code that great in VB other than Access, but I do know C++ I could take a shot if I have time.
Re: Poker - Calculating odds
The odds of, for example, of completing a flush when you have 2 of a suit pre-flop are as you say 22% but the problem is that he needs to know the odds of winning with a given 2 cards and that is much more complicated since obviously someone could for example be holding Ax of the same suit as him.
Re: Poker - Calculating odds
no C++ wouldn't be any help, and as Martin has said, your way would only calculate the odds of acheiving a certain hand, not the overall chance of winning. It's a shame as i thought you may have noticed a good way to do it. Thanks anyway tho :)
Re: Poker - Calculating odds
Re: Poker - Calculating odds
Interesting and informative sites but again I believe what the poster wants is the ability to be able say that holding, say, the king and queen of hearts, that he will win x% of the time rather than that he will complete the flush 22% of the time.
Re: Poker - Calculating odds
Re: Poker - Calculating odds