Three months later.

Well I’ve been living in Honolulu for almost three months now and I am completely loving it. The weather is absolutely fantastic. There hasn’t been a day that’s not T-shirt weather. The mornings are absolutely beautiful with the sun rising over the clouds and mountains instead of meekly breaking through a layer of fog like in Oakland.  Mid-day, the sun can be a bit harsh. However, under the shade, the temperature is just perfect for being outside.  Rarely does the daytime high reach over 90.  Evenings are just as perfect as well, nice for being outside but not too warm. Nights, with overnight lows in the 70s would probably be considered muggy and hot back in Oakland, but over here it’s perfect.  I haven’t needed a jacket to go outside at night.

But Honolulu is still a city and has its share of urban problems.  There’s urban blight throughout the city with decaying and dilapidated buildings next to some pretty swanky hotels. There are more than a few homeless people but it’s definitely not as bad as San Francisco.  I haven’t seen any aggressive panhandlers or anything unusually gross, like two homeless people doing the dirty deed ( I’m sure that’s only the tip of the iceberg of what happens around the Powell St. BART station back in SF.)

I splurged a bit and bought myself a new camera- basically the cheapest DSLR out there. It took me a while to get used to a lot of the settings and the first few pictures that I took were not what I expected. I also learned a lot of about white points and white balance.  I wonder if the Daylight white point setting is geared towards the sunlight of more northern latitudes since every shot I took with that setting came out decidedly on the blue side.  But I also learned how to use a gray card and fix the white balance in post-processing so I’m really having fun learning a lot of new things. Most of my Hawaii pictures are here.

As for Whirled, I haven’t really logged on in quite a while and honestly, I haven’t been playing that many games since I got here. However, we’ll see how things go once I’m all completely settled in and doing the daily grind instead of exploring new places every week.  

A week to go

Well, next week I move to Honolulu. I haven’t had time to really do anything in Whirled.  However, due to move, I have to give up my piano keyboard. I can’t take it with me:

I don’t know when I’ll be getting  another one so I really don’t think I’ll be able to do any music for Aliens Over Hawaii.

Below are three songs that would’ve served as the base for some of the stages. This is what I had when I stopped working on them many weeks ago. These are very, very, very early rough drafts- they’re basically just easy piano pieces. There’s a several bar theme that can be heard in all three songs that serves as the “Hero’s Theme”.

Song #1

Song #2

Song #3

I wanted the songs to have a driving feel to them but the mood would change from lighthearted to a more serious and darker tone depending on the stage. In the early stages, the hero is having a bit of fun killing the aliens. In the middle stages the hero realizes that it’s going to be a bit of work to get to the mothership and in the final stages the Hero’s Theme would nearly be drowned out due to the difficulty and desperation of trying to get to the mothership.

Oh well, maybe I’ll get back to it sometime later. However, that might be after I finish memorizing the ocean in Puzzle Pirates. It’s been too long since I played it.

A big move

Obviously, I haven’t been around much. Either in Whirled or here posting. There’s a good reason for that. Not only did work get quite busy, now I also have to deal with a big move. I’m moving from wonderful Oakland:

to wonderful Honolulu:

I’m very excited but I also know that it’s going to be a crazy time. I have four weeks to move to Honolulu and I’ll be busy, busy, busy dealing with relocation. I’m really looking forward to it!

Getting back on track.

Well I just finished my last trip for work for quite a while.  It also looks like I may not be moving anytime soon, so it definitely seems like I’ll have a bit more free time! I still have a few things unfinished with Aliens Over Hawaii so I’ll get back to the sound effects and music for it. I’m also going to include a Very Hard difficulty mode and a few new trophies. Now that YouTube now allows us to make captions for videos, the “Making Of” video will be a lot easier. Once that is done, I can put it out of my mind and focus on revamping the graphics for Paint Factory. After that, it’s all about making new games.

I haven’t been on Whirled much either so I have to catch up on all the new releases and games. I still don’t know exactly what Whirleds are all about but I’ll test them out and maybe make something.

And for no reason, here’s a picture of a one-legged seagull I took yesterday on the central California coast:

Taking a break

It’s been a really hectic month and it doesn’t seem like it’s going to let up. Many weeks of travel, driving all around the state, are coming up. I also have to worry about a possible move and a minor hand injury. Yikes.  So I haven’t been doing much regarding Aliens Over Hawaii.

However, I did write music for 3 of the stages but I’ve had to rewrite them a few times. There’s an 8-bar theme, the ‘hero’ theme, which I’m building the music around.  But when I heard the three songs back-to-back, that theme got to be repetitive and annoying. So I’m dialing it back and using that theme sparingly in each song instead of repeating twice or thrice.

If I start putting too much effort into these games, it starts to feel like work and I already have a job so I’m trying to get too involved so that it’s still fun.  I don’t know when I’ll be finished with updating the game or Paint Factory but we’ll see.

Auction Poker Update! Finally free from cards!

Alright, Auction Poker has been updated with new trophies and some graphical changes. Note to game designers: if you put point values in the trophies themselves, it makes it harder to change their requirements!

I wanted to reduce the requirements for meeting the poker chip trophies but it would’ve been really odd to earn a trophy that says 500K on it with only 250,000 points.

