Getting a computer to play Bridge

Blog6 Comments on Getting a computer to play Bridge

Getting a computer to play Bridge

When I was a teenager, my best friend Hugo invited me to join him on his family vacation with his parents. There was one condition though, I had to learn bridge so we could play every night. His parents tried to get his brother and sister to play, but they denied, so I had to fill this void.

A life long love was born. Since that vacation, we played bridge many times, me pairing with Arrien his dad and Hugo with his mum, as his parents cannot play together for obvious reasons 🙂 In university I pestered all my friends into learning the game, until we had a tradition of playing bridge every Monday night in our frat house.

However, these days I do not really have people to play with regularly anymore, as my beau is convinced the game is for boring old people.

But, luckily, there is a world championship of Computer Bridge! For years I have had it as a lingering life goal to make a program that could realisticly compete, but the time has come, I am going to make a computer program to compete in the next edition. Participating is more important than winning, I do not care if I lose badly, I just want to make something reasonable, at least for the first time.

Over the coming months, I will keep you posted on my blog via tag Desiderius*. It is mainly a way for me to keep tracks of my decisions is modeling the game, probably it will be very boring for most of you, I am sorry. But the only way for me to get stuff done is to be loud about it, and the only way I can write well is if I think people are reading my ramblings. So bear with me please 🙂

What language to use?

I though for a long time about what language would fit my needs best, I even tried to get advice on Twitter but that failed. I was really enticed by the idea of using Idris, as I am convince that there are scenarios where dependent types will help me. However, I deemed it would be too hard to get basic stuff to work, like reading from a file or performing an http request (needed for the competition). Also, proper support on f.e. StackOverflow for a language so esotheric will be very limited and I want to gain some speed.

In the end I think what matters is that my goal is to get a working system and join the competition and not to learn a new language, so I will just stick with F#/C#.

A quick primer into bridge

In principle, the game of bridge is not complicated. You play with 4 players, each of which gets 13 cards from a regular deck of cards. You play in fixed pairs, which sit opposite each other:

File:Nl-HaNA 2.24.01.05 920-9139 Omar Sharif bridge.jpg
Omar Sharif Bridge (nationaal Archief)

There are two phases, a playing phase and a bidding phase. In this initial explanation, I’ll focus on the bidding phase, as that is where the most interesting things happened in terms of programming.

In the bidding phase, players have to determine the contract: which pair will play, how many tricks will they will make and with what trump suit. For example: North-South might agree on a contract of 7 tricks with spades as the trump color, expressed in “bridge language” as 1 Spades (the number of tricks you will make minus 6)

If the bid is settled upon, the playing phase starts in one half of the pair that won the contract (called the dummy) will open their cards on the table, and their partner gets to play with the both of them. This is why the playing phase is not that interesting, as every player can see half of the cards (yours and the dummy’s) it is not very hard to brute force on where the other cards are. Making the contract gives you points, failing to obtain enough tricks gives your opponent points. So far, nothing very strange.

However, the bidding is where the interesting stuff starts, especially from the perspective of a computer scientist. The pairs cannot deliberate freely on what the contract will be, they can only communicate with bids. So, given the limited room you have for bidding (disregarding doublets, there are only 35 bids possible, and in practice usually you only use a few steps to reach your end bid) you want to maximize information exchange between partners, while also using somewhat realistic bids. You might agree that bidding 2 clubs means you have no clubs, but if that is your end bids you are screwed, because you’re going to have to play it.

The way you bid is called a bidding system and is not bound by the rules of the game. That means that you may agree on whatever system you think is best, but most bridge players follow a limited number of existing systems, such as ACOL. There is just one rule, if you bid something, let’s say 4 clubs, your opponents may ask you what this bids means, and you have to answer truthfully. Failing to do so is cheating, and this matters, because this rule also holds for programs in Computer Bridge, so my program will also have to be able to do that.

* My program is called Desiderius, after Dutch humanist Desiderius Erasmus, because in the city I live, there is a famous bridge named after him 🙂

6 thoughts on “Getting a computer to play Bridge

  1. Hi Félienne,
    What is not yet clear for me from this intro is whether your bridge partner is your own computer program or you play the game with 4 different computer programs?
    Greetings,
    Arno

Comments are closed.

Back To Top