Card probabilities

Started by
8 comments, last by GameDev.net 19 years, 4 months ago
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?
Advertisement
Short answer: Yep.

Look here

And here

And here

And This Could be useful too.

From,
nice coder
Click here to patch the mozilla IDN exploit, or click Here then type in Network.enableidn and set its value to false. Restart the browser for the patches to work.
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.

The questions asked and answered in the three threads linked ask and answer completely different questions.
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.
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
Click here to patch the mozilla IDN exploit, or click Here then type in Network.enableidn and set its value to false. Restart the browser for the patches to work.
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.
Nice coder, the number of (five card) poker hands isn't 52^5, but 52C5 = 2598960.
Quote:Original post by Anonymous Poster
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.

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?
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.
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!

This topic is closed to new replies.

Advertisement