Post
Topic
Board Trading Discussion
Re: PHP martingale bot for satoshiDICE
by
Sovereign108
on 07/09/2012, 19:54:36 UTC
Ok, I might as well post a modified php script. Its based on this strategy to make it safer to not loose too much btcs. I just hard coded the values for 8x betting to be used for the bets that the R script outputted (check out that link).

Lol I got broke twice now, not playing satoshidice anymore or any other game for that matter :-0

The btcs were increasing, but every so often the house would turn against me, thats the time to give yourself a short break lol

Code:
require_once('jsonRPCClient.php');
/** BITCOIN **/
$btcu = array("user" => "BitcoinRPC",             // RPC Username
            
"pass" =>   "password",               // RPC Password
            
"host" =>   "127.0.0.1",      // RPC Hostname/IP
            
"port" =>   9332);            // RPC Port
$b = new jsonRPCClient("http://{$btcu['user']}:{$btcu['pass']}@{$btcu['host']}:{$btcu['port']}");

define('MIN_BET'0.05);
define('MAX_BET'2.519995);
define('ADDRESS''1dice6YgEVBf88erBFra9BHf6ZMoyvG88');

$bet_8x=array(0.010562,0.012070,0.013795,0.015765,0.018018,0.020592,0.023533,0.026895,0.030737,0.035128,0.040147,0.045882,0.052436,0.059927,0.068488,0.078272,0.089454,0.102233,0.116838,0.133529,0.152605,0.174406,0.199321,0.227795,0.260337,0.297528,0.340033,0.388609,0.444124,0.507570,0.580081,0.662949,0.757656,0.865893,0.989592,1.130962,1.292528,1.477175,1.688200,1.929371,2.204996,2.519995,2.879994,3.291422);

$total_fees 0;
$count 0;
$count_won 0;
$current_bet_index=0;
$bet $bet_8x[0];
$total_lost=0;
while ((
$bet <= MAX_BET) && ($count_won 200))
{
        
$balance_a $b->getbalance('*'0);
        if (!isset(
$starting_balance)) $starting_balance $balance_a;
        if(
$b->getbalance('*'1) < $bet) { // If we don't have enough confirmed bitcoins to send to satoshi dice...
            
echo "Waiting for confirmed balance";
            while(
$b->getbalance('*'1) < $bet
            {
                echo 
".";
                
sleep(60); // Wait a full minute before checking the balance again.
            
}
            echo 
"\n";
        }
    
try // Wrapped in a try catch block just incase we run out of cash.
        
{
            
$b->sendtoaddress(ADDRESS, (float) $bet);
    
}
        catch(
Exception $e
        {
            echo 
"Have: " $b->getbalance('*'1) . " Needed: " $bet "\n";
    
die("Ran out of money?\n");
    
}
        
$balance_b $b->getbalance('*'0);
        
$count++;
        
$fee $balance_a $balance_b $bet;
        
$total_fees += $fee;
        
$total_fees number_format($total_fees,8,'.','')+0;

        echo 
'Game #'.$count."---------------------------------------------\n";
        echo 
"\n".'Balance:                ' $balance_a."";
        echo 
"\n".'Bet Amount Sent:        -'$bet."";
        echo 
"\n".'Fee:                    -'. (number_format($fee8'.''') +0) . "";
        echo 
"\n".'Total Fees:             -'$total_fees"";
        echo 
"\n".'Balance after bet sent: ' $balance_b "       ".'Waiting';

        
$balance_c 0;

        while (
$balance_b >= $balance_c)
        {
        sleep(4);
$balance_c $b -> getbalance('*'0);
echo '.';
        }

        echo 
"\nNew Balance:            $balance_c";

        
$diff $balance_c $balance_b;

        if (
$diff $bet)
        {
                
$bet $bet_8x[0];
                
$current_bet_index=0;
                
$count_won++;
                echo 
"\n*****Win!*****           (Won $count_won out of $count games)";
                echo 
"\nTotal lost:             ".$total_lost."";
                echo 
"\nProfit made:            ".$diff."";
                
$net_profit=$diff-$total_lost;
                echo 
"\n"."Net profit:             ".$net_profit."\n";
                
$total_lost=0;
        }
        else
        {
                echo 
"\n".'_____Lose!_____'."";
                
$total_lost += $balance_a-$balance_c;
                echo 
"\nTotal lost:             ".$total_lost."\n";
                
$bet $bet_8x[$current_bet_index++];
        }

        echo 
"\n";
}

echo 
'Starting Balance: '.$starting_balance."\n";
echo 
'Ending Balance: '$balance_c."\n";
echo 
'Total Fees: '$total_fees."\n";
$amt_won $balance_c $starting_balance;
echo 
'Net Profit: '. (number_format($amt_won,8,'.','') + 0). "\n\n";
?>