-
Notifications
You must be signed in to change notification settings - Fork 0
/
OddsSimulator.py
50 lines (42 loc) · 1.78 KB
/
OddsSimulator.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
from Strategies import Strategies
from VideoPoker import VideoPoker
from PayoutTable import PayoutTable
class OddsSimulator(object):
global_calc = 0
def __init__(self, payout_table, video_poker=None, strategies=None, optimal_hold_list=None):
self.video_poker = VideoPoker()
self.strategies = Strategies()
self.payout_table = PayoutTable(payout_table)
self.optimal_holds_list = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
def run_simulation(self, hand):
for k in range(32):
self.optimal_holds_list[k] = \
self._run_strategy(hand, self.strategies[k], self.payout_table, self.video_poker)
max = 0.0
max_index = 0
for k in range(32):
if self.optimal_holds_list[k] > max:
max_index = k
max = self.optimal_holds_list[k]
# print sum(self.optimal_holds_list) / 32.0
print ""
print "/////////////////////////////"
print ""
# print "Player Should Hold: "
# self._standard_io_formatter(hand, self.strategies[max_index])
print ""
print "Optimal Payout for the best strategy for the Hand given: %f" % max
def populate_list_to_object(self, obj, ls):
obj.populate(ls)
def _standard_io_formatter(self, hand, strategy):
for k in range(5):
if strategy[k] == 1:
self.print_object_info(hand[k])
def _run_strategy(self, hand, strategy, payout_table, video_poker):
return strategy.get_payout_from_strategy(hand, payout_table, video_poker)
def print_object_info(self, obj):
obj.print_info()
print ""
def print_percent_done(self, calcs):
pass