Pages:
Author

Topic: Satoshi Roulette Martingale Bot - update 2 - page 3. (Read 7595 times)

sr. member
Activity: 364
Merit: 252
February 12, 2013, 10:40:24 PM
#13
There a difference between features and correct programming, I made that clear sorry

Oh so this is you poorly attempting to be clever ?, cute :3
legendary
Activity: 2940
Merit: 1333
February 12, 2013, 04:01:58 PM
#12
when all has to do is add to the very top of the file...
Code:
#!/bin/php

but:

Code:
$ ls -l /bin/php
ls: cannot access /bin/php: No such file or directory

Better to use:

Code:
#!/usr/bin/env php

so it'll work wherever php is in your path.
legendary
Activity: 1498
Merit: 1000
February 12, 2013, 02:10:44 PM
#12
how does one get out of this loop?

Code:
while(1)
{
...
}

perhaps some expansion on that while condition would be a good idea


Good question and here is your answer:
CTRL+C
We will be releasing an updated bot shortly that will exit the main loop on user set conditions such as:

* Hit Target Profit
* Hit min balance.
* Jackpot Collected.

But as the current bot is fully functional, we felt releasing in its current state is fine as users can begin modifying it to suite their needs.
The bot also serves a secondary purpose of demonstrating our JSON API, eg finding address, min and max bets for specified game.


You do know you have no breaks, and one exit() that is after the while loop, so this would be an infinite loop

Sorry I thought I made it clear before this is a demonstration bot, it is fully functional but requires manual interruption.
As already said, an updated version is in the works with more features such as the ones you mentioned.


There a difference between features and correct programming, I made that clear sorry
legendary
Activity: 2940
Merit: 1333
February 12, 2013, 02:54:08 PM
#11
There a difference between features and correct programming, I made that clear sorry

It's not incorrect to write an infinite loop.

The exit; after the infinite loop will never be reached, but that doesn't matter.

The script as it stands will play forever, or until you lose all your coins, or until you interrupt it with a control-C - whichever comes first.
member
Activity: 117
Merit: 10
Not only FUD :)
February 12, 2013, 02:06:39 PM
#10

 get this warning in my error logs and wanted to know how to correct this issues in my code.

Warning: PHP Notice: Undefined property: stdClass::$balance in script.php on line 33


$balance = $json->{'balance'} / 100000000; // line 33

sr. member
Activity: 364
Merit: 252
February 12, 2013, 01:48:02 PM
#9
how does one get out of this loop?

Code:
while(1)
{
...
}

perhaps some expansion on that while condition would be a good idea


Good question and here is your answer:
CTRL+C
We will be releasing an updated bot shortly that will exit the main loop on user set conditions such as:

* Hit Target Profit
* Hit min balance.
* Jackpot Collected.

But as the current bot is fully functional, we felt releasing in its current state is fine as users can begin modifying it to suite their needs.
The bot also serves a secondary purpose of demonstrating our JSON API, eg finding address, min and max bets for specified game.


You do know you have no breaks, and one exit() that is after the while loop, so this would be an infinite loop

Sorry I thought I made it clear before this is a demonstration bot, it is fully functional but requires manual interruption.
As already said, an updated version is in the works with more features such as the ones you mentioned.

We had some issues with the newly added coin TRC which has now been resolved, this has unfortunately delayed work on the bot Sad
But do not worry there will be an updated release on git soon, unless someone else forks it first Smiley
legendary
Activity: 1498
Merit: 1000
February 12, 2013, 03:49:53 AM
#9
how does one get out of this loop?

Code:
while(1)
{
...
}

perhaps some expansion on that while condition would be a good idea


Good question and here is your answer:
CTRL+C
We will be releasing an updated bot shortly that will exit the main loop on user set conditions such as:

* Hit Target Profit
* Hit min balance.
* Jackpot Collected.

But as the current bot is fully functional, we felt releasing in its current state is fine as users can begin modifying it to suite their needs.
The bot also serves a secondary purpose of demonstrating our JSON API, eg finding address, min and max bets for specified game.

