Peut-on gagner à la roulette ?

A la recherche d'une stratégie payante pour battre le casino.

import numpy as np
import pandas as pd
import plotly.graph_objects as go
from plotly.offline.offline import plot
class PocketSet:
    def __init__(self, choices):
        self.choices = tuple(choices)
    def __hash__(self):
        return hash(self.choices)
    def __eq__(self, other):
        return isinstance(other, PocketSet) and self.choices == other.choices
    def __str__(self):
        return f"{self.choices} ({hash(self)})"
    
    def get_profit(self, sort, amount):
        profit = -amount
        if sort in self.choices:
            profit += amount * 36 / len(self.choices)
        return profit
def play(apply, cases, length, limit):
    sorts = np.random.choice(cases, length)
    profits = np.zeros(length)
    bets = {}
    win = False
    
    for i, sort in enumerate(sorts):
        bets = apply(bets, win)
        if limit and max(bets.values()) > limit:
            profit = 0
        else:
            profit = sum(pocket.get_profit(sort, amount) for pocket, amount in bets.items())
        win = profit > 0
        profits[i] = profit
        
    return profits.cumsum()
def display(scenarios, title):
    fig = go.Figure()
    t = np.arange(scenarios.shape[1])
    mean = np.mean(scenarios, axis=0)

    for i, scn in enumerate(scenarios):
        fig.add_traces(go.Scatter(x=t, y=scn, line=dict(color='rgba(100, 100, 100, 0.15)')))
    fig.add_traces(go.Scatter(x=t, y=mean, line=dict(color='blue', width=3)))
    fig.add_traces(go.Scatter(x=t, y=np.zeros_like(t), line=dict(color='black', width=3)))
    fig.update_layout(title=title, showlegend=False, yaxis_title='Profits', xaxis_title='Nombre de parties')
    return fig
def simulate(apply, title, case=np.arange(0, 37), length=100, players=250, limit=None):
    scenarios =  np.array([play(apply, case, length, limit) for _ in range(players)])
    fig = display(scenarios, title)
    print(plot(fig, include_plotlyjs=False, include_mathjax=False, output_type='div'))

Début simulation

Les mises simples (noir/rouge, pair/impair, etc)

def only_1_to_18(bets, win):
    return {PocketSet(choices=np.arange(1, 19)): 1}
simulate(apply=only_1_to_18, title='Mise Simple')
simulate(apply=only_1_to_18, title='Mise Simple Sans Zero', case=np.arange(1, 37))
def only_1_to_12(bets, win):
    return {PocketSet(choices=np.arange(1, 13)): 1}
simulate(apply=only_1_to_12, title='Mise double')
simulate(apply=only_1_to_12, title='Mise double Sans zero',  case=np.arange(1, 37))
def one_number(bets, win):
    return {PocketSet(choices=[17]): 1}
simulate(apply=one_number, title='Mise sur le 17')