Login Register






Thread Rating:
  • 1 Vote(s) - 5 Average


[Mathematics] H@x0r1ng the Betting System filter_list
Author
Message
[Mathematics] H@x0r1ng the Betting System #1
A while back, @"Lux" taught me a betting strategy that supposedly guaranteed big wins. I decided at the time to simulate it a million times in python and look at my winnings. What I found was surprising.

The technique is as follows: You have a starting amount, and your starting bet. Your starting bet is usually the square root of or just 10% of your starting money. You place a bet. If you lose, your bet amount doubles, and if you win, your betting amount is reset to the original.

Code:
from random import randint

def placeBet():
    return randint(0, 1)

balance = 100
starting_bet = balance / 10
current_bet = starting_bet

for x in range(1000000): #1000000 bets
    stat = placeBet()
    if stat == 0: #lose
        balance -= current_bet
        current_bet += current_bet
    if stat == 1: #win
        balance += current_bet
        current_bet = starting_bet

print balance

This consistently showed a massive profit and basically proved that @"Lux"'s method was legit. Or did it? Let's try with a smaller scale and verbose output.

Code:
from random import randint

def placeBet():
    return randint(0, 1)

balance = 100
starting_bet = balance / 10
current_bet = starting_bet

for x in range(100): #100 bets
    stat = placeBet()
    if stat == 0: #lose
        balance -= current_bet
        current_bet += current_bet
        print "Lost! New Balance: %s New Betting Amount: %s" % (str(balance), str(current_bet))
    if stat == 1: #win
        balance += current_bet
        current_bet = starting_bet
        print "Won! New Balance: %s New Betting Amount: %s" % (str(balance), str(current_bet))

Running that, placing 100 bets, gives us an interesting set of results. Here's a snippet:

Quote:Won! New Balance: 110 New Betting Amount: 10
Won! New Balance: 120 New Betting Amount: 10
Lost! New Balance: 110 New Betting Amount: 20
Lost! New Balance: 90 New Betting Amount: 40
Lost! New Balance: 50 New Betting Amount: 80
Lost! New Balance: -30 New Betting Amount: 160
Lost! New Balance: -190 New Betting Amount: 320
Lost! New Balance: -510 New Betting Amount: 640

Won! New Balance: 130 New Betting Amount: 10
Won! New Balance: 140 New Betting Amount: 10
Won! New Balance: 150 New Betting Amount: 10

What happened on those lines is that the computer lost the previous bet and went into negatives. This basically means that the computer cannot make the next bet as it does not have the necessary balance in order to do so. But the bet amount was still as normal doubling, so it was inevitable that it'd win and get back into positive balance. Basically, it "borrowed" money in order to place bets when it didn't have enough. We can take away the total borrowed from the end balance at the end to get the profit.

Code:
from random import randint

def placeBet():
    return randint(0, 1)

balance = 100
starting_bet = balance / 10
current_bet = starting_bet
owed = 0

for x in range(50): #50 bets
    stat = placeBet()
    if stat == 0: #lose
        balance -= current_bet
        current_bet += current_bet
        print "Lost! New Balance: %s New Betting Amount: %s" % (str(balance), str(current_bet))
    if stat == 1: #win
        balance += current_bet
        current_bet = starting_bet
        print "Won! New Balance: %s New Betting Amount: %s" % (str(balance), str(current_bet))
    if current_bet > balance:
        owed += current_bet - balance

print "Owed: %s" % str(owed)
print "Profit: %s" % str(balance - owed)

This seemed to work:

Quote:Owed: 250
Profit: 140

Except when it didn't:

Quote:Owed: 1650
Profit: -1370

Now, if we didn't factor in the borrowing, that would have shown up as a profit as the end balance was 280. The negative impact of the borrowing can be properly appreciated with more bets. Here's a set of results at a million bets. Note that although the balance is massive, the computer borrowed a fuck tonne of money each time, and so overall lost money.

Quote:Balance: 5000950
Owed: 78008950
Profit: -73008000

Balance: 5000610
Owed: 176100380
Profit: -171099770

Balance: 4994280
Owed: 89699620
Profit: -84705340

Of course, in the betting system that we have here at SL, we can't really feasibly borrow that much money. So let's add validation to check if the current_bet is more than the balance, or if the balance is less than 0, and to stop betting in both instances.

Code:
from random import randint

def placeBet():
    return randint(0, 1)

balance = 100
starting_bet = balance / 10
current_bet = starting_bet

for x in range(50): #50 bets
    stat = placeBet()
    if stat == 0: #lose
        balance -= current_bet
        current_bet += current_bet
        print "Lost! New Balance: %s New Betting Amount: %s" % (str(balance), str(current_bet))
    if stat == 1: #win
        balance += current_bet
        current_bet = starting_bet
        print "Won! New Balance: %s New Betting Amount: %s" % (str(balance), str(current_bet))
    if current_bet > balance or balance < 0:
        print "Failed! You're bankrupt. Balance: %s" % str(balance)
        break

Sometimes stuff like this happened:

Quote:Won! New Balance: 110 New Betting Amount: 10
Lost! New Balance: 100 New Betting Amount: 20
Lost! New Balance: 80 New Betting Amount: 40
Lost! New Balance: 40 New Betting Amount: 80
Failed! You're bankrupt. Balance: 40

Where the computer went bankrupt very quickly. Sometimes it took a while:

Quote:Won! New Balance: 110 New Betting Amount: 10
Won! New Balance: 120 New Betting Amount: 10
Won! New Balance: 130 New Betting Amount: 10
Won! New Balance: 140 New Betting Amount: 10
Won! New Balance: 150 New Betting Amount: 10
Won! New Balance: 160 New Betting Amount: 10
Lost! New Balance: 150 New Betting Amount: 20
Won! New Balance: 170 New Betting Amount: 10
Won! New Balance: 180 New Betting Amount: 10
Won! New Balance: 190 New Betting Amount: 10
Lost! New Balance: 180 New Betting Amount: 20
Won! New Balance: 200 New Betting Amount: 10
Won! New Balance: 210 New Betting Amount: 10
Won! New Balance: 220 New Betting Amount: 10
Won! New Balance: 230 New Betting Amount: 10
Lost! New Balance: 220 New Betting Amount: 20
Lost! New Balance: 200 New Betting Amount: 40
Lost! New Balance: 160 New Betting Amount: 80
Lost! New Balance: 80 New Betting Amount: 160
Failed! You're bankrupt. Balance: 80

And sometimes it managed to fully complete the betting cycle and come out on top:

Quote:Won! New Balance: 110 New Betting Amount: 10
Lost! New Balance: 100 New Betting Amount: 20
Won! New Balance: 120 New Betting Amount: 10
Won! New Balance: 130 New Betting Amount: 10
Lost! New Balance: 120 New Betting Amount: 20
Won! New Balance: 140 New Betting Amount: 10
Lost! New Balance: 130 New Betting Amount: 20
Lost! New Balance: 110 New Betting Amount: 40
Won! New Balance: 150 New Betting Amount: 10
Won! New Balance: 160 New Betting Amount: 10
Lost! New Balance: 150 New Betting Amount: 20
Lost! New Balance: 130 New Betting Amount: 40
Won! New Balance: 170 New Betting Amount: 10
Lost! New Balance: 160 New Betting Amount: 20
Lost! New Balance: 140 New Betting Amount: 40
Lost! New Balance: 100 New Betting Amount: 80
Won! New Balance: 180 New Betting Amount: 10
Won! New Balance: 190 New Betting Amount: 10
Lost! New Balance: 180 New Betting Amount: 20
Lost! New Balance: 160 New Betting Amount: 40
Won! New Balance: 200 New Betting Amount: 10
Won! New Balance: 210 New Betting Amount: 10
Lost! New Balance: 200 New Betting Amount: 20
Won! New Balance: 220 New Betting Amount: 10
Lost! New Balance: 210 New Betting Amount: 20
Lost! New Balance: 190 New Betting Amount: 40
Won! New Balance: 230 New Betting Amount: 10
Lost! New Balance: 220 New Betting Amount: 20
Lost! New Balance: 200 New Betting Amount: 40
Won! New Balance: 240 New Betting Amount: 10
Lost! New Balance: 230 New Betting Amount: 20
Lost! New Balance: 210 New Betting Amount: 40
Lost! New Balance: 170 New Betting Amount: 80
Won! New Balance: 250 New Betting Amount: 10
Won! New Balance: 260 New Betting Amount: 10
Lost! New Balance: 250 New Betting Amount: 20
Won! New Balance: 270 New Betting Amount: 10
Lost! New Balance: 260 New Betting Amount: 20
Won! New Balance: 280 New Betting Amount: 10
Lost! New Balance: 270 New Betting Amount: 20
Lost! New Balance: 250 New Betting Amount: 40
Lost! New Balance: 210 New Betting Amount: 80
Won! New Balance: 290 New Betting Amount: 10
Won! New Balance: 300 New Betting Amount: 10
Won! New Balance: 310 New Betting Amount: 10
Lost! New Balance: 300 New Betting Amount: 20
Lost! New Balance: 280 New Betting Amount: 40
Won! New Balance: 320 New Betting Amount: 10
Won! New Balance: 330 New Betting Amount: 10
Won! New Balance: 340 New Betting Amount: 10

Happy betting.

