Skip to content

Instantly share code, notes, and snippets.

@sebinthomas
Created May 12, 2019 13:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sebinthomas/38ce7ae397eff5fdd19d797f7cc3f08e to your computer and use it in GitHub Desktop.
Save sebinthomas/38ce7ae397eff5fdd19d797f7cc3f08e to your computer and use it in GitHub Desktop.
Martingale betting
# user/bin/env python
import random
# used for a dumb function to get random number
import time
USE_SYSRAND = True
ODDS = 1
FIRST_BET = 1
def get_random():
global USE_SYSRAND
if USE_SYSRAND:
return random.randint(0, 1)
else:
return int(time.time()) % 2
def martingale():
global FIRST_BET
global ODDS
betting_amount = FIRST_BET
winnings = 0
win = False
game_outcome = None
while not win:
print 'Betting amount: {}'.format(betting_amount)
game_outcome = get_random()
if game_outcome:
winnings += betting_amount * ODDS
win = True
else:
winnings -= betting_amount
betting_amount = betting_amount * 2
print 'Outcome: {} Winnings: {}'.format(game_outcome, winnings)
if __name__ == '__main__':
martingale()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment