PART II - Refining the affinity method.
The first step the AI makes when given a set of cards is to find those that have maximum affinity. Given the set of cards pictured below, the AI would pick the King of Clubs and the Queen of Clubs.

After the first two cards, however, the AI needs to be careful in determining which cards to bid on and how many. The next best card is the Jack of Clubs but after that, the AI would pick the Queen of Spades which would spoil the chances for a Royal Flush.
I needed to find a way to tell the AI avoid some cards. The easiest way of doing that was by having the the AI only bid on cards that exceeded a minimum affinity with the rest of the cards.
For example, the average affinity between the King and Queen of Clubs with the Jack of Clubs is about 22. However, the average affinity between those three cards and the Queen of Spades is only about 18. So, if the affinity cutoff is higher than 18, the AI will only select the first two cards and will wait until further rounds to bid on the right card.
However, while the minimum affinity cutoff worked okay in testing, there needed to be a lot more work before it was ready for the game.
When I looked at the cards above, I made the decision not to bid on the Queen of Spades because it would SPOIL the chances for a Royal Flush. I needed to show the AI that by selecting the next card its range of possible hands would be drastically diminished.
In that respect, I added a function that had the AI determine which hands were possible given a set of cards. For example, having any card lower than 10 automatically means that a Royal Flush isn’t possible.
After some tweaking and testing, it turned out that each set of cards fell into one of these Conditions, sorted roughly in order of hand value:
1. Royal Flushes are possible
2. Straight Flushes are possible.
3. Flushes are possible. Straights are not possible.
4. Straights are possible. Flushes are not possible.
5. Only pairs, trips, full houses, etc, are possible.
For example, if these three cards were in the AI’s hand:

Condition #1 is not possible since we have low ranked cards.
Conditions #2 and #3 are not possible since the cards have different suits.
Condition #4 is possible since the maximum difference in ranks in 2 and the cards all have different ranks.
Condition #5 is possible for all hands and isn’t checked.
Looking back on the cards from the first example…

…the first three cards would fall under Condition #1. However with the addition of the fourth card, the set of cards goes all the way down to Condition #5 - Neither Royal Flushes, Straight Flushes, Straights or Flushes are possible with that extra card.
From that, it’s a simple matter of adding a couple of variables to the AI - one for the current Condition and one for the updated Condition. If the Condition changes too much then the AI refuses to bid on the Card. Dropping from Condition #1 to Condition #2 is not too bad since a Straight Flush is still a pretty decent hand. However, bidding on a card that drops a hand from Condition #1 to Conditions #5 is not a good decision.
After some more testing with this new code, I found that the AI’s were still booching too much. It turned out that every single one of them was always trying for the Royal Flush or a Straight Flush. I needed to put some variety in each of the AI’s personalities. On to Part 3.