-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathmontecarlo2.py
More file actions
46 lines (28 loc) · 882 Bytes
/
montecarlo2.py
File metadata and controls
46 lines (28 loc) · 882 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import random
# let us go ahead and change this to return a simple win/loss
def rollDice():
roll = random.randint(1,100)
if roll == 100:
print roll,'roll was 100, you lose. What are the odds?! Play again!'
return False
elif roll <= 50:
print roll,'roll was 1-50, you lose.'
return False
elif 100 > roll >= 50:
print roll,'roll was 51-99, you win! *pretty lights flash* (play more!)'
return True
'''
Simple bettor, betting the same amount each time.
'''
def simple_bettor(funds,initial_wager,wager_count):
value = funds
wager = initial_wager
currentWager = 0
while currentWager < wager_count:
if rollDice():
value += wager
else:
value -= wager
currentWager += 1
print 'Funds:', value
simple_bettor(10000,100,100)