Also, I completed my four-part section on making the AI for Auction Poker. The first two posts are a bit of a rehash from the previous time I tried to do it but there’s a little more information.  It was originally a bit longer since I edited out big chunks that I thought were going to be confusing or boring.

With this update I am free from working with card games for a few months! Next, I’ll be working on some updates to Aliens Over Hawaii - mainly adding sound effects, music and an extra difficulty mode. I also want to dig down and figure out why the payout for the game seems to be quite lower than other games.  I suspect there’s a bug based on an examination of the Game Metrics.

In addition, I’ll be re-doing the “Making Of” video that I never finished. This clip was the introduction to that half-finished video. The second part of that video would’ve been this clip which showed roughly how the stages were made and where they were located on the island of Oahu.

In retrospect, I’m glad I didn’t finish that video. I don’t think it would’ve been as interesting as the new video I’ll be making. Instead of showing how the game is built, I’ll be showing the process of making the game. I’ll show the initial sketches, stages that didn’t make it into the game and other bloopers:

Well, that’s it for now. Time to make some music and sound effects.

Auction Poker AI - Part 4

PART IV - Bidding, tweaking and the Last card.

The big hole remaining in the AI was bidding.  The AI is constrained to the same limits as the player  - they have the same amount of chips, can only bid in increments of 5 chips and don’t know anybody else’s cards or know which cards are coming up. However, they do know how many cards are remaining in the deck.

Like the process for picking the cards, I tried to approach coding this process from the point of view of a person playing the game. For example, if I know that a card works really well with my hand (high affinity) then I’ll bid a lot higher than I normally would.  That was the very first step in the bidding process - the higher affinity, the higher the bid.

If I’m playing against more players, I’ll also tend to bid a bit more. Thus, the more players on the board the higher the bid will be. However, each AI player has their own personality - a high bid for one player might be 40 or 50 chips, while for another player it might be 20 chips.

After this bit of coding,  I played many games against the AI players and while I found that they were generally decent players they were still a bit too predictable. Human players would not be as predictable. They might try sneak in a win by:

  • bidding really low on a half-decent hand.
  • skipping bidding on the first round and waiting  until the second or third round.
  • randomly picking a card and see what they can build.

So I went ahead and coded all those types of behaviors into the AI and even a couple more.

The final part in coding fittingly dealt with selecting the final card. While the AI managed to get 5 cards most of the time, there were still occasions where an AI player stopped at 4 cards.

After some testing, it turned out that some of the AI personalities were still a bit too rigid - if they went for a Flush, they only bid on cards that gave them a Flush, even if that meant Booching.  If I was playing the game, I would give up the Flush and just settle for a Pair if I was about to Booch.

In Part 2, I mentioned that the AI is aware of what Condition a new card will make its hand:

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.

Most of the time, the AI selects cards that keep it in the same Condition so that the new card won’t spoil a good hand. However, a spoiled hand is better than a Booched hand.  So I added code directing the AI to allow itself to select cards of a much lower Condition if there are few cards remaining in the deck.  This also is dependent on the AI’s personality - a ‘few’ cards to one might be 5, to another it might be 15.  The AI will also increase its bid to avoid a booch.  How much it increases its bid depends on its personality as well.

So in summary, that pretty much covers how the AI in Auction Poker works. What surprised me the most was how many subjective adjustments and refinements I had to put in place. Before I began coding the AI, I thought it was going to be a matter of brute force calculations to find the best cards and bid on them. The calculations turned out to be just the very first step.

Auction Poker AI - Part 3

PART III - Resolving a bottleneck.

At this point, the AI for the computer players has a pretty good foundation. They’ll bid on the good cards and ignore cards that spoil decent hands.  However, after having a few AI players play against each other I noticed a lot of booching of this type:

They always seemed to go for the Royal Flushes and the Straight Flushes and they never bid on anything else. As a player I don’t always go for those hands; sometimes I try for a Full House or 4-of-a-Kind instead. I needed to tell the AI to try some variety in picking its hands.

However, the big problem at this point was that the AI bid on cards with the highest affinity and those  tended to be cards that made Straight Flushes and Royal Flushes.  So how would I tell the AI to try different hands?

The solution turned out to be pretty simple but it meant adding a lot more calculations and charts to the AI code. Remember that the affinity between cards is directly dependent on which hands they can make and the amount of chips each hand is worth:

If I don’t want the AI to try for the Royal Flush or a Straight Flush, then I’ll make those hands worth 0 points which will in turn affect the affinity calculation and which cards the AI will pick.

This is what happens to the affinity of suited cards when the Royal Flushes and Straight Flushes are taken out of the equation.

As can be seen on the updated chart on the right, the rank of the card in suited pairs becomes irrelevant with those two hands out of the way. To the AI, any two cards of the same suit are the same and it would try for plain Flushes instead of those higher hands.

From that point it was a simple matter of zeroing certain hands so the AI would bid on the others. For example, zeroing out all the Flushes and Straights meant that the AI’s would try for Full Houses, Three-of-a-Kinds and Four-of-a-Kinds.

I also started to give each AI player its own personality - some of them will go for the highest hands all the time and others will switch between trying for Full Houses and Straight Flushes every other round.

At this point, the AI is working fairly well but I still needed to add a bit more personality to iron out some kinks. In addition, while the AI pretty much knew which cards to bid on, it still wasn’t very smart on figuring out how much to bid. On to Part 4.

Auction Poker AI - Part 2

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.

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.