New Hand analysis tool

loopmeister

loopmeister

Rock Star
Silver Level
Joined
Aug 14, 2006
Total posts
332
Chips
0
Hi all,

I've been working on a hand analysis tool in my spare time (which isn't much these days). The plan is to have something that
- parses HH and stores the info in a SQL database
- allows me to extract histories, stats, profit graphs etc.
Something similar to PokerTracker or whatever you guys use. I mainly wanted to do this to get some practice in programming Python. It's still quite buggy in places, but you'll get the idea.

Any comments, thoughts, suggestions will be appreciated.

Here's a sample HH:
Code:
[FONT="Fixedsys"]
Game no. 18598873 at PiggsPeak. Played on Sun Feb 25 00:07:37 2007
Game Type - No Limit. Money Type - Sit n Go
Ante - 0, Blinds - 40/80
9 players in the hand. Player 8 is on the button.
------- Preflop -------
|Pot   0.00|       | 870.00 | Avec [small blind] Post SBs for 20.00
|Pot  20.00|       | 957.50 | Rick [big blind] Post BBs for 40.00
|Pot  60.00| 2.5:1 | 2355.00 | brand [UTG] Calls for 40.00
|Pot 100.00| 3.5:1 | 2080.00 | queendebbie [EP] Calls for 40.00
|Pot 140.00|       | 910.00 | TheStudent [MP] Folds
|Pot 140.00| 4.5:1 | 385.00 | peterc [MP] Calls for 40.00
|Pot 180.00|       | 1450.00 | Hero [2s, 5h] [LP] Folds
|Pot 180.00|       | 400.00 | Goldfingers [CO] Raises for 80.00
|Pot 260.00| 4.2:1 | 532.50 | RideTheRiver [button] Calls for 80.00
|Pot 340.00|       | 850.00 | Avec [small blind] Folds
|Pot 340.00|       | 917.50 | Rick [big blind] Raises for 80.00
|Pot 420.00| 6.2:1 | 2315.00 | brand [UTG] Calls for 80.00
|Pot 500.00|       | 2040.00 | queendebbie [EP] Raises for 2000.00
|Pot 2500.00|       | 345.00 | peterc [MP] Folds
|Pot 2500.00|       | 320.00 | Goldfingers [CO] Raises for 240.00
|Pot 2740.00|       | 452.50 | RideTheRiver [button] Raises for 372.50
|Pot 3112.50|       | 837.50 | Rick [big blind] Folds
|Pot 3112.50|       | 2235.00 | brand [UTG] Folds
------- Flop: 6s 6d 4c-------
------- Turn: (6s) (6d) (4c) 7c-------
------- River: (6s) (6d) (4c) (7c) 2c-------
-------- Showdown --------
queendebbie shows OnePair [6s 6d Ah 8s 7c]
Goldfingers shows TwoPair [8d 8h 6s 6d 7c]
loopy shows TwoPair [6s 6d 2s 2c 7c]
RideTheRiver shows OnePair [6s 6d Ac Kh 7c]
Goldfingers wins 1765.00 holding [8h, 8d]
-------- Profit Summary --------
queendebbie loses 2040.00 holding [8s, Ah]
Goldfingers wins 1180.00 holding [8h, 8d]
Avec loses 20.00 holding [__, __]
brand loses 120.00 holding [__, __]
RideTheRiver loses 187.50 holding [Kh, Ac]
Rick loses 120.00 holding [__, __]
peterc loses 40.00 holding [__, __]
Rake: 1347.50

---------- Odds analysis -----------
-------- Preflop analysis ----------
9 players in hand
Community cards: [__ __ __ __ __]
         queendebbie: [8s, Ah]   2.1%
         Goldfingers: [8h, 8d]  12.7%
               loopy: [2s, 5h]   8.6%
        RideTheRiver: [Kh, Ac]  20.0%

---------- Flop analysis ------------
3 players in hand
Community cards: [6s 6d 4c __ __]
         queendebbie: [8s, Ah]   1.1%
         Goldfingers: [8h, 8d]  77.1%
        RideTheRiver: [Kh, Ac]  21.6%

---------- Turn analysis ------------
3 players in hand
Community cards: [6s 6d 4c 7c __]
         queendebbie: [8s, Ah]   4.7%
         Goldfingers: [8h, 8d]  83.5%
        RideTheRiver: [Kh, Ac]  11.7%

---------- River analysis ------------
3 players in hand
Community cards: [6s 6d 4c 7c 2c]
         queendebbie: [8s, Ah]   0.0%
         Goldfingers: [8h, 8d] 100.0%
        RideTheRiver: [Kh, Ac]   0.0%
[/FONT]

You can also pull stats on players:
Code:
[FONT="Fixedsys"]
Preflop summary for queendebbie
Total hands: 19
Post BB           4% Raise            17%
Fold             50% Post SB           8%
Call             21% Reraise           0%
Post ante         0% Check             0%
Bet               0% Total preflop actions: 24
Tightness: 19/26%/21% (n/VIP/pfR)

Preflop summary for loopy
Total hands: 2847
Post BB          12% Raise             8%
Fold             49% Post SB          12%
Call             13% Reraise           0%
Post ante         0% Check             5%
Bet               1% Total preflop actions: 3785
Tightness: 2847/18%/10% (n/VIP/pfR)
[/FONT]

And of course, you want to see your bankroll progress:
attachment.php
 

Attachments

  • profit.jpg
    profit.jpg
    11.9 KB · Views: 84
XxJackAcexX

XxJackAcexX

