# Algorithm for winning casino roulette

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

-
Unless you have infinite money, and the casino has no bet limit, this strategy is guaranteed to lose in the long run. The only way -- the only way -- to make money off roulette over the long term in a casino is to be the casino. Everything else, no matter how convoluted, is a sucker bet. If you enjoy playing, then play low stakes and treat the losses as the ticket price for that enjoyment. If you don't particularly enjoy playing, find investments with positive expected return instead. – Glen_b May 27 '14 at 8:15
This (famous) class of strategies is a very refined way to go broke fast. Sending me $100 a month is less refined, but will send you broke so much more slowly that it will seem profitable by comparison. – Glen_b May 27 '14 at 8:24 @Glen_b you can also win if you can succesfully estimate the speed of the wheel and the position where the ball is thrown in as this can significantly narrow the odds. Roulette is not an entirely random situation and you can exploit habits of the dealer. – JamesRyan May 27 '14 at 9:29 In your code, you forgot the cases where the number is neither odd nor even. Depending on the location you are playing in, there will be either one or two 0's on the wheel and these are counted as neither odd nor even. – Peter Flom May 27 '14 at 10:08 @PeterFlom I added a fix, hope I got your point correctly. – 0x90 May 27 '14 at 13:43 ## 3 Answers 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. - I am looking on events which are sequence pf at least 4 events. where 3 of the first are identical. – 0x90 May 27 '14 at 13:52 Actually, Martingale always win in the long run, as long as you have infinite money to keep double your bet with. – KoKo Mar 6 at 22:19 You missed the fact that your calculation refers to the prior probability of four same-parity numbers in a row, whereas at the moment when you place your bet, you have already observed three of the numbers, hence the probability you are betting on is either the conditional probability of an odd number given that the three previous numbers were odd or the conditional probability of an even number given that the three previous numbers were even. If you compute that conditional probability correctly, you should find that it is equal to the prior probability that any given spin of the wheel will come up odd (and also equal to the probability that it will come up even). The rest of your system appears to consist of a double-or-nothing strategy. If you start with a large enough pile of money (for example,$10^8$times your initial bet, as shown in your Python code), and you play not too many games (only 3000 in your example), the chances are quite good that this strategy will "work". But if you are very unlucky, or if you play long enough, you will hit such a bad streak of losses that you will not have enough money left to double your bet after the last loss, and the strategy fails. In effect, you are risking the loss of 5 to 10 billion units of money in return for a non-quite-certain chance to win 300,000 units of money. At only 3000 games in each run of your simulation, it may take quite a few runs before you encounter a disastrous outcome, so after a limited number of simulations it may appear to you that this system works well. But that would only be because you haven't done enough trials to correctly discover the risk. - Looks like everyone already told you this-- But, surprisingly enough, each bet in Roulette has the exact same odds to payout ratio, or expected value (EV). That EV is negative (house edge). So red, black, columns, numbers -- all the same expected return, with the exception of the "sucker's bet" pentagon, which has slightly worse EV than any other bet. Your system is a combination of believing the roulette wheel has a memory (the 'hot' and 'icy' numbers graphics in Roulette wheels in Vegas are meant to entice suckers with 'systems' that don't work). It doesn't. You also throw in the Martingale system -- which goes like this. Make a bet -- if you lose, make a larger bet that covers all your losses. Play until you win one time. The problem with this is that, given you have finite money, and the house has a max bet limit (it does) --- you WILL, at some point, accomplish the unlikely but inevitable feat of losing 8 or 9 times in a row (going from one bet to the max bet) -- and losing a metric S$@! ton of money.

Ultimately, the house has about a 5% edge in Roulette. That means long term, you will average a 95% return on every bet placed on the wheel.

So a bet of 1000 in the long term average out to 50 lost per bet.

The more bets you make, the more statistically certain this is.

So any system, like the Martingale, that throws increasingly larger sums on the table, averages out to lose increasingly higher amounts overall.

-
I am working on events of 4 spins – 0x90 May 27 '14 at 16:24
If you really believed in this, I'm surprised you'd be publishing it to the masses. But regardless, it doesn't matter that 4 spins went red in a row. It doesn't matter if there are 99 spins in a row that went red --- the next one has the exact same odds -- almost exactly 50% chance of red, almost 50% chance of black, minus the zeroes. – user45867 Jun 2 '14 at 16:02
I did believe and lost some money, the question is why within the script the outcome is always higher than the initial money in the bank? secondly why if I ask you what are the odds to have 4 blacks in a row is about $(1/2)^4$ and that doesn't hold in my case. – 0x90 Jun 2 '14 at 16:29