# Card probabilities

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

## Recommended Posts

Hello! I am making a poker game, and for that I will have a computerized player. I want the computerized player to sometimes calculate the probability that the hand he has is the best hand in the game. I have come up with the following: float prc = (num - pos) / num; prc = pow(prc, numopponents); Num is the number of possible hands, pos is the "goodness position" of that hand - 0 would be the best possible hand and higher numbers worse. numopponents is the number of opponents (not including self). The final result is prc. Am I completely off base with this?

##### Share on other sites

Look here

And here

And here

And This Could be useful too.

From,
nice coder

##### Share on other sites
Thanks, but none of that is related to my question. It is a simple mathematic question about probability, and is not really very related to poker at all, except for the fact that I will be using it for that.

##### Share on other sites
What I said might have been confusing. I will elaborate.

These numbers I am certain I have correctly:
num - The number of hands that exist.
pos - The position relative to other hands, the lower the number, the better the hand.

Then, I figure, (num - pos)/num will give the probability that the hand is better than another random hand (distribution of hands is uniform).

Then, p^n, where p is the above discussed probability and n is the number of opponents will give the probability that more than one player has a hand as good as or better than self.

Still, somehow I think I am missing something (It's been a while since I took stats & probability and it makes me uncertain), which is why I am posting here.

##### Share on other sites
Ok then.

You want to know the probability that your hand if the best hand in the game.

Sorry that the links didn't work... theres a thread somewhere which would be really helpful. i thought it was one of those.....

Ok, you've got 5 cards per hand per person

So you've got 52^5*numberofpeople card combinations. (its either 52*5 or 52^5)
thats 380204032*numpeople combonations.

You assign each of them a score. you then sort them by the score. you store them all in an array, with the score as the index (like a giant hash-table with the score as the hash).

Want to know your probability of winning?

Find the amount of cards that would beat your score (you find your score, add the amount of cards there, keep going until you reach the best hand).

Probability of winning = Numberofcardsabovecard / 52^5*numpeople * 100

Good? thanks.

Its been a while since i looked at that thread.

From,
Nice coder

##### Share on other sites
First of all, there's a lot more to poker than just calculating probabilities. Your computer player will be weak if this is all you base the betting on.

Regarding the probabilities, your algorithm doesn't seem to take into account the cards already used. There are a lot of hands your opponents can't have, because of the cards you already have. Also, when there are more than one opponent their probabilities won't be independant of each other, so just taking the probability for one player to the power of the number of players isn't correct.

##### Share on other sites
Nice coder, the number of (five card) poker hands isn't 52^5, but 52C5 = 2598960.

##### Share on other sites
Quote:
 Original post by Anonymous PosterFirst of all, there's a lot more to poker than just calculating probabilities. Your computer player will be weak if this is all you base the betting on.

Yes, this is of course just a little part of the whole puzzle.
Quote:
 Regarding the probabilities, your algorithm doesn't seem to take into account the cards already used. There are a lot of hands your opponents can't have, because of the cards you already have. Also, when there are more than one opponent their probabilities won't be independant of each other, so just taking the probability for one player to the power of the number of players isn't correct.

Is it close enough to be useable?

##### Share on other sites
It depends on the situation and how accurate you need it to be to consider it useful. In general your approach should be less accurate the more opponents you've got, but I can't give you any numbers.

##### Share on other sites
I have modified my algorithm a little, so that it at least takes into account what hands the opponents can't have because of the cards that are already in the hand. You have been very helpful!

1. 1
2. 2
3. 3
Rutin
22
4. 4
5. 5

• 13
• 19
• 14
• 9
• 9
• ### Forum Statistics

• Total Topics
632930
• Total Posts
3009289
• ### Who's Online (See full list)

There are no registered users currently online

×