Poker Copilot 3.18 Now Available

Poker Copilot 3.18 is now available to download.

What’s changed:

  • Fix for PartyPoker parsing errors when numbers are reported as “$1,73 USD” instead of “$1.73”, despite user’s locale settings
  • Added support for some new zoom poker tables
  • Fix for PokerStars Audit parser – can now cope with formatted numbers >= 1000
  • Some performance tweaks and other minor bug fixes

Known problem:

  • PartyPoker tournament hands not yet supported. There are several problems in PartyPoker’s hand history file on Mac OS X.

(And if you don’t own it yet, click here to buy Poker Copilot, securely and instantly.)

<!– This update needs to update your database. –>

Poker Real Time Odds on Mac OS X: Part 6

The continuing story of creating a tool called SeeingStars, offering real time odds for PokerStars. Read from the beginning here.

If you need to evaluate poker hands on a computer quickly and reliably, you need poker-eval. It is highly-optimised C library to evaluate poker hands. I suspect it is used by most poker software and poker rooms.

I added poker-eval to SeeingStars to evaluate hands that go to the flop, turn, and river. I use the Monte Carlo method for the flop and turn, but once the hand goes to the river, it is quick to evaluate every possible combination.

Once I added poker-eval to SeeingStars, I had real-time odds fully functioning. Here’s a video I made of a heads-up SNG I played today. with real-time odds:

As you can see, I have a proof-of-concept working. That is just the beginning of the required work. There are remaining steps to make this useful more generally, including quality control, packaging, getting a logo, producing a website, working with smaller window sizes, supporting different PokerStars room themes, tables other than heads-up tables. Then I have to decide if I should charge money for this, as a stand-alone product, or whether it belongs in PokerZebra. Can I sell it in the Mac App Store, or do sandbox restrictions get in the way? How much will this add to my workload?

Would you pay money for a fully working SeeingStars? Say 10 dollars/10 euros? Without financial incentive I’m unlikely to spend too much time finishing this proof-of-concept.

 

Learn Poker in Barcelona

My friend Valentina Pokerina is a rare combination: she plays poker well and teaches well – in five or six languages. She lives here in Barcelona and runs regular poker workshops. Mostly in Spanish, but also in English. Heck, ask her, and she’ll teach you poker in Catalan, German, or Portuguese. And French too, I think.

And if you are a poker bigwig, I bet she is willing to travel to run poker workshops.

I do, however, mostly beat her in our home games!

Poker Real Time Odds on Mac OS X: Part 5

The continuing story of creating a tool called SeeingStars, offering real time odds for PokerStars. Read from the beginning here.

Calculating odds can be time-consuming. A short-cut preflop is to use pre-calculated tables. I found a table of preflop odds for all starting hands here. I copied this into SeeingStars, and created some code to look up in this table your starting hand by # of players. It works well, and outputs as follows:

cards = hand: Jc 5s, playerCount: 2, board: : 47.1% chance of winning

But who wants to read tiny text while playing? I made a HUD-style window, found a scoreboard style typeface, and displayed the number in a large size:

Screen Shot 2012 08 28 at 6 35 43 PM

Screen Shot 2012 08 28 at 6 36 09 PM

Screen Shot 2012 08 28 at 6 37 56 PM

Not looking too bad, I think.

However this is only working preflop. After the flop, turn and/or river are revealed, it is more complicated. A look-up approach would require more than 500 billion recalculated values. Two possible approaches are

  • iterate through all opponent cards and all possible outcomes. This takes too long, so I won’t do this.
  • to sample a range of possible outcomes via the Monte Carlo method.

I think with the Monte Carlo method the odds calculated by sampled values will soon approach the actual odds. The trick is determining the amount of possible outcomes to sample that balances time constraints and accuracy.

 

Poker Real Time Odds on Mac OS X: Part 4

The continuing story of creating a tool called SeeingStars, offering real time odds for PokerStars. Read part 1, part 2, and part 3.

In the last part I showed how I turned a screenshot into a 2-bit picture, which in text form looks like this:

00000000000000000000000000
00000000011111000000000000
00000001110011110000000000
00000111100000111000000000
00001111000000111100000000
00001110000000011110000000
00011110000000011111000000
00011110000000001111000000
00011100000000001111000000
00111100000000001111000000
00111100000000001111000000
00111100000000001111100000
00111100000000000111100000
00111100000000001111000000
00111110000000001111000000
00011110000000001111000000
00011110000000001111000000
00001110000000001110000000
00001111000000011110000000
00000111100000011100000000
00000011110000111000000000
00000000111111100000000000
00000000001111000000000000
00000000001111000000000000
00000000001111100000000000
00000000001111110000000000
00000000000111111000000000
00000000000011111111000000
00000000000000011100000000
00000000000000000000000000

I played on PokerStars for a couple of hours while my embryonic program grabbed screenshots, turned it into a string of 1’s and 0’s, then saved it. I now had a corpus of screen scrapings. Using a text editor, I manually augmented the text file with the character I could see. For example, a section of the text file looks like this:

Screen Shot 2012 08 27 at 4 50 28 PM

It’s a manual way of training a computer to do optical character recognition.

Now I can compare future scraped characters to this corpus to find out what character it is.

The process of scraping doesn’t always return identical matches; sometimes the character ‘Q’ might have a couple more 1’s or a couple more 0’s. So I compare the scraped stream of 1’s and 0’s with my corpus using an “edit distance” algorithm. If the edit distance of the scraped text from an item in the corpus is no more than 4, then I count it as a match.

Let’s fire up PokerStars, play a hand, and see what SeeingStars does so far. Here’s the table:

Screen Shot 2012 08 27 at 4 56 17 PM

Here’s what SeeingStars thinks is on the table:

cards = hand: Ks 4s, playerCount: 2, board: 3c 6c 2h 2d 5h

Perfect!

I think the hard part is done. Now to turn those cards and board into real time odds. That’s coming in part 5.

 

Poker Real Time Odds on Mac OS X: Part 3

The continuing story of creating a tool called SeeingStars, offering real time odds for PokerStars. Read part 1 and part 2.

Now the tricky stuff starts: having found the PokerStars table window, how do we determine the cards? This is not an easy programming problem. To make it easier, I’ll add some constraints. For the purpose of creating proof that real time odds is possible, here are the constraints I’m imposing:

  1. Heads-up only, so that we know there are always exactly two players in the hand.
  2. Maximum window size only, which is 1320 pixels by 932 pixels.
  3. Using PokerStars’ Nova theme, with green felt, 4-color deck, using the modern-style deck:
    Screen Shot 2012 08 23 at 3 10 14 PM

These constraints can be relaxed later, once I get the basics working.

Using the window id obtained in part 2 of this series we can get the screenshot:

- (NSBitmapImageRep *)createSingleWindowShot:(CGWindowID)windowID {
CGImageRef cgImageRef = CGWindowListCreateImage(
CGRectNull,
kCGWindowListOptionIncludingWindow,
windowID,
kCGWindowImageBoundsIgnoreFraming);
NSImage *const nsImage = [[NSImage alloc] initWithCGImage:cgImageRef size:NSZeroSize];
return [[NSBitmapImageRep alloc] initWithData:[nsImage TIFFRepresentation]];
}

From the screen image we can determine the suit of a card by sampling the colour of one pixel. I used stackoverflow.com for information on finding the nearest colour to a pixel, and then map that colour to a suit.  Some reading and experimentation shows the colour’s hue is a good method for differentiating between colours:


- (NSString *)getSuit:(NSBitmapImageRep *)bitmapImageRep x:(NSInteger)x y:(NSInteger)y {
NSDictionary *hues = @{
@0.57f:@"d",
@1.0f:@"d",
@0.29f:@"c",
@0.0f:@"s"
};
CGFloat pixelHue = ([bitmapImageRep colorAtX:x + 2 y:y + 4]).hueComponent;
double smallestDiff = fabs(0.38 - pixelHue); // 0.38 is the hue of the table felt
NSString *match = nil;
for (NSNumber *hue in hues.allKeys) {
const double diff = fabs((hue.floatValue) - pixelHue);
if (diff < smallestDiff) {
smallestDiff = diff;
match = [hues objectForKey:hue];
}
}
return match;
}

What about a card’s rank? This is harder. From experience I know that “thresholding” is helpful. Thresholding turns an image into a one-bit image: every pixel becomes either black or white, on or off, according to a threshold algorithm.

I started up Pixelmator and opened a PokerStars screenshot. Using Pixelmator’s threshold effect, I found that a setting of 80% worked well.

Screen Shot 2012 08 23 at 3 46 12 PM

Most detail is gone, but the ranks of the cards are visible.

I turned this into Objective-C code:


- (BOOL)threshold:(NSColor *)color {
float value = 0.8f;
return color.redComponent > value &&
color.blueComponent > value &&
color.greenComponent > value;
}

- (void)logOneBitImage:(NSBitmapImageRep *)bitmapImageRep startX:(NSInteger)startX startY:(NSInteger)startY {
int width = 26;
int height = 30;
int ary[width * height];
for (int y = 0; y < height; y++) {
NSString *row = @"";
for (int x = 0; x < width; x++) {
NSColor *color = [bitmapImageRep colorAtX:x + startX y:y + startY];
ary[x * height + y] = [self threshold:color] ? 1 : 0;
row = [row stringByAppendingString:(ary[x * height + y]) == 0 ? @"0" : @"1"];
}
NSLog(@"row = %@", row);
}
NSLog(@" ");
}

This gives output in which you can clearly see the rank:

00000000000000000000000000
00000000011111000000000000
00000001110011110000000000
00000111100000111000000000
00001111000000111100000000
00001110000000011110000000
00011110000000011111000000
00011110000000001111000000
00011100000000001111000000
00111100000000001111000000
00111100000000001111000000
00111100000000001111100000
00111100000000000111100000
00111100000000001111000000
00111110000000001111000000
00011110000000001111000000
00011110000000001111000000
00001110000000001110000000
00001111000000011110000000
00000111100000011100000000
00000011110000111000000000
00000000111111100000000000
00000000001111000000000000
00000000001111000000000000
00000000001111100000000000
00000000001111110000000000
00000000000111111000000000
00000000000011111111000000
00000000000000011100000000
00000000000000000000000000

In the next article in this series, I’ll show how that set of 1’s and 0’s can be turned in a ‘Q’, in a reasonably fault-tolerant way.