-
Notifications
You must be signed in to change notification settings - Fork 0
/
ccount_agent.py
131 lines (126 loc) · 2.03 KB
/
ccount_agent.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
"""
A collection of card-counting strategies
Names are suffixed by their level (we pick 2 per level)
"""
# card value dictionaries
# level 1
hi_lo_dict = dict([
(0, -1),
(1, 1),
(2, 1),
(3, 1),
(4, 1),
(5, 1),
(6, 0),
(7, 0),
(8, 0),
(9, -1),
(10, -1),
(11, -1),
(12, -1)
])
ko_dict = dict([
(0, -1),
(1, 1),
(2, 1),
(3, 1),
(4, 1),
(5, 1),
(6, 1),
(7, 0),
(8, 0),
(9, -1),
(10, -1),
(11, -1),
(12, -1)
])
# level 2
zen_dict = dict([
(0, -1),
(1, 1),
(2, 1),
(3, 2),
(4, 2),
(5, 2),
(6, 1),
(7, 0),
(8, 0),
(9, -2),
(10, -2),
(11, -2),
(12, -2)
])
ten_dict = dict([
(0, 1),
(1, 1),
(2, 1),
(3, 1),
(4, 1),
(5, 1),
(6, 1),
(7, 1),
(8, 1),
(9, -2),
(10, -2),
(11, -2),
(12, -2)
])
# level 3
halves_dict = dict([
(0, -1),
(1, 0.5),
(2, 1),
(3, 1),
(4, 1.5),
(5, 1),
(6, 0.5),
(7, 0),
(8, -0.5),
(9, -1),
(10, -1),
(11, -1),
(12, -1)
])
uston_dict = dict([
(0, 0),
(1, 1),
(2, 2),
(3, 2),
(4, 3),
(5, 2),
(6, 2),
(7, 1),
(8, -1),
(9, 3),
(10, 3),
(11, 3),
(12, -3)
])
# return current count value
def ccount(name: str, value: int) -> float:
# level 1
if name == "hi_lo":
return hi_lo_dict.get(value)
elif name == "ko":
return ko_dict.get(value)
# level 2
elif name == "zen":
return zen_dict.get(value)
elif name == "ten":
return ten_dict.get(value)
# level 3
elif name == "halves":
return halves_dict.get(value)
elif name == "uston":
return uston_dict.get(value)
# invalid input
else:
raise Exception("Invalid card-counting method provided!")
# a state-based weighted card-counting action heuristic
def ccount_action(state: int, count: float):
if state == 1 and count > (26/4):
return 9
elif count > 0:
return 7
else:
return 8