Introduction
Auction Poker is a pretty easy game to explain. The player starts off with 200 chips and must use those chips to bid on cards and complete hands. However only 10 cards are shown at a time. In the first round there are five computer players competing and bidding against the player (and each other) for the same cards.
After completing hands, a chip bonus is earned depending on the hand completed. A Royal Flush earns 320 chips, while a Three of a Kind earns 100 chips.
Players have to be careful not to spend all of their 200 chips to make a simple Two Pair hand. If the player does not win at least 5 cards, there is a 100 chip penalty. After each round, the player with the lowest amount of chips is eliminated.
Making the AI for Auction Poker was a tedious, albeit fun, programming task. Originally, Auction Poker was 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. In writing the code for the AI, I tried to approach it from the point of a view of a human player. What cards would I choose and how much would I bid and why?
PART I - Affinity and the first two cards.
The first step in writing the AI was determining which cards the computer player would pick. I’m not concerned about bidding at this point, all we need to do is figure out which cards the AI should bid on.
If I was given this set of cards, which ones would I bid on?

With just a quick glance, I would probably bid on the King and Queen of Clubs since I know I can 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 bid on the pair of 10’s and the pair of 9’s and hope for a Full House.
How did I determine which cards I was going to bid on? I looked to see how well the cards worked with the other cards in creating a good hand. Each card has little value by itself. Only when combined with other cards is their value realized. For example, the King of Clubs is practically useless if all the remaining cards are low ranking Diamonds and Hearts.
To create the AI, I somehow needed to put into numbers that measure how well each pair of cards works together, which I call ‘affinity’. The Ace of Spades and the King of Spades have a high affinity since they can make high ranking hands together. But the Ace of Spades and Seven of Hearts have low affinity since there’s not a good hand that contains both those cards.
I needed to create a chart that contained the affinity between each pair of cards. That chart would be used by the AI to help determine which cards it would bid on. At first glance, that seemed like a daunting task: (52 cards * 51 cards/2) is 1326 possible pairs. That’s a significantly sized chart. However, I realized that the specific suit of the cards doesn’t matter. It only matters whether the suit between the pair of cards matches or not. A Three of Clubs has the same affinity with a Six of Hearts or a Six of Diamonds. That drastically reduced the number of pairs.
Further below are some screenshots from the spreadsheet that calculated the affinity between cards. Each pair of cards was given a portion of the Chip Bonus based on which hand it could be part of. The Chip Bonuses weren’t finalized yet at this point but it was easy to change them and see how they affected the affinity between cards. The sum of these bonuses is combined and made into a measure of affinity.
This chart shows how the affinity was calculated between a 3 and other unsuited cards. The final affinity is shown in the bottom row.

The final charts look like this:

It’s much easier to see what’s going on with a graphic chart. The brighter the green, the higher the affinity.


The charts highlight the big difference in behavior between suited and unsuited cards. With suited cards, there is some affinity with cards from very different ranks. The affinity also increases as the rank of the cards gets closer together. At high ranks, the affinity is also influenced by the possibility of a Royal Flush. With unsuited cards, the only cards with high affinity are pairs. There is also some minor affinity between those of close ranks since it is possible to make a straight. But there is no affinity with everything else.
Now that I had these charts, I thought it would be a fairly simple matter for the AI to look at a set of cards and bid on those that had maximum affinity. However, things were not that simple. On to Part 2.