Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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    AK   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?

share|improve this question
    
To answer this question you need to know how the cards were distributed among the players in the first place. For example, if they were distributed by just giving player 1 all the cards, then the odds are 100% that you'll lose. –  Noah Snyder Nov 2 '12 at 16:30
    
The cards are dealt randomly. AI does not know how many cards each of them have, only that they have 3 cards together. Each of the opponents might have 0,1,2 or 3 cards. Overall probability needs to be calculated taking in account all the possible combinations. –  Milan Babuškov Nov 2 '12 at 16:34
    
I know this might look odd, but those are actually cards of the same suit, and players have to follow suit. Of course, players have cards from other suits but that's irrelevant to the calculation. –  Milan Babuškov Nov 2 '12 at 16:35
    
By cards are dealt randomly do you mean that for each card you flip a coin and give the card to 1 if it's heads and 2 if it's tails? –  Noah Snyder Nov 2 '12 at 17:41
1  
If they both have the same number of cards then it shouldn't matter whether it's 4 cards or 5 cards. But if they had different numbers of cards, then I think that could change the answer. –  Noah Snyder Nov 3 '12 at 0:07
show 3 more comments

2 Answers 2

up vote 1 down vote accepted

You have 3 distinguishable cards and 1 partition (dividng the hands between the two players). Therefore, the number of cases should be $4! = (4)(3)(2)(1) = 24$. The permutation method is correct. In essence, the cards and the "partition" can be shuffled to any configuration, and as such, while P1 having AK7 isn't different from him having K7A in terms of the net result, these are two different states resulting from different shuffles. In your first calculation, you neglect the multiplicity of each configuration, and that's why you get an erroneous result.

share|improve this answer
add comment

As I mention in comments, in order for this question to be well-defined you need to make explicit what you mean by "random." Nonetheless, I think the first answer is the one that you want.

To make the question well-defined we will deal out cards by taking each card and assigning it to one of the two players by 50/50 chance.

Let's think about this in two ways. First we can say it doesn't matter which order you assign the cards in, because for each card there's still a 50/50 chance that it goes to each player. So there are 8 possible deals all of which are equally likely. As you checked 6 of those are survives, so 3/4 of the time you survive.

There's a second way you could think about it, which is to shuffle the cards and then assign each randomly starting at the first. Now there's not 8 possibilities, there's 6*8 = 48 possibilities. This is what you're trying to get at with your second method of calculating, but you're missing some of the options, because there are three different ways that say AK 7 could happen: the 7 could be the first card, second card, or third card.

So your second answer is wrong because the possibilities that you list aren't all equally likely. The AK 7 hand will happen 3 times as often as the AK7 hand.

share|improve this answer
    
This seems to contradict what Muphrid wrote, so I'm now back at start with two answers to a dilemma and still not being sure which one is correct. ;) –  Milan Babuškov Nov 2 '12 at 18:01
    
Indeed, I think Muphrid's answer is wrong. At any rate I can't follow the argument that answer. –  Noah Snyder Nov 2 '12 at 18:08
    
The question is about what's equally likely. I modeled every configuration of cards in the deck, prior to being dealt, as equally likely. Don't see how AK7 could happen any more ways than the OP had them. There are 6 ways, and he has all 6 of them. There are 4 ways of having AK|7 (AK on one player, 7 on the other), and he has all 4 of them. What's with the 48 total number that's running around? Overall, the discrepancy in answers comes from different choices in how the cards are allocated. How are the cards divided between the two players? –  Muphrid Nov 2 '12 at 20:12
    
@Muphrid: These sorts of questions are notoriously confusing, and I'm happy to admit that I might be missing something. But I still don't follow your argument. There's actually 6 ways you could have $1p=\{AK\}$ $2p = \{7\}$ because the 7 could have been the first card dealt, the second card dealt, or the third card dealt. –  Noah Snyder Nov 2 '12 at 20:45
    
Yeah, I realize now I implicitly decided (since it doesn't affect the overall result) that player P1 would be dealt all cards until the "partition" card comes up, and then P2 would be dealt all remaining cards. It could just as easily go the other way around, but the symmetry of the problem means no incorrect result has been arrived at. At least, for that way of dealing the cards. I think either of us could be right, just depending on how the cards are allocated. –  Muphrid Nov 2 '12 at 20:48
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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