Hello,
I knew BASIC back in the 80’s… and figured it would be nice to start reading about Python and give it a go as a new hobby. I decided to try to write a red/black roulette betting program. For the heck of it I’m just going up in bets by power of 2, (up to 64). Like typical martingale betting, wins go back to the original bet amount, losses stop at 64x.
I have it working, (I’ll include my crude coding below). I have also set it up to double the betting amounts if and when the bankroll triples. What I CAN NOT figure out is this:
I want to incorporate ‘dialing down’ the bets if the bankroll falls below the prior doubling amount, until (and if) it gets back over that same threshold, at which point I’d like the bets go go back to the double amount cycle they were at. And so on.
I’d be very grateful for any help with this. I’ve spent too much time trying and figured it was time to seek some expert help. Thanks very much in advance for any assistance.
OK - the code:
import random
Bankroll is the starting bankroll
bankroll = 50
x is a bankroll counter that will double the bet if and when the bankroll triples
x = 50
s is a counter for each spin of the wheel
s = 0
wl = 1
wl (win or loss) is the bet. First bet is 1.
wheel = [“Red”] * 18 + [“Black”] * 18 + [“Green”] * 1
bankroll_history =
This below is to double the bets if / when the bankroll triples as the program runs
while bankroll > 0:
if bankroll/3 >= x:
wl *= 2
x = bankroll
print ("BETS DOUBLED AT", x)
else:
spin = random.choice(wheel)
if spin == "Red":
bankroll += wl
s+=1
print (s,"WIN ", wl, "TOTAL = ", bankroll)
bankroll_history.append(bankroll)
else:
bankroll -= wl
s+=1
print (s,"Lose ", wl, "TOTAL = ", bankroll)
if bankroll < 0: break
spin = random.choice(wheel)
if spin == "Red":
bankroll += (wl*2)
s+=1
print (s,"WIN ", wl*2, "TOTAL = ", bankroll)
bankroll_history.append(bankroll)
else:
bankroll -= (wl*2)
s+=1
print (s,"Lose ", wl*2, "TOTAL = ", bankroll)
if bankroll < 0: break
spin = random.choice(wheel)
if spin == "Red":
bankroll += (wl*4)
s+=1
print (s,"WIN ", wl*4, "TOTAL = ", bankroll)
bankroll_history.append(bankroll)
else:
bankroll -= (wl*4)
s+=1
print (s,"Lose ", wl*4, "TOTAL = ", bankroll)
if bankroll < 0: break
spin = random.choice(wheel)
if spin == "Red":
bankroll += (wl*8)
s+=1
print (s,"WIN ", wl*8, "TOTAL = ", bankroll)
bankroll_history.append(bankroll)
else:
bankroll -= (wl*8)
s+=1
print (s,"Lose ", wl*8, "TOTAL = ", bankroll)
if bankroll < 0: break
spin = random.choice(wheel)
if spin == "Red":
bankroll += wl*16
s+=1
print (s,"WIN ", wl*16, "TOTAL = ", bankroll)
bankroll_history.append(bankroll)
else:
bankroll -= (wl*16)
s+=1
print (s,"Lose ", wl*16, "TOTAL = ", bankroll)
if bankroll < 0: break
spin = random.choice(wheel)
if spin == "Red":
bankroll += (wl*32)
s+=1
print (s,"WIN ", wl*32, "TOTAL = ", bankroll)
bankroll_history.append(bankroll)
else:
bankroll -= (wl*32)
s+=1
print (s,"Lose ", wl*32, "TOTAL = ", bankroll)
if bankroll < 0: break
spin = random.choice(wheel)
if spin == "Red":
bankroll += (wl*64)
s+=1
print (s,"WIN ", wl*64, "TOTAL = ", bankroll)
bankroll_history.append(bankroll)
else:
bankroll -= (wl*64)
s+=1
print (s,"Lose ", wl*64, "TOTAL = ", bankroll)
if bankroll < 0: break
bankroll_history.append(bankroll)