-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgame.py
More file actions
59 lines (42 loc) · 1.22 KB
/
Copy pathgame.py
File metadata and controls
59 lines (42 loc) · 1.22 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
#game.py
import wheel as wh
import player as pl
import random
import table as tab
class Game:
def __init__( self, wheel, table ):
self.wheel = wheel
self.table = table
def getBets(self, player):
if player.isPlaying():
new_bets = player.placeBets()
def spin(self, wheel):
self.current_bin = self.wheel.spin()
def displayBetsAndResults(self):
for b in self.table:
print 'Bet: ', b, ' result is ', self.current_bin
def resolveBets( self, player ):
for b in self.table:
if b.outcome in self.current_bin.outcomes:
player.processWin(b)
else:
player.processLose(b)
self.table.clearBets()
def cycle( self, player, display = False ):
self.getBets(player)
self.spin(self.wheel)
if display:
self.displayBetsAndResults()
self.resolveBets(player)
if __name__ == '__main__':
r = random.Random()
w = wh.Wheel(r)
b = wh.BinBuilder()
b.buildBins(w)
t = tab.Table(10000)
g = Game(w, t)
p = pl.SimplePlayer(t, w)
b = p.makeMyBet()
for i in xrange(12):
g.cycle(p, True)
print p