• entries
149
510
• views
94710

# Return of Agent Shark

223 views

I'm moving on with my Poker AI experiment. My initial entry can be found here if you'd like to catch up. It's been a while since I've looked at this code so this entry will mostly be to help me refresh and get some direction. As I've said, a poker hand is made of 4 16 bit words. Each 16 bit word represents the potential cards in a suit. This uses 13 of the 16 bits. Hand types are seen below:

0 = High Card
1 = Pair
2 = Two Pair
3 = Set
4 = Straight
5 = Flush
6 = Full House
8 = Straight Flush

I've created a function to calculate a 32 bit comparable value called the hand value. A straight flush looks like 0x00890000 in hex. Where 8 is the hand type and the rank(9) = Jack high. So we have a Jack high straight flush, not bad. The remaining ranks are not needed in this particular value as any Jack high straight flush will equate with another, thus a chopped pot.

The next step according to West (Game Developer Nov,2005) is to calculate the hand strength, a percentage value of winning, using the following algorithm:
• Create a pack of cards
• Set score to 0
• Remove the known cards (community and hole cards)
• Loop a few thousand times
• Shuffle the remaining deck
• Deal opponent's hole cards and the remaining community cards
• Evaluate all hands (using hand values) and see who has the best hand
• If agent has best hand
• Increment score by 1/number of people with same value
• Hand Strength = score/number of loops
So this is my next step. I'm thinking that other useful data could be found using this function as well. For instance we could track the number of times we make a particular hand type and form useful probability scores from this.

I'm trying to stay motivated on gamedev. It has always been a rewarding part of my life and I'd like to keep it. I'll be forcing myself to make posts, even if it's just to say blah, in an effort to keep on truckn.

It would be useful if the gamedev journals allowed categories.

## 1 Comment

You definitely should keep on truckin [grin]

Could be very interesting to add some sort of graphing/statistical reporting tool to run alongside your Poker program. Even if just as a learning tool it could be interesting to see inside the "mind" of a "perfect" player - especially graphed over time or whatnot..

Jack