2
$\begingroup$

I'm creating AI for a card game, and I run into problem calculating the probability of passing/failing the hand when AI needs to start the hand. Cards are A, K, Q, J, 10, 9, 8, 7 (with A being the strongest) and AI needs to play to not take the hand.

Assuming there are 4 cards of the suit left in the game and one is in AI's hand, I need to calculate probability that one of the other players would take the hand. Here's an example:

AI player has: J Other 2 players have: A, K, 7

If a single opponent has AK7 then AI would lose. However, if one of the players has A or K without 7, AI would survive. Now, looking at possible distribution, I have:

P1   P2   AI ---  ---  --- AK7       loses AK   7    survives A7   K    survives K7   A    survives A    7K   survives K    7A   survives 7    KA   survives      AK7  loses 

Looking at this, it seems that there is 75% chance of survival.

However, I skipped the permutations that mirror the ones from above. It should be the same, but somehow when I write them all down, it seems that chance is only 50%:

P1   P2   AI ---  ---  --- AK7       loses A7K       loses K7A       loses KA7       loses 7AK       loses 7KA       loses AK   7    survives A7   K    survives K7   A    survives KA   7    survives 7A   K    survives 7K   A    survives A    K7   survives A    7K   survives K    7A   survives K    A7   survives 7    AK   survives 7    KA   survives      AK7  loses      A7K  loses      K7A  loses      KA7  loses      7AK  loses      7KA  loses 

12 loses, 12 survivals = 50% chance. Obviously, it should be the same (shouldn't it?) and I'm missing something in one of the ways to calculate.

Which one is correct?

  • 0
    Everyone must play the same suit and highest card loses.2012-11-02

2 Answers 2

2

It depends on how the cards are drawn, which you haven't described.

For example, if each card is dealt to a random player, one at a time, then the first calculation is correct. On the other hand, if the cards are first shuffled, the deck is then split at a random position, and one player gets the bottom half while the other gets the top half, then the second calculation is correct.

In particular, using the first method of dealing, the probability of player 1 getting no cards at all is (1/2)3 = 0.125, while using the second method, it is 1/(3+1) = 0.25.

  • 2
    It's not the shuffling it's how they're dealt. If you are handing out the cards one at a time then each card has a 50/50 chance of going to each player; but if you have three cards and you pick (with equal probability) either to split before the first card (all three to P2), before the second (one to P1, two to P2) before the third (two to P1, one to P2) or after the third (all to P1), then there are 4 possible outcomes with 6 combinations each that each have a 25% chance of happening. Essentially you're cutting out all the possibilities of the single card being dealt between the other two.2012-11-02
1

Assuming you're handing out each of those remaining cards with a 50% chance between the two players, the chance of a specific having all three is (1/2) * (1/2) * (1/2), or 0.125. Since if either player has all three the AI will lose we have two of this situation that will end in AI failure, 0.125 * 2 = 0.25 = 25% chance of failure.

The reason you don't see this in your second chart is because you're missing permutations. In the all to one player examples you're showing every set of orders, however in the examples where one player gets two and the other gets one you are only looking at combinations where each player's individual order matters.

If player 1 gets AK and player 2 gets 7, there aren't two ways this can happen as in your chart, there are six (3 * 2 * 1)

  • Player 1 gets A, Player 1 gets K, Player 2 gets 7
  • Player 1 gets A, Player 2 gets 7, Player 1 gets K
  • Player 1 gets K, Player 2 gets 7, Player 1 gets A
  • Player 1 gets K, Player 1 gets A, Player 2 gets 7
  • Player 2 gets 7, Player 1 gets A, Player 1 gets K
  • Player 2 gets 7, Player 1 gets K, Player 1 gets A

If that particular order looks familiar it's because it's the same ordered combinations of cards from the 1 player gets all example in your second chart. The truth is for the situation you're describing, order doesn't matter so your first inclination was correct. Each of those possibilities has 6 ways to be dealt out, so in the end you're going to end up with the same probabilities