Oh, and @"Lux" may have some improvements on the strategy above that could be implemented to shift the odds in the player's favour, so look out for part two of this thread. I'll also be making a little script that you use based on the above strategy to make it more likely to come out on top.

[+] 1 user Likes Eclipse's post
Reply

RE: [Mathematics] H@x0r1ng the Betting System #2
Great work.

Ghe only issue with this is you have no margin for error, which is where the strategy reaps rewards. Try running the simulation with a balance of 1,000 and starting bets of 5 - unless you're really unlucky, you're almost sure to profit.

Reply

RE: [Mathematics] H@x0r1ng the Betting System #3
I ran the simulation of 1,000,000 intervals with a starting balance of 1,000 and a bet amount of 10. It dropped down to 50, and rose to 17k before I had to end the program. I will finish this up and collate the data into a graph.

[+] 1 user Likes lux's post
Reply

RE: [Mathematics] H@x0r1ng the Betting System #4
That just makes me question the true 'randomness' of the plugin. If it's so simplistically algorithmic and this easy to crack, isn't that bad code? Could you not just have something like this?
PHP Code:
$betters=Array('user1','user2');

$winner=$betters[array_rand($betters)]; 
It's often the outcasts, the iconoclasts ... those who have the least to lose because they
don't have much in the first place, who feel the new currents and ride them the farthest.

Reply

RE: [Mathematics] H@x0r1ng the Betting System #5
(10-27-2015, 06:30 PM)Gaige Wrote: That just makes me question the true 'randomness' of the plugin. If it's so simplistically algorithmic and this easy to crack, isn't that bad code? Could you not just have something like this?
PHP Code:
$betters=Array('user1','user2');

$winner=$betters[array_rand($betters)]; 

This is interesting to read: https://phpolyk.wordpress.com/2012/02/10...you-think/

Reply

RE: [Mathematics] H@x0r1ng the Betting System #6
(10-27-2015, 06:34 PM)Lux Wrote: This is interesting to read: https://phpolyk.wordpress.com/2012/02/10...you-think/

True, it's not 100% random with large array lengths, but you're unconditionally inputting 2 values.
It's often the outcasts, the iconoclasts ... those who have the least to lose because they
don't have much in the first place, who feel the new currents and ride them the farthest.

Reply

RE: [Mathematics] H@x0r1ng the Betting System #7
(10-27-2015, 06:39 PM)Gaige Wrote: True, it's not 100% random with large array lengths, but you're unconditionally inputting 2 values.

But we do not know the source code behind the betting, in our defence. The only way to properly do this would be through the Provably Fair system. http://provablyfair.org/

Reply

RE: [Mathematics] H@x0r1ng the Betting System #8
Just so you can put a name to this bet doubling method, it's called the Martingale betting system. This idea has been around for somewhere in the area of 300 years, and was originally a betting system that was introduced for a game where a person would be on a coin flip. Nowadays people who think they're super-smart use it on roulette, because the odds of red or black showing up are around 50% (48.6% on European boards, 47.3% on American boards).

As to why this wouldn't work realistically, it's mentioned in the Wikipedia article:

Quote:Assuming that the win/loss outcomes of each bet are independent and identically distributed random variables, the stopping time has finite expected value.[citation needed] This justifies the following argument, explaining why the betting system fails: Since expectation is linear, the expected value of a series of bets is just the sum of the expected value of each bet.[dubious – discuss] Since in such games of chance the bets are independent, the expectation of each bet does not depend on whether you previously won or lost. In most casino games, the expected value of any individual bet is negative, so the sum of lots of negative numbers is also always going to be negative.

The martingale strategy fails even with unbounded stopping time, as long as there is a limit on earnings or on the bets (which are also true in practice). It is only with unbounded wealth, bets and time that the martingale becomes a winning strategy.
[Image: CDUAq9d.png]

[+] 1 user Likes Shebang's post
Reply

RE: [Mathematics] H@x0r1ng the Betting System #9
(10-27-2015, 08:09 PM)Shebang Wrote: Just so you can put a name to this bet doubling method, it's called the Martingale betting system. This idea has been around for somewhere in the area of 300 years, and was originally a betting system that was introduced for a game where a person would be on a coin flip. Nowadays people who think they're super-smart use it on roulette, because the odds of red or black showing up are around 50% (48.6% on European boards, 47.3% on American boards).

As to why this wouldn't work realistically, it's mentioned in the Wikipedia article:

Yup that's pretty much what the simulation showed us. Thanks for the explanation. I hadn't heard of the actual name for the strategy.

Reply

RE: [Mathematics] H@x0r1ng the Betting System #10
Gambler's fallacy.
[Image: fSEZXPs.png]

Reply







Users browsing this thread: 4 Guest(s)