1111 TypeVar ,
1212 Union ,
1313)
14-
14+ import warnings
1515import yaml
1616
1717from axelrod .player import Player
@@ -59,15 +59,12 @@ def classify_player(self, player: Type[Player]) -> T:
5959
6060
6161stochastic = Classifier [bool ]("stochastic" , lambda _ : False )
62- memory_depth = Classifier [Union [float , int ]]("memory_depth" ,
63- lambda _ : float ("inf" ))
62+ memory_depth = Classifier [Union [float , int ]]("memory_depth" , lambda _ : float ("inf" ))
6463makes_use_of = Classifier [Optional [Set [Text ]]]("makes_use_of" , lambda _ : None )
6564long_run_time = Classifier [bool ]("long_run_time" , lambda _ : False )
6665inspects_source = Classifier [Optional [bool ]]("inspects_source" , lambda _ : None )
67- manipulates_source = Classifier [Optional [bool ]]("manipulates_source" ,
68- lambda _ : None )
69- manipulates_state = Classifier [Optional [bool ]]("manipulates_state" ,
70- lambda _ : None )
66+ manipulates_source = Classifier [Optional [bool ]]("manipulates_source" , lambda _ : None )
67+ manipulates_state = Classifier [Optional [bool ]]("manipulates_state" , lambda _ : None )
7168
7269# Should list all known classifiers.
7370all_classifiers = [
@@ -178,7 +175,8 @@ def __getitem__(
178175 raise KeyError ("Unknown classifier" )
179176
180177 def classify_player_for_this_classifier (
181- player : Union [Player , Type [Player ]]) -> Any :
178+ player : Union [Player , Type [Player ]]
179+ ) -> Any :
182180 def try_lookup () -> Any :
183181 try :
184182 player_classifiers = cls .all_player_dicts [player .name ]
@@ -192,9 +190,16 @@ def try_lookup() -> Any:
192190 if not isinstance (player , Player ):
193191 try :
194192 player = player ()
193+ warnings .warn (
194+ "Classifiers are intended to run on player instances. "
195+ "Passed player {} was initialized with default "
196+ "arguments." .format (player .name )
197+ )
195198 except :
196- # Can't use the instances, so just go by name.
197- return try_lookup ()
199+ # All strategies must have trivial initializers.
200+ raise Exception (
201+ "Passed player class doesn't have a trivial initializer."
202+ )
198203
199204 # Factory-generated players won't exist in the table. As well, some
200205 # players, like Random, may change classifiers at construction time;
0 commit comments