2
$\begingroup$

I'm working on the AI for a card game that uses a standard deck of 52 cards consisting of 13 cards in 4 (spades, clubs, diamonds, hearts) suits.

Each player starts with 13 cards in their hand. When a trick is started, a player must follow suit if they can, otherwise they can play any card.

I'd like to calculate the probability that a given card in my hand is a winner if I start a trick.

To do so, I'm using the following formula:

t = number of unknown cards in play
c = cards in the opponent's hand
n = number of "key" cards

$$ P_i = \frac{(t - c)! (t - n)!}{t! (t - c - n)!} $$


If I want to play the king of clubs, only the ace of clubs can beat me, so the probability that the king can win is:

$$ P_1 = \frac{(39 - 13)!(39 - 1)!}{39!(39 - 13 - 1)!} = 0.667 $$

This result seems to make sense because the opponent only has 1/3 of the remaining deck.

Next, I'd like to determine the probability that the opponent does not have any clubs and can play a trump. I calculate the probability that the opponent has any club. Let's say I have four clubs in my hand and the opponent does not have the ace of clubs (five clubs total):

$$ P_2 = \frac{(39 - 13)!(39 - 8)!}{39!(39 - 13 - 8)!} = 0.025 $$

So, the opponent has about a 3% chance of not holding a club. Finally, I calculate the probability that my opponent is holding any trump. Let's assume I'm holding four trump cards:

$$ P_3 = 1 - \frac{(39 - 13)!(39 - 9)}{39!(39 - 13 - 9)!} = 0.985 $$

I'd like to say:

$$ P(win) = P_1 + (P_2 * P_3) $$

This would yield about a 69.1% chance to win.

But, I don't believe these probabilities are independent because I've encountered some scenarios where the final result sometimes falls outside the range of [0, 1].

What's the correct way to account for the chance that an opponent does not have a particular suit and can play trump to win the trick so I can accurately calculate the chance a given card is a winner?

$\endgroup$
  • $\begingroup$ If you lead the king of clubs and don't have the ace, somebody else does. You haven't defined how the other people decide which card of the suit to play. Will they always take the trick if they can? The chance somebody is out of the suit changes as the play progresses. You can compute the chance of somebody being void at the start given the number you start with, but that won't stay the chance somebody is void. $\endgroup$ – Ross Millikan Dec 23 '17 at 23:49
2
$\begingroup$

For the sake of definiteness, let's say you want to play clubs; there are $k$ clubs you don't have above the one you want to play, $l$ clubs you don't have below it, and $m$ trumps you don't have.

It's the losing events, not the winning events, that are disjoint.

One of two losing events is that your opponent has a higher club, with probability

$$ 1-\frac{\binom{39-k}{13}}{\binom{39}{13}}=1-\frac{(39-k)!26!}{(26-k)!39!}\;, $$

as you correctly calculated. The second, disjoint losing event is that your opponent has no clubs but has a trump. To calculate the probability for this, we need the probabilities that she has no clubs and that she has neither clubs nor trump. The probability that she has no clubs is

$$ \frac{\binom{39-k-l}{13}}{\binom{39}{13}}=\frac{(39-k-l)!26!}{(26-k-l)!39!}\;. $$

The probability that she has neither clubs nor trumps is

$$ \frac{\binom{39-k-l-m}{13}}{\binom{39}{13}}=\frac{(39-k-l-m)!26!}{(26-k-l-m)!39!}\;. $$

The probability that she has no clubs but has trump is the difference between the two. Thus, the overall probability you're looking for is

$$ 1-\frac{(39-k)!26!}{(26-k)!39!}+\frac{(39-k-l)!26!}{(26-k-l)!39!}-\frac{(39-k-l-m)!26!}{(26-k-l-m)!39!}\\ =1-\frac{26!}{39!}\left(\frac{(39-k)!}{(26-k)!}+\frac{(39-k-l)!}{(26-k-l)!}-\frac{(39-k-l-m)!}{(26-k-l-m)!}\right)\;. $$

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.