3. A family of simple rummy games

To illustrate the facilities defined above, we show how they might be used to generate cards for a simple game; or, rather, for a family of related games with similar rules. The simplest of these games might be suitable for young children, but the more complicated variations should be challenging enough for adults.

Each card will have three properties printed on it; these will be a person, something for the person to do, and a place to do it. Parents might use our program to generate a customized deck of cards, featuring their children and their friends, their favorite activities, and places they go or have visited.

The games will be played much like gin rummy. Each player is dealt a certain number of cards, and a card is turned up on the table to start a discard pile. As each turn, a player draws either a card from the unused part of the deck, or the card on the top of the discard pile. The player may be able to combine all of the cards in his or her hand, to win the game; otherwise, the player discards a card and puts it on the discard pile, and he turn passes to the next player.

Cards are combined by making groups of three (or more) of a kind: these are cards with matching values for any one of the three properties. Different games can be defined by varying the number of cards dealt to each hand and the rules for combining. Some possibilities are:

• Two cards in a hand, giving three after drawing. A player only needs to make one three-of-a-kind. This is a very simple game, and usually only lasts for a few turns. The obvious strategy is to get two of a kind and hold onto it, trying to draw a third to match.

• Five cards, giving six after drawing. The goal is two groups of three-of-a-kind. Here the player needs to think a bit about how best to combine cards into groups, since there may be a number of reasonable possibilities.

• Four cards, giving only five after drawing. Here the goal is two groups of three-of-a-kind, with one card common to both. An example might be a card with "John", "swimming" and "Florida" on it, two other cards with "John" on them, and two other cards with "Florida" on them.

3.1. Design of the cards

Here we define the design of the cards for this game. The design is simple: the three properties and words to connect them to make a sentence. Examples might be "John goes bird watching in Florida" and "Lynda goes swimming in New Mexico". The elements of the sentence are on separate lines. Positions, fonts and sizes are chosen rather arbitrarily, for appearance.

The code in this section and the next is specific to this game, so it is marked with the `role` attribute `"rummy"`. This is so it can be extracted separately from the code that pertains to all games. We assume that the latter code, when extracted, will be placed in a module named `cards`.

rummy
```def makeCard(person, activity, place):
Card.start()
Card.put(person, 16, 0.0, 0.6)
Card.putCentered("goes", 12, 1.1, font="Helvetica-Oblique")
Card.putCentered(activity, 16, 1.6)
Card.putCentered("in", 12, 2.1, font="Helvetica-Oblique")
Card.putCentered(place, 16, 2.6)
Card.finish()
```

Here is a sample of such a card, as printed on business-card stock with the long dimension vertical.