A study of a generalization of a card problem

https://doi.org/10.1016/j.amc.2004.04.091Get rights and content

Abstract

In this paper, we study a card problem, and its generalization, related to a computer based Cribbage player, namely, how many ways are there to select 12 Poker cards out of a deck of 52 such that their total face value exceeds 31? As an immediate application, the answer to the above question provides useful information for designing and enhancing computer based game playing software for Cribbage and other similar card games. Moreover, the analysis of the general problem also leads to a solution to a problem of “sampling without replacement”.

Besides presenting a combinatorial solution to the general problem, and discussing its “expressive complexity” via its relationship with the well-known integer partition problem, we also provide a computer solution, implemented in Prolog, based on a non-trivial recurrence relation. Relying on the latter result, we then carry out preliminary analysis of the computational aspects of some of the rules governing the Cribbage game.

Introduction

Since Claude Shannon wrote the original paper [15], in 1950, on computer chess playing, suggesting how a computer might play a game of chess, and Dietrich Printz wrote a chess playing program to solve the mate-in-two problem on a general purpose computer in 1951 [4], much progress has been made in the field of computer based game playing. An definitive example is that, on May 11, 1997, Deep Blue, a computer system designed and implemented by IBM Research, defeated the reigning World Chess Champion Garry Kasparov [10].

In this paper, we study some issues dealing with a computer based player for the Cribbage game. Cribbage is a card game mainly for two players, although can be easily adapted for three players or even four players forming fixed partnerships [20]. A play consists of several rounds. Starting with six cards each, the two players take turns to play cards, and score according to a set of rules. During playing, the total face value of the cards played by both players is counted, starting at zero and adding the value of each card as it is played. The total face value of the cards played must not exceed 31. When no more cards can be played without letting their total face value go over 31, the next round starts with unused cards.

The goal of playing the game is to be the first to score at least 121 points,1 perhaps accumulated over several rounds. For more details of the Cribbage game, readers are referred to the official web site of the American Cribbage Congress [1].

There are several computer software devoted to the game of Cribbage, such as Royal Cribbage [14], as well as a few web sites for on-line playing, such as Net Cribbage [13].

Among the rules for scoring, some of them are computationally simple. One such example is the Double Pair Royal rule: When four cards of the same rank are played in immediate succession, the player of the fourth card scores 12.

Another rule is the Run rule: A run is a sequence of three or more consecutive rank cards in any order during the play of the cards; such as 9–10–J or 2–3–4–5. Since A is counted as 1, A–K–Q, e.g., is not a run. The player of a card which completes a run is awarded a score equal to the number of cards contained within [1, Section 6].

For example: If cards are played in the following order: 4–2–3–5–6. The player of the card with a value of 3 scores 3 for a run, since now the three cards constitute a run of 2–3–4;2 then the player of the card with a value of 5 scores 4 for the run of 2–3–4–5. Finally, the player of the card with a value of 6 scores 5.

It turns out that this rule is rather time consuming to enforce, since whenever a card is played, there is a need to check if this new card, together with the previously played cards for this round, constitute another run, before a score can be determined. For example, if the cards played are 4–2–6–5–3, then a score could not be determined until all the cards are checked.

Let n be the number of cards that have been played in a round, since we can certainly avoid the run-checking process with either one or two cards; and, since the longest consecutive sequence with its sum does not exceed 31 contains A, 2, 3, 4, 5, 6, 7; it seems that we have to check for runs when n  [3, 7].

The situation is a bit more interesting since, as already discussed, a round is over when the total face value of the cards played reaches 31 or neither player can proceed without letting this total value exceed 31, when n gets reset to 0 and a new round starts. Obviously, if the total face value exceeds 31, there is no need to check if a new run is formed. Hence, the more often the total face value exceeds 31, the less run-checking we need to do. Below shows one of the best scenarios, where ‘∣’ represents a reset, when the next card from the other player will make the total face value exceed 31:

  • J Q K 10 J Q

and one of the worst case examples:
  • 4 7 3 2 5 6 A

In the best cases, run-checking can be completely avoided. But, in the worst cases, we have to check all the cases.

In general, the answer to the question that how often we have to check the cards for runs depends on how often the sum of the face values of those cards exceed 31. Thus, the following question becomes interesting: when taking n, 4  n  12, cards out of 52 cards, how often will the total face value of those n cards exceeds 31? We refer to the combinatorial problem associated with this question as the original (card) problem in the rest of this paper.

Although it is clear that, in a run, no card shares a value with any of the other cards, we do allow cards to share the same value to make it more natural and interesting when we solve the above problem. This also explains the expanded upper bound in the above question.