You do know you have no breaks, and one exit() that is after the while loop, so this would be an infinite loop, you should at least have $flag variable to set to false so the while loop can be stopped, this is like programming 101.

But very smart by you so they bet and lose all there funds, I see you are not a dumb one in that area.
sr. member
Activity: 364
Merit: 252
February 12, 2013, 01:11:34 AM
#8
https://github.com/satoshiroulette/bot

in case others would like to contribute to the bot Smiley
sr. member
Activity: 364
Merit: 252
February 10, 2013, 10:51:52 PM
#7
how does one get out of this loop?

Code:
while(1)
{
...
}

perhaps some expansion on that while condition would be a good idea


Good question and here is your answer:
CTRL+C
We will be releasing an updated bot shortly that will exit the main loop on user set conditions such as:

* Hit Target Profit
* Hit min balance.
* Jackpot Collected.

But as the current bot is fully functional, we felt releasing in its current state is fine as users can begin modifying it to suite their needs.
The bot also serves a secondary purpose of demonstrating our JSON API, eg finding address, min and max bets for specified game.
hero member
Activity: 812
Merit: 1000
February 10, 2013, 10:43:33 PM
#6
how does one get out of this loop?

Code:
while(1)
{
...
}

perhaps some expansion on that while condition would be a good idea
sr. member
Activity: 364
Merit: 252
February 10, 2013, 10:37:04 PM
#5
no you do not Smiley, the game address is loaded from our JSON api Cheesy
eg: http://satoshiroulette.com/api.php?game=jdice-050

As are the min and maximum bets etc Smiley

I see.  Sorry, I misunderstood.

No problem at all, as one of the more prominent scripters in this area we are flattered to have you look over the bot and welcome any feedback you can offer.
legendary
Activity: 2940
Merit: 1333
February 10, 2013, 10:08:00 PM
#4
no you do not Smiley, the game address is loaded from our JSON api Cheesy
eg: http://satoshiroulette.com/api.php?game=jdice-050

As are the min and maximum bets etc Smiley

I see.  Sorry, I misunderstood.
sr. member
Activity: 364
Merit: 252
February 10, 2013, 08:18:09 PM
#3
Simply edit the settings in the section marked user defined settings and then run.

I think you need to edit this line too:

Quote
$address      = '';

Maybe it should be in the user defined settings section.

no you do not Smiley, the game address is loaded from our JSON api Cheesy
eg: http://satoshiroulette.com/api.php?game=jdice-050

As are the min and maximum bets etc Smiley
legendary
Activity: 2940
Merit: 1333
February 10, 2013, 03:29:17 PM
#2
Simply edit the settings in the section marked user defined settings and then run.

I think you need to edit this line too:

Quote
$address      = '';

Maybe it should be in the user defined settings section.
sr. member
Activity: 364
Merit: 252
February 10, 2013, 08:47:26 AM
#1
Presenting Codemonkeys php martingale bot:

A working bot and a good demonstration of our JSON API.

it supports blockchain.info, bitcoind, litecoind, ppcoind and terracoind Smiley
you do need to download the file: jsonRPCClient.php and place it in the same directory as this script for JSON calls to work.
Simply edit the settings in the section marked user defined settings and then run.

I am currently using it myself to test the new terracoin.

Install:

Linux

install php.
create bot.php in your home directory.
Code:
# cd
# php ./bot.php

Windows

Download and install the latest PHP windows installer:
http://windows.php.net/downloads/releases/php-5.3.21-nts-Win32-VC9-x86.msi

Install and follow the prompts, note optional web server component is not required.

create the file bot.api in c:\ (or a directory of your chosing).
open command prompt.
Code:
# cd \
# PHP bot.api


Configure:

You must have the following in your bitcoin.conf, set your own password and username.

Code:
server=1
rpcpassword=password
rpcuser=user

then edit bot.php and adjust this section to match:

Code:
# -----------------------------------------------------------------------------
# Begin user defined settings
# -----------------------------------------------------------------------------

# SNIP All user settings go here :) see main code block below.

# -----------------------------------------------------------------------------



Bot:

