11from numpy .random import choice
22
3- from axelrod .actions import Actions
3+ from axelrod .actions import Actions , Action
44from axelrod .player import Player
55from axelrod .random_ import random_choice
66
77C , D = Actions .C , Actions .D
88
9+ #Type Hinting has not finished yet
10+ #Lines 9 and 10 will be deleted
911
10- def is_stochastic_matrix (m , ep = 1e-8 ):
12+ def is_stochastic_matrix (m , ep = 1e-8 ) -> bool :
1113 """Checks that the matrix m (a list of lists) is a stochastic matrix."""
1214 for i in range (len (m )):
1315 for j in range (len (m [i ])):
@@ -29,7 +31,7 @@ class SimpleHMM(object):
2931 """
3032
3133 def __init__ (self , transitions_C , transitions_D , emission_probabilities ,
32- initial_state ):
34+ initial_state ) -> None :
3335 """
3436 Params
3537 ------
@@ -43,7 +45,7 @@ def __init__(self, transitions_C, transitions_D, emission_probabilities,
4345 self .emission_probabilities = emission_probabilities
4446 self .state = initial_state
4547
46- def is_well_formed (self ):
48+ def is_well_formed (self ) -> bool :
4749 """
4850 Determines if the HMM parameters are well-formed:
4951 - Both matrices are stochastic
@@ -61,7 +63,7 @@ def is_well_formed(self):
6163 return False
6264 return True
6365
64- def __eq__ (self , other ):
66+ def __eq__ (self , other ) -> bool :
6567 """Equality of two HMMs"""
6668 check = True
6769 for attr in ["transitions_C" , "transitions_D" ,
@@ -70,7 +72,7 @@ def __eq__(self, other):
7072 return check
7173
7274
73- def move (self , opponent_action ):
75+ def move (self , opponent_action ) -> Action :
7476 """Changes state and computes the response action.
7577
7678 Parameters
@@ -111,7 +113,7 @@ class HMMPlayer(Player):
111113
112114 def __init__ (self , transitions_C = None , transitions_D = None ,
113115 emission_probabilities = None , initial_state = 0 ,
114- initial_action = C ):
116+ initial_action = C ) -> None :
115117 super ().__init__ ()
116118 if not transitions_C :
117119 transitions_C = [[1 ]]
@@ -126,7 +128,7 @@ def __init__(self, transitions_C=None, transitions_D=None,
126128 self .state = self .hmm .state
127129 self .classifier ['stochastic' ] = self .is_stochastic ()
128130
129- def is_stochastic (self ):
131+ def is_stochastic (self ) -> bool :
130132 """Determines if the player is stochastic."""
131133 # If the transitions matrices and emission_probabilities are all 0 or 1
132134 # Then the player is stochastic
@@ -138,7 +140,7 @@ def is_stochastic(self):
138140 return True
139141 return False
140142
141- def strategy (self , opponent ):
143+ def strategy (self , opponent ) -> Action :
142144 if len (self .history ) == 0 :
143145 return self .initial_action
144146 else :
@@ -148,7 +150,7 @@ def strategy(self, opponent):
148150 self .state = self .hmm .state
149151 return action
150152
151- def reset (self ):
153+ def reset (self ) -> None :
152154 super ().reset ()
153155 self .hmm .state = self .initial_state
154156 self .state = self .hmm .state
@@ -175,7 +177,7 @@ class EvolvedHMM5(HMMPlayer):
175177 'manipulates_state' : False
176178 }
177179
178- def __init__ (self ):
180+ def __init__ (self ) -> None :
179181 initial_state = 3
180182 initial_action = C
181183 t_C = [[1 , 0 , 0 , 0 , 0 ],
0 commit comments