Where do the hands come from?

Bridge boards with my Dealer4 machine

My desk with computer monitor and Dealer4 machine. On the screen is the Dealer4 software with a hand displayed.

Most players take my word when I say, "The hands are randomly generated and dealt to the boards by a machine." That's all true as far as it goes, but what does it really mean?

Let me give you a peek behind the curtain and show you what it takes to make pre-dealt hands and hand records for a duplicate pairs game1.

Since the early days of generating bridge deals by computer, quite a bit of research has gone into the mathematics involved. Early random number generators were woefully inadequate for being able to replicate a hand-shuffled deck of cards.

For one thing, the number of possible bridge deals is a huge number: 5.36 x 1028. To generate all possible hands, you need at least 96 bits of random seed. Some source of entropy must be used to generate that seed.

The random number generator also needs to be cryptographically secure, such that someone with knowledge of the program and the first few deals from a set can not recreate the remaining deals from that information.

A program that satisfies these requirements was developed by Hans van Staveren in 2000, named Big Deal. You can see his documentation and get links to the source and binaries at this link. Since Hans did that groundbreaking work, his program has become the basis for all hands generated at tournaments at all levels, from world-class championships to the hands I'll use on a bridge cruise.

Besides collecting at least 96 bits of random seed, its internal pseudo-random number generator (PRNG) uses 160-bit integer random numbers in the process of generating a shuffled deck.

That takes care of one part of the problem, but there's a lot of infrastructure that goes into making it all useful.

The ACBL, The Common Game, and most clubs that pre-deal hands use a Windows app called Bridge Composer to format printable hand records as a PDF file. Bridge Composer comes with a built-in random deal generator, but it also has hooks to run Big Deal to generate hands during a run. That's the configuration I use.

A screen shot of the "generate" dialog from Bridge Composer.
Here's a screen shot of Bridge Composer's dialog for generating hands.

Bridge Composer also embeds a double dummy solver written by Bo Haglund to create a double dummy analysis of each hand, along with something called a par result (follow the links if you'd really like to dig into those).

So to start a hand generating session, I launch Bridge Composer on my PC.  I'll use the tools | generate menu commands to create boards 1 through 15 for an average BridgeMojo game. I always generate 15 boards to cover the case where I have five or six tables. In that instance we'll play 15 boards instead of 14.

Bridge Composer launches Big Deal in the background to generate a deal set.  It use its built-in double dummy solver to create a double dummy analysis for each hand, and saves the set as a PBN (Portable Bridge Notation) file. I use another command to save the deal set as a PDF hand record suitable for printing and downloading.

Once the hands are generated, and I have a PBN file, I can use that to actually deal boards.

I use a machine called the PlayBridge Dealer 4, created and built in the U.K. A few years ago I created this YouTube video (see below) that shows my machine in action. The machine connects to a Windows PC with USB. There's an app running on the computer that actually controls the machine.

The machine has sensors that read a bar code on the side of each board to check that the correct board has been inserted. Then its camera looks at the index of the bottom card in the stack. The software uses the image to recognize the card, and directs the machine to route the card to the correct pocket of the board. Sorting a deck of cards into a board usually takes less than six seconds.

In the Dealer4 app, I load the PBN file associated with my next game or class. Then I can stack up boards and decks of cards and generate, say, four identical sets of 14-15 boards in about twenty minutes.

Since the BridgeMojo games are short by bridge game standards, the hand records are all one-sided. It's easy to print thirty or so copies of the game hand record on my own laser printer.

When I was studying the Big Deal documentation, the author Hans had a very good bit of advice near the end:

... you should never look at the deals generated. Even if you deal 16 boards, of which in the first three North has an eight-card spade suit, so be it. If you would deal by hand it could happen too. If you ever decide to manipulate the output, for example by dealing the session again if you do not like the hands, you are interfering in the interaction between players and deals.

The software for Dealer4 will deal the cards without displaying the hand being dealt, and that's usually how I create my game boards. I usually have no idea what's in the boards until you actually see them during the game.  It's true that I had to print the hand records, and I'll always take a look at North on Board 1 and compare it with the hand record to make sure they match, but beyond that bit of verification I make it a practice not to touch the generated hands.

What's amusing to me are the beliefs about computer-generated bridge hands that seem to be unavoidable. Players are often convinced that someone or something "set up the hands" to create strange or interesting results. The absolute truth of bridge is that all you need to do to get strange and interesting results is to shuffle your card decks well. Computer-shuffled deals never have cards that stick together, or humans that don't shuffle well enough for a good random mix.

Here's an embedded version of my dealing video. It's a bit out of date, in that the deal set I'm demonstrating has been supplemented with one that fully sorts a deck. It's still fun to watch the machine deal cards.


1. Hands for team games are usually shuffled and dealt before each match, with very few exceptions.