-
Notifications
You must be signed in to change notification settings - Fork 2
/
customspec.py
168 lines (113 loc) · 5.46 KB
/
customspec.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
from auctions import AuctionPlayerSpecification
class CustomWeaklyIncreasing(AuctionPlayerSpecification):
def __init__(self, range_list, no_jumps):
self.range_list = range_list
super(CustomWeaklyIncreasing, self).__init__(
player_types=range(len(range_list)),
player_actions=range(len(range_list)),
no_jumps=no_jumps)
def get_bid_range(self, valuation, previous_bid):
min_bid = previous_bid
max_bid = max(valuation - 1, 0)
expected_min_bid, expected_max_bid = self.range_list[valuation]
if min_bid < expected_min_bid:
min_bid = min_bid
if max_bid > expected_max_bid:
max_bid = expected_max_bid
return min_bid, max_bid
class ThreePlayersFirsPriceTiesSpec(AuctionPlayerSpecification):
player_valuations = None
def __init__(self, no_jumps):
super(ThreePlayersFirsPriceTiesSpec, self).__init__(
player_types=ThreePlayersFirsPriceTiesSpec.player_valuations,
player_actions=ThreePlayersFirsPriceTiesSpec.player_valuations,
no_jumps=no_jumps)
def get_bid_range(self, valuation, previous_bid):
min_bid = previous_bid
max_bid = max(valuation - 1, 0)
if 2 <= valuation <= 4 and min_bid == 0:
min_bid = 1
elif valuation >= 5 and min_bid < 2:
min_bid = 2
return min_bid, max_bid
class FivePlayerSpecification(AuctionPlayerSpecification):
player_valuations = range(0, 5)
def __init__(self, no_jumps):
super(FivePlayerSpecification, self).__init__(player_types=FivePlayerSpecification.player_valuations,
player_actions=FivePlayerSpecification.player_valuations,
no_jumps=no_jumps)
def get_bid_range(self, valuation, previous_bid):
min_bid = previous_bid
max_bid = max(valuation - 1, 0)
return min_bid, max_bid
class WeaklyIncreasing6PlayerSpecification(AuctionPlayerSpecification):
player_valuations = range(0, 6)
def __init__(self, no_jumps):
super(WeaklyIncreasing6PlayerSpecification, self).__init__(
player_types=SixPlayerSpecification.player_valuations,
player_actions=SixPlayerSpecification.player_valuations,
no_jumps=no_jumps)
def get_bid_range(self, valuation, previous_bid):
min_bid = previous_bid
max_bid = max(valuation - 1, 0)
return min_bid, max_bid
class SevenPlayerSpecification(AuctionPlayerSpecification):
player_valuations = range(0, 7)
def __init__(self, no_jumps):
super(SevenPlayerSpecification, self).__init__(player_types=SevenPlayerSpecification.player_valuations,
player_actions=SevenPlayerSpecification.player_valuations,
no_jumps=no_jumps)
def get_bid_range(self, valuation, previous_bid):
min_bid = previous_bid
max_bid = max(valuation - 1, 0)
if valuation >= 2 and min_bid == 0:
min_bid = 1
return min_bid, max_bid
class SixPlayerSpecification(AuctionPlayerSpecification):
player_valuations = range(0, 6)
def __init__(self, no_jumps):
super(SixPlayerSpecification, self).__init__(player_types=SixPlayerSpecification.player_valuations,
player_actions=SixPlayerSpecification.player_valuations,
no_jumps=no_jumps)
def get_bid_range(self, valuation, previous_bid):
min_bid = previous_bid
max_bid = max(valuation - 1, 0)
if valuation >= 2 and min_bid == 0:
min_bid = 1
return min_bid, max_bid
class ElevenPlayerSpecification(AuctionPlayerSpecification):
player_valuations = range(0, 11)
def __init__(self, no_jumps):
super(ElevenPlayerSpecification, self).__init__(player_types=ElevenPlayerSpecification.player_valuations,
player_actions=ElevenPlayerSpecification.player_valuations,
no_jumps=no_jumps)
def get_bid_range(self, valuation, previous_bid):
min_bid = previous_bid
max_bid = min(valuation - 1, 6)
if valuation >= 3 and min_bid == 0:
min_bid = 1
if valuation == 5:
max_bid = 3
elif valuation == 6:
max_bid = 4
elif 7 <= valuation <= 8:
max_bid = 5
return min_bid, max_bid
class ThirteenPlayerSpecification(AuctionPlayerSpecification):
player_valuations = range(0, 13)
def __init__(self, no_jumps):
super(ThirteenPlayerSpecification, self).__init__(player_types=ThirteenPlayerSpecification.player_valuations,
player_actions=ThirteenPlayerSpecification.player_valuations,
no_jumps=no_jumps)
def get_bid_range(self, valuation, previous_bid):
min_bid = previous_bid
max_bid = valuation - 1
if valuation >= 3 and min_bid == 0:
min_bid = 1
if 6 <= valuation <= 8:
max_bid = valuation - 2
elif 9 <= valuation <= 10:
max_bid = valuation - 3
elif 11 <= valuation <= 12:
max_bid = valuation - 4
return min_bid, max_bid