Video Demo: Video Final Project CS50
My projects simulates playing Roulette with the Martingale system. It consists of the functions:
- `main()`
- `roulette(i, b, m) # i = init, b = bet, m = money`
- `doubling(b, m, i)`
- `number()`
- `even(z)`
- `proba(d, i)`
-
The
main-functionasks the user to enter his bet entry which he is to double every round he loses and the total amount ofmoneyhe has - in this README we assumebet = 5,money = 3000$. Furthermore we need an initial bet-valueinitto set back to each time he wins. These values are passed as parameters fordoubling(b, m, i)to calculate the number of doubling his amount allows. -
proba(d, i)takes the return values ofdoublingwhich consist of a tuple, i.e.d[0]= number of doubling andd[1]= user's loss and calculates the ordinal number of rounds expected to result in a loss - e.g., see above,bet = 5,money = 3000allows for 9* doubling with a loss of 2555$. So he loses (19/37) ** 9 = 0.00248 which makes for about every 400 rounds. The EV is -1.36$ per round. -
The interesting thing is now function
roulettewhich takesbet,moneyandinit, remember, his firstbet = 5, and returns the number of rounds he can play viawhile-loop -while money > bet- as long as this is the case he can double - and returns the number of rounds, the number the croupier rolled (viarandint(0, 36)) hisbetandmoney. We run this 50 times in a for-loop to see how many rounds it takes him to lose. We detect a significant high amount of outliers - expected 403, detected 13 and so on - so we investigate this further by opening an empty list and adding anif-clauseto our for-loop where we fill our list with every number of rounds < 100 - cf. the return tuple ofdoubling, number of rounds isr[0]from our return tuple ofroulette(i, b, m). Now we run the code and watch the length of our list that contains all significant deviations of our expected probabilities we got fromproba-function. -
We are now able to conclude that Martingale is definitely not a promising system and this project's aim is to not only providing us with the mathematics but also empiricism.