I am checking out a roulette python scenario. However, I am always winning, I am unable to figure out what I am missing in my algorithm.
The concept is, I start with bet = 1 on even. If I loose, I double the bet, until I win. If I win, I just get back to bet = 1
I wrote a simply python script with randint from (-1 to 36), -1 and 0 for 'double zero' and 'zero'. I ran this simulation in a while loop until 1000 times, almost all the times, I ended up with higher amount than I started. Can I use randint - which is a random number generator, to simulate a roulette?
j = 0
k = 1
while (k<1000): # simulate for 1000 times
bet = 1
bank = 1024
for i in range (1, 100): # Placing 10000 bets
num = random.randint(-1, 36)
if num == 0 or num == -1:
bank = bank - bet
bet = 2*bet
elif(num % 2) == 0:# betting on even numbers
#print("{0} is Even".format(num))
bank = bank + bet
bet = 1
else:
#print("{0} is Odd".format(num))
bank = bank - bet
bet = 2 * bet
if bank<0:
break
if bank<1024:
j = j+1 # Count how many times money is lost
k = k+1
print ('Number of times money lost is', j)