1- from axelrod .actions import Actions
1+ from axelrod .actions import Actions , Action
22from axelrod .player import Player
33from axelrod .random_ import random_choice
44
@@ -31,7 +31,7 @@ class CollectiveStrategy(Player):
3131 'manipulates_state' : False
3232 }
3333
34- def strategy (self , opponent ) :
34+ def strategy (self , opponent : Player ) -> Action :
3535 turn = len (self .history )
3636 if turn == 0 :
3737 return C
@@ -61,7 +61,7 @@ class Prober(Player):
6161 'manipulates_state' : False
6262 }
6363
64- def strategy (self , opponent ) :
64+ def strategy (self , opponent : Player ) -> Action :
6565 turn = len (self .history )
6666 if turn == 0 :
6767 return D
@@ -94,7 +94,7 @@ class Prober2(Player):
9494 'manipulates_state' : False
9595 }
9696
97- def strategy (self , opponent ) :
97+ def strategy (self , opponent : Player ) -> Action :
9898 turn = len (self .history )
9999 if turn == 0 :
100100 return D
@@ -127,7 +127,7 @@ class Prober3(Player):
127127 'manipulates_state' : False
128128 }
129129
130- def strategy (self , opponent ) :
130+ def strategy (self , opponent : Player ) -> Action :
131131 turn = len (self .history )
132132 if turn == 0 :
133133 return D
@@ -165,7 +165,7 @@ class Prober4(Player):
165165 'manipulates_state' : False
166166 }
167167
168- def __init__ (self ):
168+ def __init__ (self ) -> None :
169169 super ().__init__ ()
170170 self .init_sequence = [
171171 C , C , D , C , D , D , D , C , C , D , C , D , C , C , D , C , D , D , C , D
@@ -174,7 +174,7 @@ def __init__(self):
174174 self .unjust_Ds = 0
175175 self .turned_defector = False
176176
177- def strategy (self , opponent ) :
177+ def strategy (self , opponent : Player ) -> Action :
178178 if not self .history :
179179 return self .init_sequence [0 ]
180180 turn = len (self .history )
@@ -219,7 +219,7 @@ class HardProber(Player):
219219 'manipulates_state' : False
220220 }
221221
222- def strategy (self , opponent ) :
222+ def strategy (self , opponent : Player ) -> Action :
223223 turn = len (self .history )
224224 if turn == 0 :
225225 return D
@@ -258,7 +258,7 @@ class NaiveProber(Player):
258258 'manipulates_state' : False
259259 }
260260
261- def __init__ (self , p = 0.1 ):
261+ def __init__ (self , p : Player = 0.1 ) -> None :
262262 """
263263 Parameters
264264 ----------
@@ -270,7 +270,7 @@ def __init__(self, p=0.1):
270270 if (self .p == 0 ) or (self .p == 1 ):
271271 self .classifier ['stochastic' ] = False
272272
273- def strategy (self , opponent ) :
273+ def strategy (self , opponent : Player ) -> Action :
274274 # First move
275275 if len (self .history ) == 0 :
276276 return C
@@ -281,7 +281,7 @@ def strategy(self, opponent):
281281 choice = random_choice (1 - self .p )
282282 return choice
283283
284- def __repr__ (self ):
284+ def __repr__ (self ) -> str :
285285 return "%s: %s" % (self .name , round (self .p , 2 ))
286286
287287
@@ -314,11 +314,11 @@ class RemorsefulProber(NaiveProber):
314314 'manipulates_state' : False
315315 }
316316
317- def __init__ (self , p = 0.1 ):
317+ def __init__ (self , p : float = 0.1 ) -> None :
318318 super ().__init__ (p )
319319 self .probing = False
320320
321- def strategy (self , opponent ) :
321+ def strategy (self , opponent : Player ) -> Action :
322322 # First move
323323 if len (self .history ) == 0 :
324324 return C
0 commit comments