Making the AI, Part 2
Four months ago I wrote this post regarding the AI for Auction Poker. A lot has happened since then but I do plan to continue the discussion. Anyways, here’s Part 2.
In the last post I mentioned that the AI selects cards by their “affinity” to each other. I also mentioned that this doesn’t always result in an optimal hand. Sometimes, selecting the card with the highest affinity is detrimental to the hand - for example, selecting a second Queen after having a suited Queen, Jack and King. What was a possible Royal Flush is now at most a two-pair.
To remedy this situation, additional information was needed when calculating the affinity of the hand. Remember that affinity is based on the value of all the hands two cards can make. Once a hand is not possible to make anymore it is removed from the affinity calculation.
For example, if the AI holds a Pair of Fours, it cannot make a Royal Flush, a Straight or a Flush and those hands are not included in the calculation. Thus, the affinity between the Jack of Clubs and the Queen of Clubs drastically decreases since a lot of their value comes from a Royal Flush and Straight Flush.
Since calculating the affinity between two cards is a pretty heavy calculation to do every single time an AI player makes a bid, I pre-calculated the affinity for each pair of cards and placed them in tables for easy lookup. There are five tables for the following conditions:
1. All hands are possible.
2. Royal Flushes are not possible.
3. Straights are not possible.
4. Flushes are not possible.
5. No flushes or straights are possible. (Focus on pairs, trips, etc.)
This image, which I also used in previous post, shows the affinity between suited cards when all hands are possible. (The brighter the green, the higher the affinity.)

Once Royal Flushes and Straights are not possible (Chart #3), the affinity chart for suited cards looks like this:

At this point, the rank of suited cards is irrelevant - Straights and Straight Flushes aren’t possible anymore. Any suited card can be used for a Flush, that’s why the chart is so flat.
With these adjustments, we can update the basic procedure for selecting cards by the AI:
1. If the AI has no cards in hand, the AI checks the deck for the cards with the highest affinity.
2. The AI then determines which affinity table to use based on those two cards.
3. Using that table, the AI calculates the affinity for the remaining cards and picks the best one.
4. This process continues until the AI has filled out its hand.
However, with this process the AI will still select “bad cards” on occasion. For example, in the case below, the AI selects the King of Clubs and Ace of Clubs as its initial cards but then goes on to select the King of Hearts, the Seven of Clubs and the Seven of Hearts. These last three “bad cards” are not a result of bad calculation, there just aren’t any better cards on the board.

So where do we draw the line? The first two cards give us a nice chance for a Royal Flush, but having two Kings and a Ace isn’t bad either - we could end up with a Full House.
To figure this out, I tried to think of how I would play it. If I had the same set of cards, I would only select the King of Clubs and the Ace of Clubs and ignore the rest. Basically, I had to tell the AI which cards to ignore. This turned out to be a lot more subjective than I realized and which I’ll discuss in Part 3.



























