Beating a roulette

Last Friday my uncle joyfully shared with me how “he beat the casino” with a system that guarantees you win, in the game of roulette. His system goes like that –

  1. Place 1$ on red.
  2. If you win, repeat step 1.
  3. If you lose, double the bet amount, and bet again.
  4. Repeat step 3 until you win. Then, go back to step 1.

Basically, whenever you win, you happy. Whenever you lose, you double your next bet hoping to cover for the loss and make a small gain. For example if the roulette hits Black 8 times in a row, you lost 255$ = 1 + 2 + 4 + … + 56 + 128, and for the next bet you should place 256$ as it is exactly double the amount you betted in the previous loss (128).

It wasn’t the first time I heard about this system, and I know it to be not profitable in the long term, from mathematical perspective. You will make a lot of small gains, however you will also make one big loss to take everything you gained plus more. To counter the small loss, my uncle decided to keep the amount he brings with him to the Casino constant, meaning he won’t be able to lose today what he gained yesterday.

The classical system is explained here with more mathematical emphasis. For I am no mathematician, I’ll leave the math for others to explain. – https://en.wikipedia.org/wiki/Martingale_(betting_system)

What I will do is showing you, by simulating a game of roulette, for I am a programmer šŸ™‚

First thing first, our roulette:

class Roulette:
    def __init__(self, max_number=36, red_numbers=18):
        self._max_number = max_number
        self._red_numbers = red_numbers

    def bet_red(self) -> bool:
        rand = random.randint(0, self._max_number + 1)
        if rand <= self._red_numbers - 1:
            return True

        return False

Our roulette will have a max number, which is 36 as default for a classical roulette, and the amount of red number. The roulette will also have a method simulating placing a bet on the color red, which returns a Boolean value representing win or lose. We have 37 slots overall (including 0), 18 of them being red, so we have 18/37 chance getting true.

Now we can create the game simulation:

class RouletteGame:
    def __init__(self, roulette: Roulette, days=365, spins_each_day=100, starting_bet=1, initial_cash_amount=200):
        self._roulette = roulette
        self._days = days
        self._spins_each_day = spins_each_day
        self._starting_bet = starting_bet
        self._initial_cash_amount = initial_cash_amount

The game simulation has:

  1. Roulette object
  2. Number of days we are simulating
  3. Number of spins we want to play each day
  4. Our starting bet
  5. And the initial amount we bring with us to the Casino each day

Time for the main dish, our betting algorithm!

    def play_one_day(self) -> int:
        total = self._initial_cash_amount
        bet_amount = self._starting_bet
        spins_played = 0

        while spins_played < self._spins_each_day or bet_amount > self._starting_bet:
            if total - bet_amount < 0:  # can't place bet
                return total

            spins_played += 1
            total -= bet_amount

            if self._roulette.bet_red():
                total += 2 * bet_amount
                bet_amount = self._starting_bet

            else:
                bet_amount = bet_amount * 2

        return total

Whoa! That’s a big function! Let’s break it down…

  1. First we initialize everything we will use in the function: the Total we take home, the current bet amount, and the numbers of spins we played.
  2. A while loop. We want to continue playing if we still haven’t played enough turns, or if we are in the middle of a loosing streak we want to recover from – which is the whole point of the system. We can know if we are in the middle of such a streak by simply examining the bet amount, which is not 1$ only in a case we’ve just lost.
  3. Check if we can allow to participate in the next spin. If all we have is 5$, and the amount we wish to bet is 1024$, we better call it a day.
  4. Finally we spin the wheel. Win – we take double the amount we betted and reset the bet to 1$. Loss – we double the bet.

Lastly, let’s run everything across the whole period of time.

    def periodical_report(self):
        total_gain = 0

        for i in range(self._days):
            one_day_gain = self.play_one_day()
            total_gain += one_day_gain
            print(f"Day: {i+1}, total gained: {one_day_gain}")

        invested_amount = self._days * self._initial_cash_amount
        print(f"Total invested: {invested_amount}\n"
              f"Total gain: {total_gain}\n"
              f"ratio: {total_gain / invested_amount}\n")

And the results we all have been waiting for –

I’ve ran it multiple times, not even once the net gain was positive. Thus conclude our scheme to conquer every roulette around the world.

One thought on “Beating a roulette

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: