Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random as r
- ## 50% true or false
- ## false is lost bet
- def flipcoin():
- flip = r.randint(0,1)
- return flip == 1
- if __name__ == '__main__':
- base_bet = 10
- money = 100000
- current_bet = base_bet
- goal = money * 2
- increase_factor = 2
- highest_bet = 1
- wait = 10
- lose_counter = 0
- total_games = 0
- while money > 0 and money < goal:
- total_games += 1
- toss_result = flipcoin()
- cur_counter = lose_counter
- if not toss_result:
- lose_counter += 1 # lost again
- else:
- lose_counter = 0 # reset counter if win
- if cur_counter < wait:
- continue # only bet when there are WAIT losses in a row
- print ("Bet: " + str(current_bet) + " Money remaining: " + str(money) + " Highest bet: " + str(highest_bet))
- if current_bet > highest_bet:
- highest_bet = current_bet
- if toss_result:
- money += current_bet # we are betting, but won
- current_bet = base_bet # reset bet
- else:
- money -= current_bet # we are betting, and doubling next bet if we lost
- current_bet *= increase_factor
- print ("Final money: " + str(money))
- print ("Final bet: " + str(current_bet))
- print ("Highest bet: " + str(highest_bet))
- print ("Total games: " + str(total_games))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement