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.