4
$\begingroup$

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

$\endgroup$
6
  • $\begingroup$ Do you want the probability at the beginning of the game ? $\endgroup$
    – Peter
    Commented Jul 1, 2019 at 13:19
  • $\begingroup$ 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 $\endgroup$ Commented Jul 1, 2019 at 13:21
  • 1
    $\begingroup$ 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 ? $\endgroup$
    – Peter
    Commented Jul 1, 2019 at 13:24
  • $\begingroup$ 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. $\endgroup$ Commented Jul 1, 2019 at 13:28
  • $\begingroup$ Off-topic , but this is a hard punishment considering that this can also happen accidently. $\endgroup$
    – Peter
    Commented Jul 1, 2019 at 13:35

1 Answer 1

1
$\begingroup$

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) {
        xp.add(x);
        boolean badCase = false;
        for(Integer xpp : xp) {
            if(xpp == 0) {
                badCase = true;
                break;
            }
        }
        if(badCase) {
            badCases.incrementAndGet();
        } else {
            goodCases.incrementAndGet();
        }
        xp.remove(Integer.valueOf(x));
        return;
    }
    for(int xpp = 0; xpp < x; xpp++) {
        xp.add(xpp);
        calcCases(x - xpp, xp, p - 1, goodCases, badCases);
        xp.remove(Integer.valueOf(xpp));
    }
}

I'm sure there's a simpler way, but for now I'll use this.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .