Two Plus Two Older Archives  

Go Back   Two Plus Two Older Archives > Tournament Poker > Multi-table Tournaments
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #11  
Old 03-23-2005, 12:38 AM
eMarkM eMarkM is offline
Senior Member
 
Join Date: Sep 2002
Location: Chicago
Posts: 1,170
Default Re: A Tournament Analyzer

Yeah, I've worked through some of this already, I have much of the object model part done. At some point I may publish the source for peer review. I can certainly publish the object model diagrams.
Reply With Quote
  #12  
Old 03-23-2005, 12:46 PM
TylerK TylerK is offline
Member
 
Join Date: Jan 2005
Posts: 42
Default Re: A Tournament Analyzer

Hackish, a little ugly, but currently useful.

------- tsplit.sh -------
#!/bin/sh

# split output into files of size $SIZE
SIZE=40000

# Make sure filename and hero name are provided on cmd line
if [ ! $1 ] || [ ! $2 ] ; then
echo "tsplit <file> <name>"
exit 1
fi

FILENAME=$1
HERO=$2

# split the file into multiple hands
# csplit doesn't like curly braces ( char{num} ) for some reason
csplit -n4 $FILENAME "/^\*\*\*\*\*/" {*} > /dev/null

# delete the hands that aren't that important
for FILE in xx* ; do
grep "$HERO.*folded before Flop (didn't bet)" $FILE >/dev/null && \
rm $FILE
done

IT=1 # output will be multiple files numbered sequentially starting with 1
for FILE in xx*
do
./bisonize.pl --results --hero $HERO $FILE | sed -e s/'color:'/'color='/
g -e s/'FFFFFF'/'000000'/g >> $FILENAME.phpbb.$IT
echo -e "\n" >> $FILENAME.phpbb.$IT
# max file size of 40k
if [ `ls -l $FILENAME.phpbb.$IT | awk '{print $5}'` -gt $SIZE ]; then
IT=$(($IT+1))
fi
done

# clean up
rm xx*

exit 0
------- tsplit.sh -------

------- bisonize.pl -------
#!/usr/bin/perl -w

use strict;

use LWP::UserAgent;
use HTML::Parser;
use Getopt::Long;

my $converter = 'http://www.selachian.com/tools/bisonconverter/hhconverter.cgi';

my $hero ='Hero';
my $hhformat = 'twoplustwo';
my $results = 1;
GetOptions( 'hero=s' => \$hero,
'hhformat=s' => \$hhformat,
'results!' => \$results);
$results ? $results = 'off' : $results = 'on';

my $filename = shift or die("You must specify the filename to bisonize.\n");

open INFILE, $filename or die("Could not open $filename\n");
my @hand_raw = <INFILE>;
close INFILE;
my $hand = join "",@hand_raw;

my $ua = LWP::UserAgent->new();

my $response = $ua->post( $converter,
[ 'MessageInput' => $hand,
'HHFormat' => $hhformat,
'HeroAlias' => $hero,
'DisplayPots' => 'on',
'HighlightStacks' => 'on',
'DisplayResults' => $results
] );

unless($response->is_success) { die("HTTP request failed\n"); }

my $result = $response->content;

my $p = HTML::Parser->new();
$p->handler(start => \&textarea_h, "tagname,self,attr");
$p->parse($result);

sub textarea_h {
return if shift ne "textarea";
my ($self, $attr) = @_;
# if the textarea is named MessageOutput,
# add a text handler
if ( $attr->{"name"} eq 'MessageOutput') {
$self->handler(text => \&temptext_h, "dtext,self");
}
}

# print text, then undef the text handler
sub temptext_h {
print shift;
my $self = shift;
$self->handler(text=>undef);
}
------- bisonize.pl -------
Reply With Quote
  #13  
Old 03-24-2005, 01:05 PM
eMarkM eMarkM is offline
Senior Member
 
Join Date: Sep 2002
Location: Chicago
Posts: 1,170
Default Object Model

Ok, here's the object model I've coded up so far. This is just the class diagram, not the source code. Basically a hierarchy starting with a tournament. Each tourney has several hands. Each hand has many players, rounds and a board. Each player has a stack, cards and position. Each round has action (bet, raise), bets, and a cummulative pot. So far in my test harness it's worked out pretty well.

Right now the test harness supplies the model with some test hands, players, actions, etc. The next step is to take that model data and have it spit out output to an HTML page. After that, it's taking a PokerStars HH and parsing that out into this model.

poker object model
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 12:34 PM.


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