#1
|
|||
|
|||
stars hh parser (perl script)
I wrote the following perl script to parse stars hand histories. It should work on all cash games they spread. Make sure to pass in one file at a time and to place your nick at the top of the script.
Sorry about the spacing. I can't figure out how to post lines starting with spaces. #!/usr/bin/perl use strict; use warnings; # replace below with your stars name my $me = 'ArtVandelay'; my $table_type; my $table_name; my $start_time; my $end_time; my %action; my $bb; my $invested; my $collected; my $ignore; my $prev = 0; my $pnl = 0; my $hands = 0; while (my $line = <> { if ($line =~ /^PokerStars Game \#(\d+):\s*(\w.*) \((.*)\) - (.*) - (.*) \(ET\)/) { $ignore = 1; $ignore = 0 if $1 > $prev; $prev = $1; die 'type changed' if $table_type && $table_type ne "$2 $3"; $table_type = "$2 $3"; $start_time = "$4 $5" unless $start_time; $end_time = "$4 $5"; %action = (); $bb = 0; $invested = 0; $collected = 0; } if ($line =~ /^Table \'(.*)\'/) { die 'table name changed' if $table_name && $table_name ne $1; $table_name = $1; } if ($line =~ /^(.+): raises \$([0-9\.]*) to \$([0-9\.]*)/) { $action{$1} = $3; } if ($line =~ /^(.+): (bets|brings-in low) \$([0-9\.]*)/) { die 'bad action' if $action{$1}; $action{$1} = $3; } if ($line =~ /^(.+): calls \$([0-9\.]*)/) { $action{$1} += $2; } if ($line =~ /^(.+): posts small blind \$([0-9\.]*)/) { $action{$1} = $2; $invested += $2 if $bb && $1 eq $me; } if ($line =~ /^(.+): posts big blind \$([0-9\.]*)/) { $bb = $2; $action{$1} = $bb; } if ($line =~ /^(.+): posts small & big blinds \$([0-9\.]*)/) { $action{$1} = $bb; $invested += $2 - $bb if $1 eq $me; } if ($line =~ /^$me: posts the ante \$([0-9\.]*)/) { $invested += $1; } if ($line =~ /\*\*\* (FLOP|TURN|RIVER|SHOW DOWN|SUMMARY|4th STREET|5th STREET|6th STREET) \*\*\*/ || $line =~ /stands pat|discards \d card/) { if ($action{$me}) { my $matched = 0; foreach my $player (keys %action) { next if $player eq $me; $matched = $action{$player} if $action{$player} > $matched; } $matched = $action{$me} if $matched > $action{$me}; $invested += $matched; } %action = (); if (!$ignore && $line =~ /SUMMARY/) { $pnl += $collected - $invested; $hands++; } } if ($line =~ /$me collected \$([0-9\.]*)/) { $collected += $1; } } print "type: $table_type\nname: $table_name\nstart: $start_time\nend: $end_time\npnl: $pnl\nhands: $hands\n"; |
#2
|
|||
|
|||
Re: stars hh parser (perl script)
[ QUOTE ]
Sorry about the spacing. I can't figure out how to post lines starting with spaces. [/ QUOTE ] |
#3
|
|||
|
|||
Re: stars hh parser (perl script)
<font class="small">Code:</font><hr /><pre>
#!/usr/bin/perl use strict; use warnings; # replace below with your stars name my $me = 'ArtVandelay'; my $table_type; my $table_name; my $start_time; my $end_time; my %action; my $bb; my $invested; my $collected; my $ignore; my $prev = 0; my $pnl = 0; my $hands = 0; while (my $line = <> { if ($line =~ /^PokerStars Game \#(\d+):\s*(\w.*) \((.*)\) - (.*) - (.*) \(ET\)/) { $ignore = 1; $ignore = 0 if $1 > $prev; $prev = $1; die 'type changed' if $table_type && $table_type ne "$2 $3"; $table_type = "$2 $3"; $start_time = "$4 $5" unless $start_time; $end_time = "$4 $5"; %action = (); $bb = 0; $invested = 0; $collected = 0; } if ($line =~ /^Table \'(.*)\'/) { die 'table name changed' if $table_name && $table_name ne $1; $table_name = $1; } if ($line =~ /^(.+): raises \$([0-9\.]*) to \$([0-9\.]*)/) { $action{$1} = $3; } if ($line =~ /^(.+): (bets|brings-in low) \$([0-9\.]*)/) { die 'bad action' if $action{$1}; $action{$1} = $3; } if ($line =~ /^(.+): calls \$([0-9\.]*)/) { $action{$1} += $2; } if ($line =~ /^(.+): posts small blind \$([0-9\.]*)/) { $action{$1} = $2; $invested += $2 if $bb && $1 eq $me; } if ($line =~ /^(.+): posts big blind \$([0-9\.]*)/) { $bb = $2; $action{$1} = $bb; } if ($line =~ /^(.+): posts small & big blinds \$([0-9\.]*)/) { $action{$1} = $bb; $invested += $2 - $bb if $1 eq $me; } if ($line =~ /^$me: posts the ante \$([0-9\.]*)/) { $invested += $1; } if ($line =~ /\*\*\* (FLOP|TURN|RIVER|SHOW DOWN|SUMMARY|4th STREET|5th STREET|6th STREET) \*\*\*/ || $line =~ /stands pat|discards \d card/) { if ($action{$me}) { my $matched = 0; foreach my $player (keys %action) { next if $player eq $me; $matched = $action{$player} if $action{$player} > $matched; } $matched = $action{$me} if $matched > $action{$me}; $invested += $matched; } %action = (); if (!$ignore && $line =~ /SUMMARY/) { $pnl += $collected - $invested; $hands++; } } if ($line =~ /$me collected \$([0-9\.]*)/) { $collected += $1; } } print "type: $table_type\nname: $table_name\nstart: $start_time\nend: $end_time\npnl: $pnl\nhands: $hands\n"; </pre><hr /> |
#4
|
|||
|
|||
Re: stars hh parser (perl script)
what does it do?
|
#5
|
|||
|
|||
Re: stars hh parser (perl script)
thanks dcasper
[ QUOTE ] what does it do? [/ QUOTE ] you pass it a raw stars hand history file as input, and it spits out various stats including number of hands played and dollar win/loss I mainly use it to track my results in games not supported by PT |
#6
|
|||
|
|||
Re: stars hh parser (perl script)
a comprehensible list of perl script to parse different HH can be found at sourcefouge
|
#7
|
|||
|
|||
Re: stars hh parser (perl script)
[ QUOTE ]
a comprehensible list of perl script to parse different HH can be found at sourcefouge [/ QUOTE ]URL? [img]/images/graemlins/smile.gif[/img] |
|
|