Post
Topic
Board Gambling
Topic OP
automatic satoshicircle gambler bot -- martingale
by
AstroKev
on 13/06/2013, 22:34:27 UTC
the satoshicircle site is pretty fun to and doesn't spam the blockchain like a lot of the dice games.  after playing by hand for awhile i decided to implement a simple martingale style strategy as a php script.  as with most things bitcoin, this is pretty simple and very basic and therefore is now released into public domain.

oh and obviously, i'm not responsible for anything you lose/break/etc so use at your own risk.

i'd recommend starting small and working your way up.  you can easily get 15 "losses" in a row, so give yourself much more room than you would think you need!  enjoy!

Code:

//
// very simple bot to play a martingale strategy against satoshicircle.com
// 
// how to use:
//
// adjust martingale parameters and bailout points appropriately below.  You can change the "circle" you want to use
// or 
// sign up at: https://satoshicircle.com/?aid=843
//
// of course you're welcome to do whatever you feel like with this.
// you should read http://en.wikipedia.org/wiki/Martingale_(betting_system) 
//
// donations greatly appreciated!
//     BTC: 1LJ5qXEqveTvdFZFkvDk9MhpyDRCicLPT8
//     LTC: LcdnGybqvgfTKSV4yCscbZoDTTQiicuVw9
//


date_default_timezone_set ('America/Los_Angeles');

$AcctInfo = array ();

// $AcctInfo ['CookieFile'] = '/tmp/sc-cookies-' . posix_getpid();
// first visit https://satoshicircle.com/?aid=843 
// then you need to grab the secret out of your url and plaster it in here.


$secret 'YOUR-SECRET-GOES-HERE';

// after first bet, we only give a small increment trying 
// to win back the original bet and only a small amount.
$usebetrecovery 1;  
$betrecoverymux 1.25;

$eatnegativereturn 1// if a bet is a fractional win (between 0 and 1, like 0.25 or 0.70), reset bet series)

$bmux 2.25;      // if you lose, multiply the previous bet by this much.  
$backwalkmux 0.7;  // when reducing bets, reduce by this amount

$startbet 0.000004;
$minbet $startbet;
$bailiter 12;

$bailpctglessbalance 0.70;
//$bailpctglessbalance = 0;
// if our balance drops to this percentage below the highest balance we have seen, then stop.


$idgame 4;   
               
// 1 is the 3x circle.        9/17
               // 2 is the "5x" circle.   7/17  
               // 3 is the "10x" circle.     5/17
               // 4 is the "2x" circle.      8/17

$idbet "";
$clientseed rand (); // stick whatever you like here; change it or random or whatever.
$iter 1;
$consecerr 0;  // exit after this many consecutive errors.
$ttlbets 0;

$minbalance 0.0;
$maxbalance 1.0

$postdata sprintf ("function=getBalance&secret=%s"$secret);
GetURL ($r$AcctInfo"https://satoshicircle.com/control.php"""$postdata0);
if (
strncasecmp ($r ['response'], '{"balance"'10) == 0) {
   
$json json_decode ($r ['response'], true);
   
$curbalance $json ['balance'];
}

$startbalance $curbalance;
$highestbalance $curbalance;
$bet $startbet;

