-
Notifications
You must be signed in to change notification settings - Fork 0
/
twister.py
241 lines (218 loc) · 7.56 KB
/
twister.py
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
from random import randint
dice, result, pairs = [0, 0, 0], [0, 0, 0], ()
def roll():
global dice, result, pairs
dice[0], dice[1], dice[2] = randint(1, 6), randint(1, 6), randint(1, 6)
result = sorted([dice[0], dice[1], dice[2]])
if result[0] == result[1] == result [2]: pairs = (3, result[0], 0)
elif result[0] == result[1]: pairs = (2, result[0], result[2])
elif result[1] == result [2]: pairs = (2, result[1], result[0])
else: pairs = (1, 0, 0)
class twister(object):
def __init__(self, cash):
self.cash = cash
def check(self, bet):
assert isinstance(self.cash, int)
assert isinstance(bet, int)
assert self.cash >= bet > 0
self.cash -= bet
return self.cash
def uno_sum(self, bet, pick):
self.cash = twister.check(self, bet)
assert isinstance(pick, int)
assert 1 <= pick <= 6
roll()
print("You picked red totaling %s, and rolls are %s" % (pick, dice))
if pick == dice[2]:
self.cash += 6 * bet # zero house edge
print(self.cash)
def duo_sum(self, bet, pick):
self.cash = twister.check(self, bet)
assert isinstance(pick, int)
assert 2 <= pick <= 12
roll()
print("You picked green totalling %s, and rolls are %s" % (pick, dice))
if pick == dice[0] + dice[1]:
if pick in [2, 12]:
self.cash += 36 * bet # zero house edge
elif pick in [3, 11]:
self.cash += 18 * bet # zero house edge
elif pick in [4, 10]:
self.cash += 12 * bet # zero house edge
elif pick in [5, 9]:
self.cash += 9 * bet # zero house edge
elif pick in [6, 8]:
self.cash += 7 * bet + (bet * 2) // 12
elif pick == 7:
self.cash += 6 * bet # zero house edge
print(self.cash)
def trio_sum(self, bet, pick):
self.cash = twister.check(self, bet)
assert isinstance(pick, int)
assert 3 <= pick <= 18
roll()
print("You picked green/red totaling %s, and rolls are %s" % (pick, dice))
if pick == dice[0] + dice[1] + dice[2]:
if pick in [3, 18]:
self.cash += 216 * bet # zero house edge
elif pick in [4, 17]:
self.cash += 72 * bet # zero house edge
elif pick in [5, 16]:
self.cash += 36 * bet # zero house edge
elif pick in [6, 15]:
self.cash += 21 * bet + (bet * 7) // 12
elif pick in [7, 14]:
self.cash += 14 * bet + (bet * 5) // 12
elif pick in [8, 13]:
self.cash += 10 * bet + (bet * 3) // 12
elif pick in [9, 12]:
self.cash += 8 * bet + (bet * 7) // 12
elif pick in [10, 11]:
self.cash += 8 * bet # zero house edge
print(self.cash)
################################################################################
def uno_twin(self, bet, pick): # zero house edge
self.cash = twister.check(self, bet)
assert pick in ["odd", "even"]
roll()
print("You picked green being %s, and rolls are %s" % (pick, dice))
if dice[2] % 2 == 1 and pick == "odd":
self.cash += 2 * bet
elif dice[2] % 2 == 0 and pick == "even":
self.cash += 2 * bet
print(self.cash)
def duo_twin(self, bet, pick): # zero house edge
self.cash = twister.check(self, bet)
assert pick in ["odd", "even", "mixed"]
roll()
print("You picked green being %s, and rolls are %s" % (pick, dice))
if dice[0] % 2 == dice[1] % 2:
if dice[0] % 2 == 1 and pick == "odd":
self.cash += 4 * bet
elif dice[0] % 2 == 0 and pick == "even":
self.cash += 4 * bet
elif pick == "mixed":
self.cash += 2 * bet
print(self.cash)
def trio_twin(self, bet, pick): # zero house edge
self.cash = twister.check(self, bet)
assert pick in ["odd", "even", "mixed"]
roll()
print("You picked green/red being %s, and rolls are %s" % (pick, dice))
if dice[0] % 2 == dice[1] % 2 == dice[2] % 2:
if dice[0] % 2 == 1 and pick == "odd":
self.cash += 8 * bet
elif dice[0] % 2 == 0 and pick == "even":
self.cash += 8
elif pick == "mixed":
self.cash += 1 * bet + (bet * 4) // 12
print(self.cash)
################################################################################
def duo_dubs(self, bet, pick): # zero house edge
self.cash = twister.check(self, bet)
assert isinstance(pick, int)
assert 0 <= pick <= 6
roll()
print("You picked green double %s, and rolls are %s" % (pick, dice))
if dice[0] == dice[1]:
if pick == 0:
self.cash += 6 * bet
elif dice[0] == pick:
self.cash += 36 * bet
print(self.cash)
def trio_dubs(self, bet, pick):
self.cash = twister.check(self, bet)
assert isinstance(pick, int)
assert 0 <= pick <= 6
roll()
print("You picked green/red double %s, and rolls are %s" % (pick, dice))
if pairs[0] == 2:
if pick == 0:
self.cash += 2 * bet + (bet * 4) // 12
elif dice[0] == pick:
self.cash += 14 * bet + (bet * 4) // 12
print(self.cash)
def trio_trips(self, bet, pick): # zero house edge
self.cash = twister.check(self, bet)
assert isinstance(pick, int)
assert 0 <= pick <= 6
roll()
print("You picked green/red triple %s, and rolls are %s" % (pick, dice))
if pairs[0] == 3:
if pick == 0:
self.cash += 36 * bet
elif dice[0] == pick:
self.cash += 216 * bet
print(self.cash)
################################################################################
def trio_straight(self, bet, pick): # zero house edge
self.cash = twister.check(self, bet)
assert pick in ["lo", "hi", "any"]
roll()
print("You picked green/red straights, and rolls are %s" % dice)
if result in [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6]]:
if result in [[1, 2, 3], [2, 3, 4]] and pick == "lo":
self.cash += 18 * bet
elif result in[[3, 4, 5], [4, 5, 6]] and pick == "hi":
self.cash += 18 * bet
elif pick == "any":
self.cash += 9 * bet
print(self.cash)
def trio_number(self, bet, pick): # odds can be fixed
self.cash = twister.check(self, bet)
assert isinstance(pick, int)
assert 1 <= pick <= 6
roll()
print("You picked %ss, and rolls are %s" % (pick, dice))
if pairs[1] == pick:
if pairs[0] == 3:
self.cash += 8 * bet
elif pairs[0] == 2:
self.cash += 4 * bet
elif pick in dice:
self.cash += 1 * bet + (bet * 11) // 12
print(self.cash)
# Need Field Bets and Big/Small a.k.a Hi/Mid/Lo
################################################################################
def duo_domino(self, bet, pick1, pick2):# zero house edge
self.cash = twister.check(self, bet)
assert isinstance(pick, int)
assert 1 <= pick1 <= 6 and 1 <= pick2 <= 6
assert pick1 != pick2
roll()
print("You picked %s-%s, and rolls are %s" % (pick1, pick2, dice))
if dice[0] == pick1 and dice[1] == pick2:
self.cash += 18 * bet
elif dice[0] == pick2 and dice[1] == pick1:
self.cash += 18 * bet
print(self.cash)
def trio_domino(self, bet, pick1, pick2):
self.cash = twister.check(self, bet)
assert isinstance(pick, int)
assert 1 <= pick1 <= 6 and assert 1 <= pick2 <= 6
assert pick1 != pick2
roll()
print("You picked %s-%s, and rolls are %s" % (pick1, pick2, dice))
if # blah blah blah
self.cash += 7 * bet + (bet * 2) // 12
print(self.cash)
def trio_ricochet(self, bet, pick1, pick2): # zero house edge
self.cash = twister.check(self, bet)
assert isinstance(pick, int)
assert 1 <= pick1 <= 6 and 1 <= pick2 <= 6
assert pick1 != pick2
roll()
print("You picked %s-%s, and rolls are %s" % (pick1, pick2, dice))
if pairs == (2, pick1, pick2):
self.cash += 72 * bet
print(self.cash)
def trio_stooge(self, bet, pick1, pick2, pick3) # zero house edge
self.cash = twister.check(self, bet)
assert isinstance(pick, int)
assert 1 <= pick1 <= 6 and 1 <= pick2 <= 6 and 1 <= pick3 <= 6
assert pick1 != pick2 and pick2 != pick3 and pick1 != pick3
roll()
print("You picked %s-%s-%s, and rolls are %s" % (pick1, pick2, pick3, dice))
if result == sorted([pick1, pick2, pick3]):
self.cash == 36 * bet
print(self.cash)