1
1
from axelrod import Actions , Player
2
+ from axelrod .actions import Action
2
3
3
4
C , D = Actions .C , Actions .D
4
5
@@ -29,7 +30,7 @@ class Grudger(Player):
29
30
}
30
31
31
32
@staticmethod
32
- def strategy (opponent ) :
33
+ def strategy (opponent : Player ) -> Action :
33
34
"""Begins by playing C, then plays D for the remaining rounds if the
34
35
opponent ever plays D."""
35
36
if opponent .defections :
@@ -52,14 +53,14 @@ class ForgetfulGrudger(Player):
52
53
'manipulates_state' : False
53
54
}
54
55
55
- def __init__ (self ):
56
+ def __init__ (self ) -> None :
56
57
"""Initialised the player."""
57
58
super ().__init__ ()
58
59
self .mem_length = 10
59
60
self .grudged = False
60
61
self .grudge_memory = 0
61
62
62
- def strategy (self , opponent ) :
63
+ def strategy (self , opponent : Player ) -> Action :
63
64
"""Begins by playing C, then plays D for mem_length rounds if the
64
65
opponent ever plays D."""
65
66
if self .grudge_memory >= self .mem_length :
@@ -97,7 +98,7 @@ class OppositeGrudger(Player):
97
98
}
98
99
99
100
@staticmethod
100
- def strategy (opponent ) :
101
+ def strategy (opponent : Player ) -> Action :
101
102
"""Begins by playing D, then plays C for the remaining rounds if the
102
103
opponent ever plays C."""
103
104
if opponent .cooperations :
@@ -120,7 +121,7 @@ class Aggravater(Player):
120
121
}
121
122
122
123
@staticmethod
123
- def strategy (opponent ) :
124
+ def strategy (opponent : Player ) -> Action :
124
125
if len (opponent .history ) < 3 :
125
126
return D
126
127
elif opponent .defections :
@@ -151,13 +152,13 @@ class SoftGrudger(Player):
151
152
'manipulates_state' : False
152
153
}
153
154
154
- def __init__ (self ):
155
+ def __init__ (self ) -> None :
155
156
"""Initialised the player."""
156
157
super ().__init__ ()
157
158
self .grudged = False
158
159
self .grudge_memory = 0
159
160
160
- def strategy (self , opponent ) :
161
+ def strategy (self , opponent : Player ) -> Action :
161
162
"""Begins by playing C, then plays D, D, D, D, C, C against a defection
162
163
"""
163
164
if self .grudged :
@@ -201,7 +202,7 @@ class GrudgerAlternator(Player):
201
202
'manipulates_state' : False
202
203
}
203
204
204
- def strategy (self , opponent ) :
205
+ def strategy (self , opponent : Player ) -> Action :
205
206
"""Begins by playing C, then plays Alternator for the remaining rounds
206
207
if the opponent ever plays D."""
207
208
if opponent .defections :
@@ -232,7 +233,7 @@ class EasyGo(Player):
232
233
}
233
234
234
235
@staticmethod
235
- def strategy (opponent ) :
236
+ def strategy (opponent : Player ) -> Action :
236
237
"""Begins by playing D, then plays C for the remaining rounds if the
237
238
opponent ever plays D."""
238
239
if opponent .defections :
0 commit comments