while ((
$curbalance $bet 0) && 
   (
$curbalance $minbalance) &&
   (
$curbalance $maxbalance) &&
   (
$curbalance $bet $highestbalance $bailpctglessbalance)) {

   
sleep (6);

   
$postdata sprintf ("function=getSpin&bet=%.8f&secret=%s&clientSeed=%s&idbet=%s&idgame=%s",
      
$bet$secret$clientseed$idbet$idgame);
   
GetURL ($r$AcctInfo"https://satoshicircle.com/control.php"""$postdata0);

   
$winloss '';
   if (
strncasecmp ($r ['response'], '{"spin":'8) == 0) {
      
$json json_decode ($r ['response'], true);
      if (
$json ['result'] >= 1$winloss "WIN";
      else 
$winloss "LOSE";
      
$curbalance $json ['balance'];
      if (
$curbalance $highestbalance$highestbalance $curbalance;
   } 

   if (
$startbalance 0$startbalance $json ['balance'];
   
$delta $json ['balance'] - $startbalance;

   if (
$startbalance != 0$deltapctg $delta $startbalance 100;
   else 
$deltapctg 0;

   
printf ("%s\t%s\t%s\t"date ('Y-m-d H:i:s'), ++$ttlbets$iter);
   
printf ("%.8f\t%s\t%s\t"$bet$json ['result'], $winloss);
//   printf ("%.8f\t%.4f%%\t", $delta, $deltapctg);
   
printf ("%.8f [%.8f] %.8f\t"
      
$highestbalance $bailpctglessbalance,
      
$curbalance,
      
$highestbalance);
   
printf ("%.4f%%\n"$deltapctg);


   if (
strcasecmp ($winloss'win') == 0) {
      
printf ("\n");
      
$bet $startbet;
      
$iter 1;
      
$consecerr 0;
   } else if (
strcasecmp ($winloss'lose') == 0) {
      if ((
$usebetrecovery) && ($iter == 1)) {
         
$bet *= $betrecoverymux;
      } else {
         if ((
$json ['result'] > 0) && ($json ['result'] < 1)) {
            if (
$eatnegativereturn) {
               
printf ("eating negative return bet\n");
               
$bet $startbet;
               
$iter 0;
            } else 
$bet *= $json ['result'];
         } else {
            
$bet *= $bmux;
         }
      }
      
$iter++;
      
$consecerr 0;
   } else {
      
$consecerr++;
      
$sleeptime << $consecerr;
      
printf ("consecerr=%d  sleeping: [%d]\n"$consecerr$sleeptime);
      
sleep ($sleeptime);
      if (
$consecerr 5) exit();
   }

   if (
$iter $bailiter) {
      
printf ("iter: [%d] > %d -- eating and walking backwards.\n"$iter$bailiter);
      
$bet /= $bmux;
      
$bet *= $backwalkmux;
      if (
$bet $minbetmux) {
         
printf ("iter: [%d] -- walked backward and now at minbet.  eating loss and restarting.\n"$iter);
         
$iter 1;
         
$bet $startbet;
      }
   }
}


printf ("%s\tEXIT!  curbalance=%.8f   highestbalance=%.8f  bet=%.8f   bailpoint=%.8f\n"date ('Y-m-d'), $curbalance$highestbalance$bet$highestbalance $bailpctglessbalance);


function 
GetURL (&$Response, &$AcctInfo$url$ref NULL$postdata NULL$header 1)
{
   
$Response = array ();

   
$ch curl_init();
   
curl_setopt ($chCURLOPT_URL$url);
//   curl_setopt ($ch, CURLOPT_USERAGENT, $AcctInfo ['UserAgent']);
//   curl_setopt ($ch, CURLOPT_PROXY, $AcctInfo ['ProxyIPPort']);
//   curl_setopt ($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
//   curl_setopt ($ch, CURLOPT_COOKIEFILE, $AcctInfo ['CookieFile']);
//   curl_setopt ($ch, CURLOPT_COOKIEJAR, $AcctInfo ['CookieFile']);
   
curl_setopt ($chCURLOPT_REFERER$ref);
   
curl_setopt ($chCURLOPT_RETURNTRANSFER1);
   
curl_setopt ($chCURLOPT_FOLLOWLOCATION1);
   
curl_setopt ($chCURLOPT_HEADER$header);
   
curl_setopt ($chCURLOPT_SSL_VERIFYPEER0);
   
curl_setopt ($chCURLOPT_SSL_VERIFYHOST0);
   
curl_setopt ($chCURLOPT_VERBOSEfalse);
   
curl_setopt ($chCURLOPT_CONNECTTIMEOUT10);
   
curl_setopt ($chCURLOPT_TIMEOUT30);

   
curl_setopt ($chCURLOPT_HTTPHEADER, array (
         
'Accept: */*',
         
'Accept-Language: en-us,en;q=0.5')
      );
   if (
$postdata != NULLcurl_setopt ($chCURLOPT_POSTFIELDS$postdata);

   
$Response ['response'] = curl_exec ($ch);
   
$Response ['info'] = curl_getinfo ($ch);
   
$Response ['error'] = curl_error ($ch);

//   var_dump ($Response);

   
curl_close ($ch);
}



?>



EDIT ::: Jun 18, 2003 :::
I've reworked a bit of this so that by default it is using the 50/50 circle.  Also there are a few new parameters to edit.

usebetrecovery -- if this is '1' then it will attempt a very small increase (betrecoverymux) on the second bet as an attempt to recoup only the first bet and win only a slight amount.  this is an easy way of extending the martingale stretch by one additional run.

backwalkmux -- in the event the stretch goes past bailiter, instead of restarting the entire run from scratch, the bets are instead reduced by this amount until the bet amount is less than the original starting bet.  again this helps with some recovery with a "run gone wrong"

bailpctglessbalance -- this numbers adjusts upwards as the 'maximum balance' increases and stops the bot in the event that the losses become this percentage of the largest balance seen.  For example, if you start with 0.10 BTC, and have this set as 0.70, the bot will stop if a bet were to place the balance at or below 0.07. (0.1 * 0.7).  This number will scale upwards as your balance increases, so if you went up to 0.15 BTC, this would become 0.105 (0.15 *.07) and is recalculated with each spin.


the output file format:


1) time/date
2) total bets since bot started
3) number of iterations in the current stretch
4) bet used
5) result of bet
6) whether it's considered a win or loss ('WIN/LOSE')
7) bailpoint balance [ current balance ] highest balance seen
8 ) percentage gain/loss since bot started



---

HOW TO USE:

Simple copy/paste/save the code from above and save as "scbot.php".  Edit the configuration parameters, esepecially the 'YOUR-SECRET-GOES-HERE' area.  Get a secret key by visiting https://satoshicircle.com/?aid=843 and copying the secret out of the url you see in your browser.  Of course, you can modify any of the other parameters as you like as well and begin running the bot.  To stop it, either break out or let it exit out once an exit condition is met (i.e. minimum balance or maximum balance)








Example log:

Quote
2013-06-18 23:17:26   1   1   0.00300000   2   WIN   0.07771138 [0.11101626] 0.11101626   2.7774%

2013-06-18 23:17:32   2   1   0.00300000   0   LOSE   0.07771138 [0.10801626] 0.11101626   0.0000%
2013-06-18 23:17:39   3   2   0.00375000   2   WIN   0.07823638 [0.11176626] 0.11176626   3.4717%

2013-06-18 23:17:46   4   1   0.00300000   2   WIN   0.08033638 [0.11476626] 0.11476626   6.2491%

2013-06-18 23:17:52   5   1   0.00300000   2   WIN   0.08243638 [0.11776626] 0.11776626   9.0264%

2013-06-18 23:17:59   6   1   0.00300000   .7   LOSE   0.08243638 [0.11686626] 0.11776626   8.1932%
2013-06-18 23:18:05   7   2   0.00375000   2   WIN   0.08443138 [0.12061626] 0.12061626   11.6649%

2013-06-18 23:18:12   8   1   0.00300000   0   LOSE   0.08443138 [0.11761626] 0.12061626   8.8876%
2013-06-18 23:18:19   9   2   0.00375000   2   WIN   0.08495638 [0.12136626] 0.12136626   12.3593%

2013-06-18 23:18:25   10   1   0.00300000   2   WIN   0.08705638 [0.12436626] 0.12436626   15.1366%

2013-06-18 23:18:32   11   1   0.00300000   .7   LOSE   0.08705638 [0.12346626] 0.12436626   14.3034%
2013-06-18 23:18:39   12   2   0.00375000   2   WIN   0.08905138 [0.12721626] 0.12721626   17.7751%

2013-06-18 23:18:45   13   1   0.00300000   2   WIN   0.09115138 [0.13021626] 0.13021626   20.5525%

2013-06-18 23:18:52   14   1   0.00300000   0   LOSE   0.09115138 [0.12721626] 0.13021626   17.7751%
2013-06-18 23:18:59   15   2   0.00375000   0   LOSE   0.09115138 [0.12346626] 0.13021626   14.3034%
2013-06-18 23:19:05   16   3   0.00843750   2   WIN   0.09233263 [0.13190376] 0.13190376   22.1147%

2013-06-18 23:19:12   17   1   0.00300000   2   WIN   0.09443263 [0.13490376] 0.13490376   24.8921%

2013-06-18 23:19:18   18   1   0.00300000   2   WIN   0.09653263 [0.13790376] 0.13790376   27.6694%

2013-06-18 23:19:25   19   1   0.00300000   2   WIN   0.09863263 [0.14090376] 0.14090376   30.4468%

2013-06-18 23:19:32   20   1   0.00300000   2   WIN   0.10073263 [0.14390376] 0.14390376   33.2242%

2013-06-18 23:19:38   21   1   0.00300000   2   WIN   0.10283263 [0.14690376] 0.14690376   36.0015%

2013-06-18 23:19:45   22   1   0.00300000   2   WIN   0.10493263 [0.14990376] 0.14990376   38.7789%

2013-06-18 23:19:52   23   1   0.00300000   0   LOSE   0.10493263 [0.14690376] 0.14990376   36.0015%
2013-06-18 23:19:58   24   2   0.00375000   .7   LOSE   0.10493263 [0.14577876] 0.14990376   34.9600%
eating negative return bet
2013-06-18 23:20:05   25   1   0.00300000   0   LOSE   0.10493263 [0.14277876] 0.14990376   32.1827%
2013-06-18 23:20:12   26   2   0.00375000   2   WIN   0.10493263 [0.14652876] 0.14990376   35.6544%

2013-06-18 23:20:18   27   1   0.00300000   0   LOSE   0.10493263 [0.14352876] 0.14990376   32.8770%
2013-06-18 23:20:25   28   2   0.00375000   2   WIN   0.10493263 [0.14727876] 0.14990376   36.3487%

2013-06-18 23:20:31   29   1   0.00300000   2   WIN   0.10519513 [0.15027876] 0.15027876   39.1261%

2013-06-18 23:20:38   30   1   0.00300000   2   WIN   0.10729513 [0.15327876] 0.15327876   41.9034%

2013-06-18 23:20:45   31   1   0.00300000   2   WIN   0.10939513 [0.15627876] 0.15627876   44.6808%

2013-06-18 23:20:51   32   1   0.00300000   0   LOSE   0.10939513 [0.15327876] 0.15627876   41.9034%
2013-06-18 23:20:58   33   2   0.00375000   0   LOSE   0.10939513 [0.14952876] 0.15627876   38.4317%
2013-06-18 23:21:05   34   3   0.00843750   2   WIN   0.11057638 [0.15796626] 0.15796626   46.2430%

2013-06-18 23:21:11   35   1   0.00300000   0   LOSE   0.11057638 [0.15496626] 0.15796626   43.4657%
2013-06-18 23:21:18   36   2   0.00375000   0   LOSE   0.11057638 [0.15121626] 0.15796626   39.9940%
2013-06-18 23:21:24   37   3   0.00843750   2   WIN   0.11175763 [0.15965376] 0.15965376   47.8053%

2013-06-18 23:21:31   38   1   0.00300000   0   LOSE   0.11175763 [0.15665376] 0.15965376   45.0279%
2013-06-18 23:21:38   39   2   0.00375000   0   LOSE   0.11175763 [0.15290376] 0.15965376   41.5562%
2013-06-18 23:21:44   40   3   0.00843750   .7   LOSE   0.11175763 [0.15037251] 0.15965376   39.2128%
eating negative return bet
2013-06-18 23:21:51   41   1   0.00300000   2   WIN   0.11175763 [0.15337251] 0.15965376   41.9902%

2013-06-18 23:21:58   42   1   0.00300000   2   WIN   0.11175763 [0.15637251] 0.15965376   44.7676%

2013-06-18 23:22:04   43   1   0.00300000   2   WIN   0.11175763 [0.15937251] 0.15965376   47.5449%

2013-06-18 23:22:11   44   1   0.00300000   0   LOSE   0.11175763 [0.15637251] 0.15965376   44.7676%
2013-06-18 23:22:19   45   2   0.00375000   2   WIN   0.11208576 [0.16012251] 0.16012251   48.2393%

2013-06-18 23:22:25   46   1   0.00300000   0   LOSE   0.11208576 [0.15712251] 0.16012251   45.4619%
2013-06-18 23:22:32   47   2   0.00375000   0   LOSE   0.11208576 [0.15337251] 0.16012251   41.9902%
2013-06-18 23:22:39   48   3   0.00843750   0   LOSE   0.11208576 [0.14493501] 0.16012251   34.1789%
2013-06-18 23:22:45   49   4   0.01898438   0   LOSE   0.11208576 [0.12595063] 0.16012251   16.6034%
iter: [5] > 4 -- eating and walking backwards.
2013-06-18 23:22:52   50   5   0.01328906   2   WIN   0.11208576 [0.13923969] 0.16012251   28.9062%

2013-06-18 23:22:59   51   1   0.00300000   2   WIN   0.11208576 [0.14223969] 0.16012251   31.6836%

2013-06-18 23:23:05   52   1   0.00300000   0   LOSE   0.11208576 [0.13923969] 0.16012251   28.9062%
2013-06-18 23:23:12   53   2   0.00375000   0   LOSE   0.11208576 [0.13548969] 0.16012251   25.4345%
2013-06-18 23:23:18   54   3   0.00843750   0   LOSE   0.11208576 [0.12705219] 0.16012251   17.6232%
2013-06-18   EXIT!  curbalance=0.12705219   highestbalance=0.16012251  bet=0.01898438   bailpoint=0.11208576