Created
November 12, 2021 12:48
-
-
Save yudataguy/51ec6e55a57a964b0ac0e86ec919ac1b to your computer and use it in GitHub Desktop.
roulette simulation
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 math | |
import random | |
start = 0 | |
end = 36 | |
def createList(r1, r2): | |
# Testing if range r1 and r2 | |
# are equal | |
if (r1 == r2): | |
return r1 | |
else: | |
# Create empty list | |
res = [] | |
# loop to append successors to | |
# list until r2 is reached. | |
while(r1 < r2+1 ): | |
res.append(r1) | |
r1 += 1 | |
return res | |
table = createList(start, end) | |
buy_in = 600 | |
def payout(buy_in=1000, round=100, zero=False): | |
final = 0 | |
for r in range(round): | |
buy_in -= 600 | |
if zero: | |
buy_in -= 10 | |
outcome = random.choice(table) | |
if outcome == 1 or outcome == 2 or outcome == 4 or outcome == 5 or outcome == 7 or outcome == 8 or outcome == 10 or outcome == 11: | |
buy_in += 36 * 25 | |
elif outcome >= 13 and outcome <= 36: | |
buy_in += 200 * 3 | |
elif zero and (outcome == 0 or outcome == 100): | |
buy_in += 5 * 35 | |
print(f"Round {r}: Number {outcome}, Amount {buy_in}") | |
if buy_in <= 0: | |
print("running out of money, game over") | |
return r + 1 | |
exit() | |
return 100 | |
total_list = [] | |
for x in range(100): | |
total_list.append(payout(zero=True)) | |
print(sum(total_list)/100) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment