Hi, bridge pals.
Recently, I started experimenting with artificial intelligence (AI) even though, as the old joke goes, I am much more used to using genuine stupidity (GS). You can see some of my AI experiments here, here, and here.
Those experiments were all about generating images and they were calculated to deliver bizarre and humorous results. But then I got to thinking (uh oh), why not see if the AI can deliver up something useful for my bridge program?
My bridge program lets you generate bridge deals; it lets you view a deal in a nice online format supplied by Bridge Base Online, and it lets’ you view some excellent double-dummy analysis in BridgeSolver. You can also take deals from my program and play them in the bridge software of your choice (as long as it supports LIN or PBN format). So what’s missing?
I would like to have two more capabilities:
I want to see some extended analysis of a bridge deal (more than just the makable contracts that BridgeSolver provides); and
I want nice, print-ready formatted bridge deals, suitable for inclusion in a printed article or in something like a flashcard for studying suit combinations.
On the analysis front, writing my bridge program was fun, but it taught me the limits of what I aspire to create on my own, and that limit is the deals themselves. Everything else, I want to outsource by passing my generated deals into a program or website written by experts. I do not want to reinvent too many wheels, and analysis in particular is a wheel that has been and is being worked on by extremely smart folks. But before figuring out how and where to take advantage of their work (with their permission), I would first like to see how far I can get with AI-driven analysis.
As for print-ready deals, that is something I actually can do all by myself like a big boy, but before attempting it I would like to see if I can do it by telling the AI what I want, and seeing what it comes up with.
As for how to use an AI with deals from my program, the ideal way would be via a button or link that just passes the deal into the AI. However, my understanding is that that method would cost money. For instance, the AI that I use (ChatGPT) has an application programming interface (API), and they charge for using that API based on how much text you pass into it and how much text they send you in reply. That kind of billing is standard for web services, but I don’t want to put anything on my website that will result in charges to my bank account.
Not using the API means that I need to generate something that is suitable for cutting and pasting into whatever AI the user chooses to use. So, once I understand how to formulate a bridge-related query to an AI, I will make my program capable of generating such queries and I will give instructions for using them in a way that doesn’t cost me money.
My first step, shown here, is to see what the AI knows about bridge. The following session exchanges are done using ChatGPT (specifically, GPT-4 and DALL-E) from Openai.com. If you try this on your own, your mileage may vary.
First, let’s see how the AI can consume bridge deals.
Great. We can try giving the AI a LIN or PBN format. I will do so using the deal shown at the top of this page. I created it using my Customized Deal tool, specifying a 1NT opener in the dealer’s hand, with partner having 8-9 points. This resulted in a deal for which BridgeSolver said 3NT+1 in N/S is the optimum result. Let’s see what the AI thinks of it in LIN format:
The AI came up with a 3NT N/S contract, same as BridgeSolver. However, it did not interpret the LIN file correctly. Notice that while North is the actual dealer, the AI thinks South is the dealer. It also assigned the hands to the wrong seats. Finally, the opening lead is S8, which is under-leading the Ace.
I asked the AI to reconsider:
The AI changed to make North the dealer, but it still assigned each hand to the wrong seat. Clearly, if we want to use the LIN format we would have to somehow train the AI to interpret it properly. It is probably possibly to construct a message describing the LIN format in full before asking the AI to interpret bridge deals, but for now I want to see if we can instead use a more explicitly tagged format that we don’t have to explain. So, same deal but in PBN.
This time, the deal is parsed correctly. The 3NT contract is arrived at via a sequence of NT bids. Note that while my bridge program can create a deal with a 5-card suit when you specify a 1NT opener, some players will open with the 5-card suit as the AI suggested here. No worries—based on the bidding conversation, N/S got to NT in due time. And the opening bid seems reasonable—at least it’s not under-leading an Ace this time.
Based on this result, my first approach to supporting AI without incurring the monetary cost of an API call would be to provide a button that generates a file containing the fully-formed request to the AI, plus the PBN of the deal. The user could then open that file and cut and paste it into the AI of their choice.
Now for the print-ready nicely-formatted bridge deal diagram. Based on my non-bridge experiments with image generation, I know that I need to be explicit in my description of what I want, but I also need to expect to be surprised (possibly even alarmed) by what the AI draws. Let’s go.
Rather than trying to describe the desired format from scratch, I first pointed the AI to an old Frank Stewart column that has a standard deal diagram, like this:
Monkey see, monkey do, right? Here’s the result:
That is so wrong, but I kind of wish it was right. It’s beautiful and using it would give me a sheen of intelligence far beyond that which is imparted by the sight of me puzzling over an actual bridge diagram. An earlier experiment yielded this even more elaborate thing:
Clearly, I need to come up with a very plain but complete way of describing the desired bridge diagram. Or, you know, code it myself. But the whole point of this exercise is to discover how to properly phrase a request to get something useful out of an AI, so I’m going to keep doing that instead of writing my own diagram formatter.
I am greatly encouraged by the analysis provided by the AI. In future experiments I will give it some deals for which I have existing analysis, such as those from the Common Game or from bridge books and magazines.