#11
|
|||
|
|||
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.
|
#12
|
|||
|
|||
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 ------- |
#13
|
|||
|
|||
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 |
|
|