Rock Star
Silver Level
Joined
Feb 22, 2007
Total posts
294
Chips
0
i've been working on something like that myself!!! sorry i can share it with you! but i'm looking to get it pattened!! looks great so far keep up the good work!!!!
 
NineLions

NineLions

Advanced beginner
Silver Level
Joined
Sep 20, 2006
Total posts
4,979
Chips
0
Very cool.

Is it mostly for programming practice, or are there some specific things lacking in the commercial programs that you want to improve on?
 
loopmeister

loopmeister

Rock Star
Silver Level
Joined
Aug 14, 2006
Total posts
332
Chips
0
Mostly for practice. I thought it'd be a cool project to learn Python with.

I don't actually have any of the commercial progs, so I'm not even sure what they do, aside from c&ps I've seen on this forum.

Oddly enough, one of the things I've picked up is that the HH from my poker site is buggy itself -- not catastrophically so, but it makes the coding that much more difficult. The site is based on Microgaming technologies; I think royal vegas uses the same software.

For what it's worth, if there are ppl out there who'd want to contribute, let me know.
 
Bombjack

Bombjack

Legend
Silver Level
Joined
Jul 6, 2006
Total posts
2,389
Chips
0
How do you calculate the win% - not a simple undertaking I imagine? I was going to write something to do that in VBA for practice but didn't get very far.
 
loopmeister

loopmeister

Rock Star
Silver Level
Joined
Aug 14, 2006
Total posts
332
Chips
0
There's a python library called pokereval - based on the C library of the same name. This means it's really fast. I do Monte Carlo simulations of 50000 (i.e. simulate 50000 hands of poker and see who wins each time) which is enough to get within 1% of the true value.
 
Bombjack

Bombjack

Legend
Silver Level
Joined
Jul 6, 2006
Total posts
2,389
Chips
0
Aha - the Monte Carlo method. I have to say, I'd never use a Monte Carlo based hand evaluator. Why use one that gives different results every time when there are ones that can do it analytically? I imagine the analytical ones do it by looking to see which hand is ahead and then calculating the number of outs on each street. By no means simple to program but probably an interesting little project.
 
loopmeister

loopmeister

Rock Star
Silver Level
Joined
Aug 14, 2006
Total posts
332
Chips
0
Aha - the Monte Carlo method. I have to say, I'd never use a Monte Carlo based hand evaluator. Why use one that gives different results every time when there are ones that can do it analytically? I imagine the analytical ones do it by looking to see which hand is ahead and then calculating the number of outs on each street. By no means simple to program but probably an interesting little project.

The answer is simple: On my little 1.8GHz machine, doing an exhaustive search pre-flop with just 2 players with hidden hole cards takes over an hour.

50k simulations gets me close enough to the real answer in a fraction of a second. If it's 0.3% out, I don't care; the variance in poker is WAY more than that.
 
Bombjack

Bombjack

Legend
Silver Level
Joined
Jul 6, 2006
Total posts
2,389
Chips
0
You don't need to do an exhaustive search. Eg AA vs KK - KK can win by making 3 of a kind, a straight, or flush.

In the case of 3 of a kind (including full houses) that's 2 outs 5 times. Take away the times when an Ace hits as well, and you get the chances of KK beating AA this way. You don't have to try every possible combination - you can calculate it. I imagine it's quite tricky to program, but you don't need a fast machine. People do this kind of odds calculation in their heads all the time when playing - it's just getting a computer to do the same thing.
 
loopmeister

loopmeister

Rock Star
Silver Level
Joined
Aug 14, 2006
Total posts
332
Chips
0
AA vs KK is easy. But what about a three way pot with 9cTh vs ?? vs ?? - what are your odds of winning?
Now the flop comes QhQdJh. The problem grows combinatorially. To simplify things, in the 'analytical' approach we lump similar hands together, e.g.

88 HU against one player, you typically class your opponents hands into these categories:
Overpair, Underpair, 2 overcards, 2 undercards, 1over 1under.
In the overpair scenario, JQs has 49.4% of winning vs. AKo with 44%, but we just lump them together; and put an average number on it. This approach is fine; since a couple of % here and there aren't going to make a major difference in the short term; and that's exactly how I calculate EVs in this forum. But it's not MORE accurate than the Monte Carlo approach. And more difficult to code.

But we're digressing into technical minutae here. Bottom line: Monte Carlo does the job; it can handle the general case of n unknowns hands vs ATC easily, and it gets fast results that are accurate enough for our purposes.
 
Jack Daniels

Jack Daniels

Charcoal Mellowed
Silver Level
Joined
Mar 26, 2005
Total posts
13,414
Chips
0
Interesting project. What sites are you looking to support this for (basically, I guess, what sites do you play at, I suppose)? Depending on the sites (say pokerstars or FullTilt for example), you may be able to loan on a few copies for members to trial for you and provide feedback on for you to work on.
 
loopmeister

loopmeister

Rock Star
Silver Level
Joined
Aug 14, 2006
Total posts
332
Chips
0
You'd need to write a parser for your specific site that strips the info from the HH and dumps them in the SQL database. I've only done this for PiggsPeak, which is a MicroGames-based site, so with luck, their other sites will have the same format HH.

So the parser is totally independent of the analyser tool. (In fact my parser was initially written by a friend in Java).

I'll share the python code and SQL commands for setting up the DB under the Mozilla License if anyone is interested.

Thanks to everyone for their comments; they've been useful.
 
Starting Hands - Poker Hand Nicknames Rankings - Poker Hands
Top