Created
February 7, 2019 17:09
-
-
Save markusleh/082680a1d8ad986ed7235b9f326e032a to your computer and use it in GitHub Desktop.
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
import random | |
import math | |
value = random.randrange(0, 2) | |
vals = [] | |
rounds = 1000 | |
for i in range(0,rounds): | |
vals.append(random.randrange(0,2)) | |
avg = sum(vals)/len(vals) | |
print("Avg: {}".format(avg)) | |
# Game | |
money = 10 | |
start_bet = 1 | |
guess = 2 | |
bet = False | |
curr_bet = money | |
bet_count = 0 | |
for i in range(0,rounds): | |
if bet == True: | |
bet_count += 1 | |
bet = False | |
if vals[i] == 1: | |
money = money + curr_bet | |
else: | |
money -= curr_bet | |
curr_bet *= 2 | |
continue | |
if vals[i-guess:i] == [1,1]: | |
bet = True | |
print("Final score: {}".format(money)) | |
print("Bets made: {}".format(bet_count)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment