1313 Union ,
1414)
1515
16- import yaml
16+ from axelrod . makes_use_of import makes_use_of
1717from axelrod .player import Player
18+ import yaml
1819
1920ALL_CLASSIFIERS_PATH = "data/all_classifiers.yml"
2021
@@ -59,12 +60,18 @@ def classify_player(self, player: Type[Player]) -> T:
5960
6061
6162stochastic = Classifier [bool ]("stochastic" , lambda _ : False )
62- memory_depth = Classifier [Union [float , int ]]("memory_depth" , lambda _ : float ("inf" ))
63- makes_use_of = Classifier [Optional [Set [Text ]]]("makes_use_of" , lambda _ : None )
63+ memory_depth = Classifier [Union [float , int ]](
64+ "memory_depth" , lambda _ : float ("inf" )
65+ )
66+ makes_use_of = Classifier [Optional [Set [Text ]]]("makes_use_of" , makes_use_of )
6467long_run_time = Classifier [bool ]("long_run_time" , lambda _ : False )
6568inspects_source = Classifier [Optional [bool ]]("inspects_source" , lambda _ : None )
66- manipulates_source = Classifier [Optional [bool ]]("manipulates_source" , lambda _ : None )
67- manipulates_state = Classifier [Optional [bool ]]("manipulates_state" , lambda _ : None )
69+ manipulates_source = Classifier [Optional [bool ]](
70+ "manipulates_source" , lambda _ : None
71+ )
72+ manipulates_state = Classifier [Optional [bool ]](
73+ "manipulates_state" , lambda _ : None
74+ )
6875
6976# Should list all known classifiers.
7077all_classifiers = [
@@ -77,6 +84,8 @@ def classify_player(self, player: Type[Player]) -> T:
7784 manipulates_state ,
7885]
7986
87+ all_classifiers_map = {c .name : c .classify_player for c in all_classifiers }
88+
8089
8190def rebuild_classifier_table (
8291 classifiers : List [Classifier ],
@@ -209,7 +218,13 @@ def try_lookup() -> Any:
209218 return player .classifier [key ]
210219
211220 # Try to find the name in the all_player_dicts, read from disk.
212- return try_lookup ()
221+ lookup = try_lookup ()
222+ if lookup is not None :
223+ return lookup
224+
225+ # If we can't find it, then return a function that calculates fresh.
226+ global all_classifiers_map
227+ return all_classifiers_map [key ](player )
213228
214229 return classify_player_for_this_classifier
215230
0 commit comments