# Portuguese card game probabilities with a 40 card deck

I'm working on a Portuguese card game for 4 players for a personal java project, and need help modelling. For this game, the 8's, 9's, and 10's are removed, leaving the deck with 40 cards, 10 for each suit. In each round, each player plays 1 card, in their turn. For a given player's turn, the probability I'm trying to calculate is if at least 1 player who plays after the given player's turn has at least 1 card of suit x in their hand, while having no cards of suit y.

Looking at an example,

                player 1
A♠ 7♥ K♥

player 2                        player 4
A♥                              6♠
J♥                              2♠
7♠                              6♥

player 3
A♣ 2♥ K♦


Suppose player 3 is the first to play in this round, and suit x is ♠ (defined in the beginning of the game, it's the "trump suit"). For y = ♣ there is at least 1 player with at least 1 ♠, while having no ♣. For y = ♥, the opposite is true, all players have ♥, regardless of having ♠ or not.

The question arises from the rule that trump cards beat any card, but you have to play the same suit as the first player in the round, if you can. Players know how many cards from each suit remain because they remember which cards have been played.

I think that's all the relevant information, if something is not clear, I'm happy to explain.

The game in question is Sueca

• Do you want the probability at the beginning of the game ? Jul 1, 2019 at 13:19
• I'd like to have a formula to calculate it that I can apply in any round for any player, to use in the heuristic for machine-controlled players Jul 1, 2019 at 13:21
• This can be difficult because we should use all informations we have (for example if we know someone does not have some suit anymore). So , can we assume that the players know the cards being played ? Jul 1, 2019 at 13:24
• Yes we can, I edited my submission. And if in a round a player doesn't play the same suit, we can assume he doesn't have any more cards of that suit. In real life this is heavily enforced, and anyone not respecting the rule loses the equivalent of 4 games. Jul 1, 2019 at 13:28
• Off-topic , but this is a hard punishment considering that this can also happen accidently. Jul 1, 2019 at 13:35

I ended up with this recursive function, which seems to work. It generates all possible distributions of x cards by p players. p == 1 is the exit condition. xp contains the assumptions. The function counts bad cases (1 player doesn't have the intended suit) and good cases (all players have it).

private static void calcCases(int x, ArrayList<Integer> xp, int p, AtomicInteger goodCases, AtomicInteger badCases) {
if(p == 1) {
for(Integer xpp : xp) {
if(xpp == 0) {
break;
}
}
} else {
goodCases.incrementAndGet();
}
xp.remove(Integer.valueOf(x));
return;
}
for(int xpp = 0; xpp < x; xpp++) {