View Single Post
  #24  
Old 04-04-2007, 09:01 PM
wildzer0 wildzer0 is offline
Senior Member
 
Join Date: May 2005
Location: Balmer, hon
Posts: 2,211
Default Re: Sklansky bucks calculator (php script)

OK, here it is. Hopefully it'll be of help to someone. Instructions for getting php running are below, you'll also need a copy of pokenum (it's free) running on you system. I really have no idea how to get it running on windows, but you need it in your system path. Hopefully someone who knows more about it than I do can post a short tutorial on how to do that on windows.

It'll probably a pain in the ass for people to get running, I'll say that right now, but it does work. If anyone generous person out there feels like hosting this, that could make things easier for people too.

[ QUOTE ]


<?php
/*
ok, to use this script you need php installed. The easiest way to do this is to go to http://www.apachefriends.org/en/xampp.html
and download the windows installer. Instant php! Now you just need to edit the variables below (above the big line). Save this as luck.php

You can use the windows command line to run this script then. Just go to
start->run and type in cmd. When the windows comes up, type c:\Program Files\xampp\php\php.exe c:\path\to\luck.php
It'll spit out 3 numbers. The first number is the amount you won. The 2nd number is the amount you "should have" one
(sklansky bucks or whatever). The 3rd number is the total amount of money you put into these pots.
*/


//put your pokersite screen name here
$screen_name = "screenname";

//put the stake string here (just edit the dollar amounts to match your stake
$stake_string = "($1.00/$2.00)";

//this is the date to begin with in pokertracker, it'll go from this date to the present.
$since_date = "2007-04-04";

//connection info - put all your postgres pt db connection info into these variables.
$db_name = "PTPGSQL1";
$host = "localhost";
$user = "postgres";
$password = "password";


//***************************************DON'T EDIT BELOW THIS POINT*********************************

$conn_string = "dbname=" . $db_name ." host=" . $host . " user=" . $user . " password=" . $password;
$conn = pg_connect($conn_string);
if(!$conn) {
echo("there was an error\n");
}

$query = "select hh.hand_history, gp.hole_card_1, gp.hole_card_2, gp2.hole_card_1, gp2.hole_card_2, g.flop_1, g.flop_2, g.flop_3, g.turn, g.river, gp.pre_flop_bet, gp.flop_bet, gp.turn_bet, gp.river_bet, gp.won_hand, g.pot, gp.total_won, g.game_number, gp.total_bet
from game g
join hand_histories hh on g.game_number = hh.game_number
join game_players gp on g.game_id = gp.game_id
join game_players gp2 on g.game_id = gp2.game_id
join players p on p.player_id = gp.player_id
join players p2 on p2.player_id = gp2.player_id
where p.screen_name = '" . $screen_name . "'
and p2.screen_name != '" . $screen_name . "'
and (gp.pre_flop_bet + gp.flop_bet + gp.turn_bet + gp.river_bet >= gp.chip_count
or gp2.pre_flop_bet + gp2.flop_bet + gp2.turn_bet + gp2.river_bet >= gp2.chip_count)
and gp2.went_to_showdown_n = 1
and gp.went_to_showdown_n = 1
and g.date_played >= '" . $since_date . "'
and hh.hand_history like '%" . $stake_string . "%'
order by g.game_number";


$result = pg_query ($conn, $query);
if(!$result) {
echo("An error occured.\n");
}
$a = 0;
while($row = pg_fetch_row($result)) {
if($last_game_number == $row[17]) {
// echo("\n skipping " . $last_game_number);
} else {
$a++;
$hh = $row[0];
$my_hole_card_1 = $row[1];
$my_hole_card_2 = $row[2];
$v_hole_card_1 = $row[3];
$v_hole_card_2 = $row[4];
$flop_1 = $row[5];
$flop_2 = $row[6];
$flop_3 = $row[7];
$turn = $row[8];
$river = $row[9];
$pre_flop_bet = $row[10];
$flop_bet = $row[11];
$turn_bet = $row[12];
$river_bet = $row[13];
$i_won_hand = $row[14];
$pot = $row[15];
$total_won = $row[16];
$last_game_number = $row[17];
$total_bet = $row[18];


$exec_string = "pokenum -h " . $my_hole_card_1 . " " . $my_hole_card_2 . " - " . $v_hole_card_1 . " " . $v_hole_card_2;

if($flop_bet > 0 || $turn_bet > 0 || $river_bet > 0) {
$exec_string .= " -- " . $flop_1 . " " . $flop_2 . " " . $flop_3;
}

if($turn_bet >0 || $river_bet > 0) {
$exec_string .= " " . $turn;
}

if($river_bet > 0) {
$exec_string .= " " . $river;
}

unset($pokenum_output);
exec($exec_string, $pokenum_output);

unset($new_arr);

$line_arr = explode(" ", $pokenum_output[2]);
$arr_count = 0;
for($i=1;$i<count($line_arr);$i++) {
if(!$line_arr[$i] == "") {
$new_arr[$arr_count] = $line_arr[$i];
$arr_count++;
}
}

$sizeof_arr = sizeof($new_arr) - 1;
$ev = $new_arr[$sizeof_arr];
$equity = $ev * $pot;

$all_won += $total_won;
$all_equity += $equity;
$all_bet += $total_bet;
$total_ev += $ev;

echo("\n" . $exec_string ." ");
echo($ev);

}
}
echo("\n" . $a . " hands played with an average ev of " . $total_ev / $a);
echo("\nwon: " . $all_won);
echo("\nequity: " . $all_equity);
echo("\n total bet: " . $all_bet . "\n");

?>


[/ QUOTE ]
Reply With Quote