Making the AI, Part 1
Making the AI for Auction Poker has been one of the most tedious, albeit fun, programming tasks that I’ve done so far.
Originally, Auction Poker was going to be a multi-player game but I felt the game would be more accessible if it didn’t require other people to play it. That’s when I began to make the AI.
The very first thing I needed to do was figure out a way for the AI to determine which cards are capable of making a good hand. Given a set of ten cards such as shown in the image below, how would the AI know which cards to bid on?

In this set of cards, I would bid on the King and Queen of Clubs since I know I can possibly make a Royal Flush if the right cards come up and if not, I can settle with a plain flush or a 9-K straight. Or maybe I would go for the pair of 10’s and the pair of 9’s and hope for a Full House.
I didn’t look at each card individually, I looked to see how well it paired up with other cards in creating a good hand. Each card has little value by itself. Only when combined with other cards is their value realized. Thus, the King of Clubs is useless if all the remaining cards are low ranking Diamonds and Hearts. To make a semi-intelligent AI, this information needs to be somehow measured and placed into a chart that the AI can look up.
To measure the affinity between pairs of cards, I used a rather large spreadsheet and figured out which hands were possible with each pair. For example, given a 9 of Hearts and a 9 of Diamonds it is not possible to make a Royal Flush, a Flush, a Straight or a Straight Flush. However, it is still possible to make a 4-of-a-Kind, a 3-of-a-Kind, a Full House, a Two Pair and a Pair hand.
This is the visual result of that spreadsheet. The brighter the color, the greater the affinity between two cards:


The white spaces in the middle of suited chart are pairs that are not possible - same suited cards of the same rank.
As you can see, there is a big difference in behavior between two cards of the same suit and those from different suits. With suited cards, there is some affinity even with cards from very different ranks and the affinity increases as the rank of the cards gets close. At high ranks, the affinity is also influenced by the possibility of a Royal Flush.
With unsuited cards, the only cards with large affinity are pairs. There is also some minor affinity between those of close ranks since it is possible to make a straight. Everything else has no affinity.
Now that we have these charts, it should just be a simple matter for the AI to look at a set of cards and maximize the affinity. Let’s take a look at this set of cards and pick the ones that have the maximum affinity:

If only look at two cards at a time, the AI would pick the Queen and King of Clubs but it would miss the Jack of Clubs which would go a long way towards making a Royal Flush.
However if we look at four cards at a time, the AI would pick the Jack, Queen, King of Clubs and also the Queen of Spades. That’s not good, we wouldn’t want that extra Queen of Spades.
To refine the AI, we will have to make sure it knows what hands are still possible with each new card. Up to the third card, the Royal Flush is possible. Once we have that extra Queen, the Royal Flush is impossible and the best we can hope for is a 3-of-a-kind.
Figuring out how to do that will be the focus of Part II.





















