Archive for the ‘auction poker’ Category.

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.

More Bling!

I noticed that as of yesterday, game creators on Whirled are receiving Bling! Below is a shot of my first Game Bling.

One game in particular is bringing in much more bling than the others - 16 points. I don’t know for certain which one it is, but I’m pretty sure it’s Paint Factory since it is my most popular game.

Poker Square is also quite popular, much more than Cribbage square so I’m guessing that’s where the 5 points of bling came from.  Auction Poker and Cribbage Square bring up the rest. I also have Paint Factory Challenge listed but it’s not really played so I don’t really expect any real bling from it.

I’m currently working on fixing up some stuff on Auction Poker and I’ve already started writing the next two entries on the Auction Poker AI, but I just need to do cleanup before publishing.

Bling!

So Whirled came out with Bling earlier in the week and it has me quite excited! I can start making a little bit of cash while making fun stuff. I also noticed that game creators will also receive bling in the future! I’m definitely going to be spending more time creating stuff on Whirled - especially games. I have quite a lot of notes about possible games. I just have to hunker down and do them.

By this weekend, though, I’ll be releasing the flower toy along with some “seed packs” that will allow the player to pick some standard flowers instead of relying on random flowers.

In the next week or so,  I’ll also be tying up some loose ends in Auction Poker and start making Blackjack Square.

I have been thinking of Blackjack Square for a while, after all it seems like a logical extension of Poker Square and Cribbage Square. However, the problem with Blackjack is that there is no predetermined hand size - a 21 can be made with 2 cards, 5 cards or even more. Fitting them to a standard square is a bit tough.  However, a really obvious solution on how to fix this problem came to me when I was on Whirled. It was so obvious I was really surprised that it didn’t come to me earlier.

So Blackjack Square will definitely be coming before Gravitation. It’ll be a simple matter of reusing a lot of the code and graphics from Poker Square- just a weekend project. Hopefully I can have it done around the beginning of November or the end of October.

Also, here’s a screen cap of my very first bling - hopefully the first of many.  It’s worth about 2 cents!

Finally done with Auction Poker.

Well I finally listed Auction Poker after futzing around with it for a long while.  I’ve been tweaking it for such a long while that I think any bug-fixing will be minimal. In a way, it’s kind of a relief to finally get it done so I can work on some other stuff, like Gravitation. Anyways, I’ll finish up writing about the Auction Poker AI in the next few weeks.

On to Auction Poker (again)

Now that Cribbage Square is for the most part finished, I’ll be spending much more time finishing up Auction Poker. Hopefully I can get it all fixed and working within the next couple of weeks. Really, all I have to do is tweak, tweak, tweak the AI.

Also, the new Cribbage Square page is up. You can play it here too.

Cribbage Square

Well Cribbage Square has finally been listed! Now I can finish up Auction Poker which has been left in a 80% finished state. However, that’s better than Gravitation which is about 30% finished. Oh well. Now that I have some free time, I’ll definitely be working on polishing those two games up and finishing them.

A bit of fun

I’ll resume the Auction Poker AI posts once I figure out some of the last remaining issues. The AI is very good at picking cards when it is playing by itself or against just another person. However, once 4-5 computer players are brought into the mix, things start to get funky and they butt heads trying to get the same cards.  I need to tweak some settings and variables so that each computer player plays well even if there are 4 other bids on the same card.

But I’ll start doing that next week or so, it’s actually quite tedious and I need to work on something fun! So in the next few days I’m working on Cribbage Square! Here’s an early mockup just to see how I would lay things out. The scoring or the chart isn’t accurate, obviously.  I’m expecting to release this maybe late next week:

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.




A little bit of feedback

As I was fiddling with Auction Poker earlier this week, I got the idea that the player should receive a bit more feedback throughout the game. Currently, the player’s only feedback occurs at the end of each round - which cards were lost, were cards were won and which cards had their bids go up. I decided to I wanted to let the player know what the AI was up to and display the AI’s cards. I mocked up a screenshot of how that would work and this is how it came out:

That is not pretty at all!! Yuuuuuck! Of course, it’s a mockup and the cards on the side would be of a different format, geared to their small size, but it just doesn’t look good. It’s too cluttered and there’s too much information considering each round is only 10-15 seconds. Within that time, the player has to determine which cards he will bid on and how much he will bid taking into account the AI’s decisions of the previous round.

So, we’re definitely not going in that direction. I’ll stick with the 10-card format.

P.S. : The Poker Square page is now up!

Working on Auction Poker

The next game that I’ve been working on is called Auction Poker. Basically you are bidding for cards against the AI. Here’s a screenshot of the current version of the game:

I originally meant to get the multi-player version of the game done first but multi-player debugging is quite tedious at the moment so I decided to focus on the solo version. Currently, I’m working on developing the AI.

However, when I was browsing a card games rule-book at the bookstore today I came upon a game called Poker Square. I immediately thought that I could make this game with minimal effort right now - I have the card artwork done and the script for processing poker hands.

I think you might see Poker Square in Whirled in the very near future. ;)