As a contribution of this paper, we will provide a detailed analysis of this run checking frequency, and show that it is rather low, particularly when we have more than six cards in the play. Thus, although the run checking is time consuming, the total cost associated with this operation is not high. Secondly, it turns out that this problem is an example of sampling without replacement, in the sense that, e.g., when n > 4, if the first four cards happen to be ♣2, ♢2, ♠2, and ♥2, then no card with value 2 can ever be used again in the sequence. This is not the case when we play with, e.g., n dice, where, all the dice can assume the value of 2. We will actually solve a general version of the original card problem, as we often do in dealing with combinatorial problems. Thus, as another contribution of this paper, we will provide an analysis of a general problem of sampling without replacement. For a study of a general problem of sampling with replacement related to dice, readers are referred to [16]. Finally, we believe that, some of the general techniques, such as the one we use in enforcing the order related assumption when constructing the recurrence relation as described later in this paper, can be applied in solving other computer game playing problems and similar combinatorial problems.

The rest of this paper proceeds as follows: After discussing some issues involved with the general problem in the next section, we present a combinatorial solution of the general problem, based on the prefab approach [23], in Section 3. To provide a more practical solution, we also suggest a computer based solution in Section 5, relying on a recurrence relation which we derive in Section 4. We then make a preliminary analysis of the computational aspect of the Cribbage game in Section 6, and summarize our results in Section 7.

Section snippets

A generalization of the original problem

We firstly define a setting for the problems we are going to study in this paper. Let (V,), V={1,2,,s}, be a partial-order set, let each jV be associated with a strict order set (Sj,j), and let P(m, r1,  , rs), for all j, rj  0,3 associated with V,S1, , and Ss, be a collection of m objects, each of which is labeled with (si, j), such that jV, i  [1, rj], and siSj, with j=

A combinatorial solution for the general problem

In this section, based on the work done on the prefabs and similar combinatorial structures [23, Section 3.14], we provide a combinatorial solution to the general card problem. This body of work is intended to find out a direct link between the number of constructed objects and the number of their unlabeled basic components. It has been applied to the study of such problems as integer partition, counting of unlabeled rooted tree, etc. [23, Section 3.16]. There is also a complimentary theory,

A definition of the recurrence relation

Because of the aforementioned difficulty involved in directly applying the above combinatorial solution to solve the general problem, we now seek a more practical solution. As usual, we start the process by looking for a recurrence relation.

A computer solution for the general problem

Once a recurrence relation is obtained, people usually follow the approach of applying the generating function technique to find its closed-form solution. Numerous techniques and skills regarding such an approach have been developed over the years [12], [9], [23]. Nevertheless, the process is tedious and certainly not always mechanical [9, Section 7.3]. It seems to be a challenge to find a closed-form solution for the recurrence relations as explored in Section 4.7 by directly following this

A preliminary analysis of the Cribbage game

To demonstrate the value of the results we have accomplished in the previous sections, we now provide an answer to the question that how often a run checker has to run. Since, as we discussed in Section 1, a run contains at most seven cards, we only need to answer the following question: When taking n,4  n  7, cards out of 52 cards, how often will the sum of those cards exceeds 31? We use P(n) to represent this frequency.

It is easy to see that there are 52n ways to select those n cards without

Concluding remarks

In this paper, we studied the generalization of a computer game playing problem related to the card game of Cribbage. We came up with a combinatorial solution to the problem, as well as a computer based solution, relying on a recurrence relation. We then made some preliminary analysis of the cost of implementing one of the more computationally expensive rules, namely, Run.

We believe that the same procedure can be applied in similar situations when we model certain processes with computers to

Acknowledgements

The author is grateful to Mr. Timothy Healy for raising the original question, getting me educated about the Cribbage game, his efforts of implementing the recurrence relations in Java, and his suggestion of the testing case as included at the end of Section 4.

References (22)

  • Z. Shen et al.

    A study of a dice problem

    Applied Mathematics and Computation

    (1995)
  • Z. Shen

    The calculation of average distance in the mesh structures

    Computers and Mathematics with Application

    (2002)
  • American Cribbage Congress,...
  • G. Andrews

    The Theory of Partitions

    (1976)
  • K. Apt

    From Logic Programming to Prolog

    (1997)
  • M. Bellis, The history of computer chess. Available from...
  • W. Clocksin et al.

    Programming in Prolog

    (1994)
  • T. Cormen et al.

    Introduction to Algorithms

    (1990)
  • K. Doets

    From Logic to Logic Programming

    (1994)
  • R.A. Epstein

    The Theory of Gambling and Statistical Logic (Revised Edition)

    (1977)
  • L.R. Graham et al.

    Concrete Mathematics

    (1989)
  • Cited by (0)

    Some of the material contained in this paper appears in [18].

    View full text