Two Plus Two Newer Archives  

Go Back   Two Plus Two Newer Archives > Internet Gambling > Software
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 11-21-2006, 05:13 AM
ArtVandelay ArtVandelay is offline
Senior Member
 
Join Date: Jul 2003
Posts: 440
Default 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 = <&gt {
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";
Reply With Quote
  #2  
Old 11-21-2006, 09:32 AM
dcasper70 dcasper70 is offline
Senior Member
 
Join Date: Mar 2005
Location: Life Has Come From My Balls
Posts: 3,526
Default Re: stars hh parser (perl script)

[ QUOTE ]
Sorry about the spacing. I can't figure out how to post lines starting with spaces.

[/ QUOTE ]
Reply With Quote
  #3  
Old 11-21-2006, 09:33 AM
dcasper70 dcasper70 is offline
Senior Member
 
Join Date: Mar 2005
Location: Life Has Come From My Balls
Posts: 3,526
Default 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 = &lt;&gt {
if ($line =~ /^PokerStars Game \#(\d+):\s*(\w.*) \((.*)\) - (.*) - (.*) \(ET\)/) {
$ignore = 1;
$ignore = 0 if $1 &gt; $prev;
$prev = $1;
die 'type changed' if $table_type &amp;&amp; $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 &amp;&amp; $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 &amp;&amp; $1 eq $me;
}
if ($line =~ /^(.+): posts big blind \$([0-9\.]*)/) {
$bb = $2;
$action{$1} = $bb;
}
if ($line =~ /^(.+): posts small &amp; 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} &gt; $matched;
}
$matched = $action{$me} if $matched &gt; $action{$me};
$invested += $matched;
}
%action = ();
if (!$ignore &amp;&amp; $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 />
Reply With Quote
  #4  
Old 11-21-2006, 10:13 AM
vortex86 vortex86 is offline
Senior Member
 
Join Date: Feb 2006
Posts: 805
Default Re: stars hh parser (perl script)

what does it do?
Reply With Quote
  #5  
Old 11-21-2006, 10:23 AM
ArtVandelay ArtVandelay is offline
Senior Member
 
Join Date: Jul 2003
Posts: 440
Default 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
Reply With Quote
  #6  
Old 11-21-2006, 11:18 AM
JackStrap JackStrap is offline
Member
 
Join Date: Jan 2004
Posts: 84
Default Re: stars hh parser (perl script)

a comprehensible list of perl script to parse different HH can be found at sourcefouge
Reply With Quote
  #7  
Old 11-21-2006, 02:29 PM
rjp rjp is offline
Senior Member
 
Join Date: Sep 2006
Location: Charleston, SC
Posts: 1,115
Default 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]
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 01:23 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.