@@ -203,37 +203,34 @@ def classify_player_for_this_classifier(
203203
204204 return classify_player_for_this_classifier
205205
206+ @classmethod
207+ def is_basic (cls , s : Union [Player , Type [Player ]]):
208+ """
209+ Defines criteria for a strategy to be considered 'basic'
210+ """
211+ stochastic = cls .__getitem__ ("stochastic" )(s )
212+ depth = cls .__getitem__ ("memory_depth" )(s )
213+ inspects_source = cls .__getitem__ ("inspects_source" )(s )
214+ manipulates_source = cls .__getitem__ ("manipulates_source" )(s )
215+ manipulates_state = cls .__getitem__ ("manipulates_state" )(s )
216+ return (
217+ not stochastic
218+ and not inspects_source
219+ and not manipulates_source
220+ and not manipulates_state
221+ and depth in (0 , 1 )
222+ )
206223
207- Classifiers = _Classifiers ()
208-
209-
210- # Strategy classifiers
224+ @classmethod
225+ def obey_axelrod (cls , s : Union [Player , Type [Player ]]):
226+ """
227+ A function to check if a strategy obeys Axelrod's original tournament
228+ rules.
229+ """
230+ for c in ["inspects_source" , "manipulates_source" , "manipulates_state" ]:
231+ if cls .__getitem__ (c )(s ):
232+ return False
233+ return True
211234
212235
213- def is_basic (s ):
214- """
215- Defines criteria for a strategy to be considered 'basic'
216- """
217- stochastic = Classifiers ["stochastic" ](s )
218- depth = Classifiers ["memory_depth" ](s )
219- inspects_source = Classifiers ["inspects_source" ](s )
220- manipulates_source = Classifiers ["manipulates_source" ](s )
221- manipulates_state = Classifiers ["manipulates_state" ](s )
222- return (
223- not stochastic
224- and not inspects_source
225- and not manipulates_source
226- and not manipulates_state
227- and depth in (0 , 1 )
228- )
229-
230-
231- def obey_axelrod (s ):
232- """
233- A function to check if a strategy obeys Axelrod's original tournament
234- rules.
235- """
236- for c in ["inspects_source" , "manipulates_source" , "manipulates_state" ]:
237- if Classifiers [c ](s ):
238- return False
239- return True
236+ Classifiers = _Classifiers ()
0 commit comments