Created
May 12, 2019 13:37
-
-
Save sebinthomas/38ce7ae397eff5fdd19d797f7cc3f08e to your computer and use it in GitHub Desktop.
Martingale betting
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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