Labouchere simulation#

from roulette import Roulette
from core import *
import random
from simulations_core import simulate_different_goal_money, get_mean_and_std_of_histories
from simulations_plots_core import plot_money_histories

roulette = Roulette()

Step 1 - Decide how much you’d like to win First you need to decide how much you’d like to win, for example 10. Make this a realistic number that won’t stretch your bankroll too much. Then you need to split that number into smaller, random numbers. For example, our 10 goal could become 1, 2, 4, 1, 2.

def split_money(money):
    pieces = []
    while money != 0:
        if money>=10:
            portion = random.randint(2, 10)
            money -= portion
            pieces.append(portion)
        else:
            pieces.append(money)
            money = 0
            
    return pieces

Step 2 - Combine your numbers Take the furthest left number and the furthest right number from the sequence. In this example that would be 1 and 2. Combine these to make your first bet for 3.

Step 3 - Place your bet Bet 3 on an even bet like red, black, odd, even, 1-18 or 19-36.

Step 4 - Repeat the second step If you win, you cross off the furthest left and furthest right numbers from your sequence. Here you’d be left with 2, 4, 1. Repeat the second step, which would give you 2 and 1, so you would make another 3 bet.

If you lose, don’t cross off any numbers and add the bet you just made (3) to the far right of your sequence. You should have 2, 4, 1 and 3 now. Now repeat step 2 and in this case your bet would be 5.

Step 5 - Repeat until you win Repeat the steps until you have cleared your sequence and won your goal number. If you are on a bad losing streak, never chase your losses and know when to call it a day. Equally, if you’re on a winning streak, stop after the first loss to retain your profits.

def labouchere_betting(goal_money_won, bet=1, money_limit=None):
    bets = split_money(goal_money_won)
    money = 0
    money_history = [money]
    while money < goal_money_won:
        if money_limit != None and money < money_limit:
            return money_history
        
        prev_money = money 
        if len(bets) == 1:
            bet = bets[0]
        else:
            bet = bets[0] + bets[-1]
        money += roulette.make_even_bet(bet)
        money_history.append(money)
        if money < prev_money:
            bets.append(bet)
        else:
            if len(bets) == 1 or len(bets) == 2:
                return money_history
            bets.pop(0)
            bets.pop()
    
    return money_history
money_histories = simulate_different_goal_money(
                    betting_type = labouchere_betting, 
                    goal_money_list = [10, 100, 500, 1000], 
                    number_histories = 10000,
                    start_bet= 1,
                    money_limit= None)

Analysis when the goal is to win 10 units#

mean_money_list, std_money_list = get_mean_and_std_of_histories(money_histories, 10)
plot_money_history(mean_money_list, std_dev=std_money_list, title='Simulations mean and std', log_values=True)
../_images/63fee8287c236bb9ff2af83a1ad7146f7fed51e7b75b51f5f918bd7527a59dcd.png
plot_money_histories(money_histories, 10)
../_images/57c6b3e69137f19798bb46c8754d0de3346f2cd18a08b809f2d169a1dc81dae8.png ../_images/2c3b2d03a298522de1df890cb2d2361e50a4d54cfed2e91ecddd83e044cb8de9.png ../_images/c98b626c05f3532f7371fdc515b871230a83c84a15d1a6a9d5f5e68391deaf12.png ../_images/c98b626c05f3532f7371fdc515b871230a83c84a15d1a6a9d5f5e68391deaf12.png ../_images/c98b626c05f3532f7371fdc515b871230a83c84a15d1a6a9d5f5e68391deaf12.png ../_images/493018888cb585bd72dca7ba1e401f3265e97945a2a03351f5a9ea8a1303206f.png ../_images/c98b626c05f3532f7371fdc515b871230a83c84a15d1a6a9d5f5e68391deaf12.png ../_images/c98b626c05f3532f7371fdc515b871230a83c84a15d1a6a9d5f5e68391deaf12.png ../_images/c98b626c05f3532f7371fdc515b871230a83c84a15d1a6a9d5f5e68391deaf12.png ../_images/4339d939eac8017f5b2201b024a39c12188a6fc4aa6f66373316610a70dcbf8d.png

Analysis when the goal is to win 100 units#

mean_money_list, std_money_list = get_mean_and_std_of_histories(money_histories, 100)
plot_money_history(mean_money_list, std_dev=std_money_list, title='Simulations mean and std', log_values=True)
../_images/e3bb19aa8d5bd7f590d962150abbfed83f28433e7d347504c9c6515e7bbb604f.png
plot_money_histories(money_histories, 100)
../_images/e923d093e429938dee2f349bb004091edc511a23c98b0b5f1a83583e96421e21.png ../_images/2c078aa5c331579db908f469b9a0c1cee96ddea5914e6d06cf153ba78ed1ac92.png ../_images/1fc8ab3911624a34721ed44ffd686b1c5b930f14ecfb84985d6052cfc4ba3cc4.png ../_images/8608ca2b5dcec7cdcabb71774f1a681926335801db4743e8116b3c70aebf8776.png ../_images/998c1c8054b2bc950f3eb0c6d88bb986c2eab7238232559e4858d699ea118c20.png ../_images/a0feacecd197ea8aa4bddd4f55dc42edd25e0f47903c0baf920417ec5c16e2b5.png ../_images/b2c4e67a94c3032bf163f195c92bd81ca4f5f32c772d1f6c5ce3d767adb53cd5.png ../_images/69be1894c1cc9680569301f8a457b877e2e1499611fc1c7f27c3d04b71a9e08a.png ../_images/b00d90dcef7c88b289cbac663b9d9e2420d943a17212d598acdd687c1d7864f7.png ../_images/0f4135dacca606e76d0c584197b9ac42c3c3fe7c531c407cfb88965b0bfb427e.png

Analysis when the goal is to win 500 units#

mean_money_list, std_money_list = get_mean_and_std_of_histories(money_histories, 500)
plot_money_history(mean_money_list, std_dev=std_money_list, title='Simulations mean and std', log_values=True)
../_images/fa5e342a2808c09133d6e9791a46df1e9c693866ff0a31c1954b056734838ea4.png
plot_money_histories(money_histories, 500)
../_images/af48bedf97af6a71c05d83c3780cae8ca3ab7d171f46d1a21af98d4a4939fa68.png ../_images/0f16a1ede0a579adfc0768424c75e2665253b147cdb7328d5d2c599efaddebc0.png ../_images/b89b2f0d75f446d4f7f2fcda702eec0b979cfb11c83e3c1ab46f2d0f4880ab4b.png ../_images/b43a84df4976d0379326e726efe190d3f2e7e505f8b6aca7945f5ef1c6674361.png ../_images/9e54eb2288ca223dbf484b517ccafedb991c32df34bf30b4b8bfe2de38446c2c.png ../_images/12762c83d617403a153e128fdc9e21a65bf823bed6b61090903cd83e59c9a3df.png ../_images/0ce86797934f119a01b9acf62ffebf481c34f9d44e3e4297bb88c3f67c757c70.png ../_images/8782ef66654f77bd4b3bb96b3caee44395c06065f23f3cc30a6a15baecbfd73d.png ../_images/5ddae63aaacc4c5702bdb8831abc916c85273fda979d95a21fd16353d5526539.png ../_images/39a32d0c9d1aaa5427c8ad31e83c6a79c7046bedb6016f1df06a574103048580.png

Analysis when the goal is to win 1000 units#

mean_money_list, std_money_list = get_mean_and_std_of_histories(money_histories, 1000)
plot_money_history(mean_money_list, std_dev=std_money_list, title='Simulations mean and std', log_values=True)
../_images/3fd8e1966ed1cdeed81075b3ad693c14d62b1788133587a7a8b23058bd0c892d.png
plot_money_histories(money_histories, 1000)
../_images/f7cc1275c9d529024973daa9c4b9835a57887d895b242fabf48620e5b2fd1469.png ../_images/363d23364f8d601e0ba9a49f12be51b03b74d92c527d8a160a114a1a19d95c51.png ../_images/78d87b96e0548069391cf8a8e051174ddfe8cde4fbdfb3243a606622a236275e.png ../_images/927994c86f254bef7a632c8f6478e6914bdb7688b25fe37c77854b99563e4f04.png ../_images/66dea18ee0abb269caeb7b82daf77e54d958831ada3791161ff55f6e56eb3e8b.png ../_images/17efd24e2f19cf4e342a6c69152f49222a25c603e8ce67ca3951a2ab912725a1.png ../_images/dafb4ff156cd6148779f9bb76f23486d5a42f62a7547998167e091c9df36ef80.png ../_images/6f68c7a57f32c764454bc3722bd065220fa616e61d976aafc736072d94f50f2b.png ../_images/580b2b6c72cc136aa044f2605f898f30c8dba882570aa4fc43226d509a67381f.png ../_images/edb72bd85ca00956f0d515e1cedef02904c4a329644c72aca80b287d32504798.png