@@ -12,7 +12,7 @@ class TestGrudger(TestPlayer):
12
12
name = "Grudger"
13
13
player = axl .Grudger
14
14
expected_classifier = {
15
- "memory_depth" : float (' inf' ),
15
+ "memory_depth" : float (" inf" ),
16
16
"stochastic" : False ,
17
17
"makes_use_of" : set (),
18
18
"long_run_time" : False ,
@@ -276,3 +276,34 @@ def test_strategy(self):
276
276
expected_actions = actions ,
277
277
init_kwargs = {"n" : 1 , "d" : 1 , "c" : 1 },
278
278
)
279
+
280
+
281
+ class TestSpitefulCC (TestPlayer ):
282
+
283
+ name = "SpitefulCC"
284
+ player = axl .SpitefulCC
285
+ expected_classifier = {
286
+ "memory_depth" : float ("inf" ), # Long memory
287
+ "stochastic" : False ,
288
+ "makes_use_of" : set (),
289
+ "long_run_time" : False ,
290
+ "inspects_source" : False ,
291
+ "manipulates_source" : False ,
292
+ "manipulates_state" : False ,
293
+ }
294
+
295
+ def test_strategy (self ):
296
+ # If opponent defects at any point then the player will defect forever.
297
+ # Cooperates for the first 2 turns.
298
+ opponent = axl .Cooperator ()
299
+ actions = [(C , C )] * 20
300
+ self .versus_test (opponent , expected_actions = actions )
301
+
302
+ opponent = axl .Defector ()
303
+ actions = [(C , D )] * 2 + [(D , D )] * 20
304
+ self .versus_test (opponent , expected_actions = actions )
305
+
306
+ opponent_actions = [D ] * 20 + [C ] * 20
307
+ opponent = axl .MockPlayer (actions = opponent_actions )
308
+ actions = [(C , D )] * 2 + [(D , D )] * 18 + [(D , C )] * 20
309
+ self .versus_test (opponent , expected_actions = actions )
0 commit comments