Auction Poker AI - Part 1

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.

New Auction Poker Trophies

Spent some time this weekend drawing up the new Auction Poker Trophies. The image below shows nearly all of them. I’ll be coding them into the game during some free time this week and next week, unless some other commitments come up.  Except for the Poker Chips, the general theme of the trophies are royal and medieval items.  A little bit of trivia: all of the names of the AI players are from French Royalty.

Most of the writing is nearly done for the Auction Poker AI posts but I just have to dig down and get some numbers and make some diagrams.  I’ll wait to release the new trophies until I finish the posts but I do think it’ll be done by the end of the month.

Looking forward

So I finally listed Blackjack Square tonight. Took a bit longer than I originally intended but I think the final tweaks were worth it.

Anyways, here are the icons for the three games - Poker Square, Cribbage Square and Blackjack Square.

There is one suit missing and I’ve actually reserved that for the final Square game. It’s based on a game that’s not that popular anymore but I do like the mechanics of its gameplay and will probably be awfully easy to code. I’ll probably finish that one after updating Aliens Over Hawaii and Paint Factory, most likely near the end of the year.

Currently, the next big push will be to create about 30 new trophies for Auction Poker in addition to finish writing how the AI was developed. Hopefully I can finish all this in about a month or so but we’ll see.

Tinkering and Stuff

So I’ve taken a bit longer to release Blackjack Square but there’s a good reason. Even after lots of testing,  to check the trophies, it struck me that the outcome of the game relied too much on luck. While luck does play a part in the other two Square games, it seems to play a  much bigger part in Blackjack Square.  I did some tinkering here and there with the Switches but we’ll see what feedback there is when I release the game.

I’ve probably been a bit slow in finishing up the testing of the game because I’m already looking forward and dabbling with some other things on my list. Auction Poker is going to get a bunch of new trophies as well and I have written new drafts explaining how the AI works. (I’ll finish it this time, really!)

In addition, I wrote some themes on the piano for Aliens Over Hawaii so hopefully I can get some sound and music into the game, as well as fixing one rather annoying bug that seems to be affecting the scores.  A little bit of sound can really add to the game:  Depth Charge wouldn’t be the same with those pretty cool sound effects.

And after that, in a few months, Paint Factory is going to get a big upgrade with a couple of new modes and themes.

I also have a ton of ideas for new games so we’ll see when I can get them out. At this pace, somewhere around 2012.

Rolling It Out

Well I had a nice break this week, hit Sausalito, went on a very long hike, met up with a couple of old friends and did a lot of spring cleaning so it was only until yesterday evening that I got to working on the games.  I managed to finish the updated version of Poker Square! The coding of the trophies didn’t take too long and neither did testing them. Most of the time was spent in thinking them up, drawing them and listing them.

After a lot of testing today, however, I decided to always let the player use a card Switch. I just like the mechanic so much that I found it annoying whenever I ended up with 0 switches. That will make some of the trophies a bit easier to get but that’s fine.

Anyways, I hope to get Cribbage Square out by next Sunday.  Coding the trophies should be a bit faster the second time around.

A bit of a delay

I haven’t had much time to work on the games at all this month.  I’ve been kept pretty busy planning some pretty significant life changes - plans upon plans upon contingency plans.  Anyways, I have a slight break coming up at the beginning of July so I’ll devote some real hard time to cranking the games out. I’ll also have a much shorter commute! I orginally meant to publish the three updated games at the same time, but I think I’ll do a slow rollout to make sure all the trophies and cookies are working correctly.

Working on the trophies

Although I barely touched my laptop during my vacation at the end of May, I made great progress this weekend on drawing the 105 new trophies for the Square games.  It wasn’t as hard as it seemed, though. All three of the games have quite a bit in common and the conditions for winning those trophies will share similar characteristics.

However, while the trophies will share similarities, each game will have a look to their own trophies:

