-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwheel.py
More file actions
209 lines (159 loc) · 6.36 KB
/
Copy pathwheel.py
File metadata and controls
209 lines (159 loc) · 6.36 KB
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
#wheel.py
import bin
import random as r
class Wheel:
def __init__(self, rng):
self.rng = rng
self.all_outcomes = set()
self.bins = tuple( bin.Bin() for i in xrange(38) )
self.labelBins()
def addOutcome(self, number, outcome):
b = self.get(number)
b.add( outcome )
self.all_outcomes.add( outcome )
def getOutcome( self, name ):
for oc in self.all_outcomes:
if oc.name == name:
return oc
def spin(self):
return self.rng.choice( self.bins )
def randomOutcome(self):
return self.rng.sample( self.all_outcomes, 1 )[0]
def get( self, bin ):
return self.bins[bin]
def labelBins( self ):
for i in xrange(37):
self.bins[i].bin_str = 'Bin: ' + str(i)
self.bins[37].bin_str = 'Bin: 00'
def __str__(self):
pass
class NonRandom(r.Random):
def __init__(self):
pass
def setSeed(self, value):
pass
def choice(self, sequence):
pass
##### Check this out JR
##### this is the one I care about
def makeOutcomeString( type, values ):
if len(values ) > 6:
val_string = str(values[0]) + '...' + str(values[-1])
else:
val_string = '-'.join( map( str, values ) )
return type + val_string
class BinBuilder:
def __init__(self):
pass
def buildStraightBets(self, w):
for i in xrange(1, 37):
out_str = makeOutcomeString( bin.o.RouletteBetType.STRAIGHT, [i] )
oc = bin.o.Outcome( out_str , bin.o.AmericanRouletteOdds.STRAIGHT )
w.addOutcome( i, oc )
out_str = makeOutcomeString( bin.o.RouletteBetType.STRAIGHT, [0] )
oc = bin.o.Outcome( out_str, bin.o.AmericanRouletteOdds.STRAIGHT )
w.addOutcome( 0, oc )
out_str = makeOutcomeString( bin.o.RouletteBetType.STRAIGHT, ['00'] )
oc = bin.o.Outcome( out_str, bin.o.AmericanRouletteOdds.STRAIGHT )
w.addOutcome( 37, oc )
def buildSplitBets(self, w):
for i in xrange(1, 36):
other_num = i + 1
values = [i, other_num]
out_str = makeOutcomeString( bin.o.RouletteBetType.SPLIT, values )
oc = bin.o.Outcome( out_str, bin.o.AmericanRouletteOdds.SPLIT )
w.addOutcome( i, oc )
w.addOutcome( other_num, oc )
for i in xrange(1, 34):
other_num = i + 3
values = [i, other_num]
out_str = makeOutcomeString( bin.o.RouletteBetType.SPLIT, values )
oc = bin.o.Outcome( out_str, bin.o.AmericanRouletteOdds.SPLIT )
w.addOutcome( i, oc )
w.addOutcome( other_num, oc )
def buildStreetBets(self, w):
for i in xrange(12):
num1 = 3*i + 1
num2 = 3*i + 2
num3 = 3*i + 3
values = [num1, num2, num3]
out_str = makeOutcomeString( bin.o.RouletteBetType.STREET, values )
oc = bin.o.Outcome( out_str, bin.o.AmericanRouletteOdds.STREET )
w.addOutcome( num1, oc )
w.addOutcome( num2, oc )
w.addOutcome( num3, oc )
def buildLineBets(self, w):
for i in xrange(11):
values = [ 3*i + x for x in xrange(1, 7) ]
out_str = makeOutcomeString( bin.o.RouletteBetType.LINE, values )
oc = bin.o.Outcome( out_str, bin.o.AmericanRouletteOdds.LINE )
for j in values:
w.addOutcome( j, oc )
def buildColumnBets(self, w):
for i in [1, 2, 3]:
values = [ 3*x + i for x in xrange(12) ]
out_str = makeOutcomeString( bin.o.RouletteBetType.COLUMN, values )
oc = bin.o.Outcome( out_str, bin.o.AmericanRouletteOdds.COLUMN )
for j in values:
w.addOutcome( j, oc )
def buildDozenBets(self, w):
for i in [0, 1, 2]:
values = [ 12*i + x for x in xrange(1, 13) ]
out_str = makeOutcomeString( bin.o.RouletteBetType.RANGE, values )
oc = bin.o.Outcome( out_str, bin.o.AmericanRouletteOdds.RANGE )
for j in values:
w.addOutcome( j, oc )
def buildEvenMoneyBets(self, w):
values = bin.o.RouletteNums.RED
out_str = makeOutcomeString( bin.o.RouletteBetType.RED, values )
oc = bin.o.Outcome( out_str, bin.o.AmericanRouletteOdds.RED )
for j in bin.o.RouletteNums.RED:
w.addOutcome( j, oc )
values = bin.o.RouletteNums.BLACK
out_str = makeOutcomeString( bin.o.RouletteBetType.BLACK, values )
oc = bin.o.Outcome( out_str, bin.o.AmericanRouletteOdds.BLACK )
for j in bin.o.RouletteNums.BLACK:
w.addOutcome( j, oc )
values = bin.o.RouletteNums.EVEN
out_str = makeOutcomeString( bin.o.RouletteBetType.EVEN, values )
oc = bin.o.Outcome( out_str, bin.o.AmericanRouletteOdds.EVEN )
for j in values:
w.addOutcome( j, oc )
values = bin.o.RouletteNums.ODD
out_str = makeOutcomeString( bin.o.RouletteBetType.ODD, values )
oc = bin.o.Outcome( out_str, bin.o.AmericanRouletteOdds.ODD )
for j in values:
w.addOutcome( j, oc )
values = bin.o.RouletteNums.LOW
out_str = makeOutcomeString( bin.o.RouletteBetType.LOW, values )
oc = bin.o.Outcome( out_str, bin.o.AmericanRouletteOdds.LOW )
for j in values:
w.addOutcome( j, oc )
values = bin.o.RouletteNums.HIGH
out_str = makeOutcomeString( bin.o.RouletteBetType.HIGH, values )
oc = bin.o.Outcome( out_str, bin.o.AmericanRouletteOdds.HIGH )
for j in values:
w.addOutcome( j, oc )
def buildBins( self, wheel ):
self.buildStraightBets( wheel )
self.buildSplitBets( wheel )
self.buildStreetBets( wheel )
self.buildColumnBets( wheel )
self.buildDozenBets( wheel )
self.buildLineBets( wheel )
self.buildEvenMoneyBets( wheel )
if __name__ == '__main__':
r = r.Random()
ww = Wheel(r)
b = BinBuilder()
b.buildBins(ww)
values = bin.o.RouletteNums.HIGH
out_str = makeOutcomeString( bin.o.RouletteBetType.HIGH, values )
oc = ww.getOutcome(out_str)
print oc
print oc in ww.all_outcomes
for i in xrange(4):
b = ww.spin()
# print b
# print oc in b.outcomes
# print ww.get(37)