Solved – Is it a valid algorithm to win at the casino roulette

conditional probabilitymartingaleprobabilitypython

I would like to try the following algorithm in order to win in the roulette:

  1. Be an observer until there are 3 same parity numbers in a row ($0$ has no defined parity in this context)

  2. Once there were achieved 3 numbers with the same parity in a row: init $factor$ to be $1$

  3. Bet the next number will be the opposite parity if you were wrong double $factor$ and return 3 else goto 1.

Here is a python code for it – which bring profit all the time:

import random

nums = range(37)
bank = 10**10
games = 3000
factor=1
bet_amount=100
next_bet = None
parity_in_row ={"odd":0, "even":0}

for i in xrange(games):
    num = nums[random.randint(0,36)]

    if next_bet == "odd":
        if num % 2 == 1:
            bank += factor*bet_amount
            factor = 1
            next_bet = None
        else:
            bank -= factor*bet_amount
            factor *= 2
    elif next_bet == "even":
        if num % 2 == 0:
            bank += factor*bet_amount
            factor = 1
            next_bet = None
        else:
            bank -= factor*bet_amount
            factor *= 2


    if num > 0 and num % 2 == 0:
        parity_in_row["even"] += 1
        parity_in_row["odd"] = 0
    elif num % 2 == 1:
        parity_in_row["odd"] += 1
        parity_in_row["even"] = 0
    else:
        parity_in_row ={"odd":0, "even":0}

    if parity_in_row["odd"] > 2:
        next_bet = "even"
    elif parity_in_row["even"] > 2:
        next_bet = "odd"
    else:
        next_bet = None

print bank
  • If I did the calculation correctly the probability to have 4 numbers
    in a row with the same parity $ < (1/2-\epsilon)^4 $ [where $\epsilon
    < 1/36$ is a compensation for the probability to achieve $0$].
  • Keep doubling $factor$ ensures you will have positive expectation,
    right?
  • Isn't the probability of getting odd number is $0.5$ ? since
    $Prob(odd | even, even, even) = \frac{1}{2}$ ?

Please try to supply a rigorous proof why it is wrong, and try to explain why my python code always return with a positive outcomes

Best Answer

You have discovered the Martingale. It is a perfectly reasonable betting strategy, which was played by Casanova and also by Charles Wells, but unfortunately it doesn't win in the long run. Essentially the strategy is no different from the following idea:

Keep betting. Each time you lose, bet more than your total losses up to now. Since you know that you'll eventually win, you will always end up on top.

Your plan of only betting after getting three the same in a row is a red herring, because spins are independent. It makes no difference if there have already been three in a row. After all, how could it make a difference? If it did, this would imply that the roulette wheel magically possessed some kind of memory, which it doesn't.

There are various explanations for why the strategy doesn't work, among which are: you don't have an infinite amount of money to bet with, the bank doesn't have an infinite amount of money, and you can't play for an infinite amount of time. It's the third of these that is the real problem. Since each bet in roulette has a negative expected value, no matter what you do, you expect to end up with a negative amount of money after any finite number of bets. You can only win if there is no upper limit to the amount of bets you can ever make.

For your last question, the probability of getting an odd number on a real roulette wheel is actually less than $0.5$, because of a 00 on the wheel. But this doesn't change the fact that you have discovered a nice winning strategy; it's just that your strategy can't win (on average) in any finite amount of bets.

Related Question