On the top row are trophies for Blackjack Square, the middle row is Cribbage Square and the bottom row is Poker Square.  The trophies in each column will be earned in similar ways in each of the three games.

I’m also working on a few things behind the scenes. Lots and lots of drafts and notes. One day I’ll catch up and finish them all!

Vacation Time

A while back, as I was looking through my old games, I decided that I needed to update them before working on any new ones. One of the things that struck out at me about Poker Square and Cribbage Square is how few trophies they have - about 10 each.  I also noticed that half of those trophies would only be earned after a near-eternal grind.

One of the more significant updates to either of those games will be the addition of dozens of new trophies. Each of the three games - Cribbage Square, Poker Square and Blackjack Square will have 40 trophies.  I will also reduce the requirements for the ‘lifetime points’ trophies. My goal is to have all the trophies capable of being earned with just 6-8 hours of playtime on each game. Previously, the lifetime point trophies took dozens of hours to earn - way too much for such simple games.

Like the stamp-themed trophies from Aliens Over Hawaii, the new trophies will also have theme to tie them together. However the theme will carry to all 3 of the ‘Square’ games. The trophy artwork for the lifetime trophies will remain the same but everything else will be redone in a coin theme. I think it’ll be fun collecting the coin trophies for each of the games.

Luckily, the big thing left do before listing the games is drawing up and coding the trophies which is an easy and undemanding thing to do - perfect for some of the down times during vacation (assuming I even turn on my laptop.)

Anyways, I’m off to enjoy the Arizona and Nevada sunshine for the next week!

P.S. I see that my problem of me trying to find the Whirled Coin/Bar Ratio when I’m offline was pretty much solved (for the moment). Ha! I’ll still check up to see if there are any changes due to the HWFO if I’m online on vacation.

Up and Up

I’ve noticed over the last week or so that the Coin/Bar Ratio has been increasing at a relentless pace. Take a look at this graph for the last couple of months. The Ratio was holding steady, under the 12,000 coin level until around May 5th when it just rocketed upwards at a pace I haven’t seen before.  I speculate that lots of people playing the game, earning coins and not buying bars causes an increase in the rate.  Bang Heroes was released on NewGrounds on April 21st; a bit too early to cause the big bump so I don’t have much of a clue on what’s causing the big bump.

Anyways, I should probably find a more automated way of getting the current ratio instead of me just checking on Whirled once or twice a day.  I wonder if I can use one of those websites that allows me to create an RSS feed for any site.  It hasn’t been much of a priority before since I’m generally lurking on Whirled. However,  I’ll be out of internet access travelling through Arizona for about a week starting next Sunday so I think I should spend more effort into looking at something.

Working on the Squares

I’ve been making some slight changes to Poker Square and Cribbage Square. The biggest change is adding the ability to switch cards after they’ve been placed. However, this ability must be earned by scoring a certain number of points in a previous round. In addition, a player can switch at most two pairs of cards. Here’s a quick screenshot showing a pair of cards in the middle of being switched.

To figure out at what point threshold a card-switch would be earned, I had to take a look at metrics for each of the games. I didn’t want a card-switch to be easily earned but neither did I want it to be rare.

These are the metrics for Poker Square as of yesterday. I recently updated the game so the number of scores recorded are a bit low.  The red line indicates where I’m placing the threshold for earning a card-switch: 100 points.  I also noticed that I need to bring the score cap down quite a bit, to possibly 200 points (currently it is 300) since the bulk of the scores are bunched up on the low end.

Below are the metrics for Cribbage Square. The red line again indicates the threshold for earning a card-switch. In this case I decided to place it at 80 points. You can also see that the scores are a bit more balanced here than in Poker Square.

Since I mainly work on these games during some free time on the weekend and I do have a week-long trip to Arizona coming up, I think it will be early June before I get these changes in the live versions.  I could get them up right now, but I want to wait until I finish Blackjack Square and I’m also going to try do something special with the games. Hopefully I can do it without too much hassle.