Code:
# *****************************************************************************
# Satoshi Roulette Bot
# *****************************************************************************
#
# references:
# https://bitcointalk.org/index.php?topic=137519.msg1512149#msg1512149
# http://blockchain.info/api/blockchain_wallet_api

include './jsonRPCClient.php';

global 
$address;
global 
$address_old;
global 
$bet;
global 
$min;
global 
$max;
global 
$max_old;
global 
$jackpot;
global 
$sleep;
global 
$user;
global 
$password;
global 
$coind;
global 
$blockchain;
global 
$turbo;

# -----------------------------------------------------------------------------
# Begin user defined settings
# -----------------------------------------------------------------------------

$turbo 0; # enable turbo mode, for fast result checking using the latest recieved bitcoind txid.

# list of games to bet against.

$games = array("roulette-red""roulette-black""roulette-odd""roulette-even""jdice-052""coinflip-heads""coinflip-tails""roulette-1to18""roulette-19to36");

# exit settings
$percent_win 100; # what % wallet increase to stop at
$percent_lose 50; # what % wallet decrease to stop at

# bot settings
$mode 'TRC'; # mode: BTC/ LTC/ PPC
$blockchain 0; # 1 for using blockchain.info wallets, set mode to BTC
$min 0.025; # if lower than the games min, the games min is used
$max 100; # if higher than the games max, the games max is used
$goto_max 1; # if the next bet greater than the games max bet, bet max. Used for collecting jackpots.

# bitcoind/ litecoind/ trcoind rpc connection settings
$ip '127.0.0.1'; # coind ip
$user 'user'; # coind rpc user
$password 'password'; # coind rpc password
$port 8866; # coind rpc port

# misc settings
$x 2; # when a bet loses, the next bet = $bet * $x;
$sleep 10; # sleep time: 10 seconds is optimal, 5 or lower for turbo.

# -----------------------------------------------------------------------------
# End user defined settings
# -----------------------------------------------------------------------------

$bet 0;
$json_coind_url "http://$user:$password@$ip:$port/";
$game_name $games[0]; # start with first game in array
$balance 0;
$jackpot 0;
$address_old '';
$gweedo 1;
$json_coind_url "http://$user:$password@$ip:$port/";
$address '';

# *****************************************************************************
# Start
# *****************************************************************************

if(!$blockchain# connect to coind via rpc if not using blockchain.info api
{
$coind = new jsonRPCClient($json_coind_url);
}

$start_balance $balance sprintf("%.4f"check_balance());
$win_balance sprintf("%.4f"$start_balance * ((100+$percent_win) / 100));
$lose_balance sprintf("%.4f"$start_balance * ((100-$percent_lose) / 100));

check_last();

echo 
"===============================================================================
Satoshi Roulette - Martingale Bot - Mode 
$mode
===============================================================================

Target Balance:
$win_balance $mode
Start Balance :
$start_balance $mode
Stop Balance  :
$lose_balance $mode
"
;

if(
$turbo == 1)
{
echo 
"\nTURBO MODE\n";
}

echo 
"
-----------------------------------------------------------------------------

"
;

# load game info
$rand_keys array_rand($games2); $game_name $games[$rand_keys[0]]; 
$s load_game($mode$game_name);
if(!
$bet) { $bet $min; }

while(
1)
{
# send bet
$bet_txid send_bet($bet$address);
echo date("H:i:s: "time())  . "Balance: " sprintf("%.4f"$balance) . $mode, txid: $bet_txid, bet: " sprintf("%.4f"$bet) . $mode on $game_name ";

# wait for result
$result  = get_result($mode$bet_txid$game_name);

# pre select next game
$rand_keys array_rand($games2); $game_name $games[$rand_keys[0]]; $s load_game($mode$game_name);

# check win / lose
if($result) # WIN
{
#echo $win_string;
echo " WIN\n";
$bet $min;
}
else # LOSE
{
echo " LOSE\n";
$bet sprintf("%.8f"$bet $x);
if($bet $max)
{
echo "[Hit Wall - Reseting]\n";
$bet $min;
}
else if($goto_max && $bet $x $max)
{
$bet $max;
}
}

# -----------------------------------------------------------------------------
# check exit :3
# -----------------------------------------------------------------------------

$balance check_balance();

if($balance $start_balance * (100-$percent_lose) / 100) # loss exit
{
echo "Exiting, Balance $balance is $percent_lose % lower than start balance $start_balance\n";
exit;
}
if($balance $start_balance * (100+$percent_win) / 100  # profit exit
{
echo "Exiting, Balance $balance is $percent_win % higher than start balance $start_balance\n";
exit;
}
}
exit;

# *****************************************************************************
# done
# *****************************************************************************

# -----------------------------------------------------------------------------
# Load Game

function load_game($mode$game_name)
{
$GLOBALS['jackpot'] = 0;

while(1)
{
$tmp file_get_contents("http://satoshiroulette.com/api.php?game=$game_name&mode=$mode");
$game json_decode($tmp);

if( isset($game->{'address'}) )
{
break;
}
else
{
print "JSON Reply:\n$tmp\n";
sleep(10);
}

}
$GLOBALS['address'] $game->{'address'} ;

if(isset($game->{'jackpot'}))
{
$GLOBALS['jackpot'] = sprintf("%.8f"$game->{'jackpot'});
}
if($GLOBALS['min'] < $game->{'min_bet'} || !$GLOBALS['min'])
{
$GLOBALS['min'] = $game->{'min_bet'} ;
}
if($GLOBALS['min'] > $game->{'max_bet'})
{
$GLOBALS['min'] = $game->{'min_bet'} ;
}
if($GLOBALS['max'] > $game->{'max_bet'} || !$GLOBALS['max'])
{
$GLOBALS['max'] = $game->{'max_bet'};
}
}

# -----------------------------------------------------------------------------
# Get Balance

function check_balance()
{
if($GLOBALS['blockchain'])
{
$jsonurl "https://blockchain.info/merchant/".$GLOBALS['user']."/balance?password=".$GLOBALS['password'];
$json file_get_contents($jsonurl,0,null,null);
$json json_decode($json);
return $json->{'balance'} / 100000000;
}
return $GLOBALS['coind']->getbalance('*'0);
}

# -----------------------------------------------------------------------------
# wait for bet result

function get_result($mode$bet_txid$game_name)
{
$jsonurl "http://satoshiroulette.com/log.api.php?txid=$bet_txid&mode=$mode";
$c 0;

while(! isset($r->{$game_name}))
{
$c++;

# sleep straight away as its unlikely we bitcoin travels the speed of light
sleep($GLOBALS['sleep']);

# check local wallet for latest tx
$w check_last();
if($w == 'WIN')
{
return 1;
}
else if ($w == 'LOSE')
{
return 0;
}

# check satoshiroulette.com API for win / lose
$r json_decode(file_get_contents($jsonurl));
if(isset($r->{$game_name}))
{
return $r->{$game_name};
}
if($c == 6)
{
$c 0;
print "|";
}
else
{
print "-";
}
}
}

# -----------------------------------------------------------------------------
# Bet

function send_bet($bet$address)
{
if($GLOBALS['blockchain'])
{
$b $bet 100000000;
$jsonurl "https://blockchain.info/merchant/".$GLOBALS['user']."/payment?password=".$GLOBALS['password']."&to=$address&amount=$b";
$bet_tx json_decode(file_get_contents($jsonurl,0,null,null));
return $bet_tx->{'tx_hash'};
}
return $GLOBALS['coind']->sendtoaddress($address, (float) $bet );
}

function 
check_last()
{
if($GLOBALS['blockchain'] || !$GLOBALS['turbo'])
{
return 'NULL';
}
$r $GLOBALS['coind']->listtransactions();
$l count($r) - 1;
$cat $r[$l]['category'];
$txid $r[$l]['txid'];
$amount $r[$l]['amount'];

if($cat == 'receive')
{
if($amount $GLOBALS['bet'])
{
return 'LOSE';
}
else
{
return 'WIN';
}
}
return 'NULL';
}

?>
Pages:
Jump to: