@@ -288,6 +288,7 @@ def test_set_n(self):
288
288
init_kwargs = init_kwargs )
289
289
290
290
def test_set_d_and_c (self ):
291
+ # Sets the number of D's then C's in the grudge response.
291
292
init_kwargs = {'d' : 3 , 'c' : 3 }
292
293
grudge_response_d = [(D , D )] * 3 + [(C , D )] * 3
293
294
grudge_response_c = [(D , C )] * 3 + [(C , C )] * 3
@@ -305,6 +306,53 @@ def test_set_d_and_c(self):
305
306
self .versus_test (opponent , expected_actions = actions ,
306
307
init_kwargs = init_kwargs )
307
308
309
+ def test_edge_case_n_is_zero (self ):
310
+ # Always uses grudge response.
311
+ init_kwargs = {'n' : 0 }
312
+ grudge_response_d = [(D , D )] * 4 + [(C , D )] * 2
313
+ grudge_response_c = [(D , C )] * 4 + [(C , C )] * 2
314
+
315
+ opponent = axl .Defector ()
316
+ actions = grudge_response_d * 5
317
+ self .versus_test (opponent , expected_actions = actions ,
318
+ init_kwargs = init_kwargs )
319
+
320
+ opponent = axl .Cooperator ()
321
+ actions = grudge_response_c * 5
322
+ self .versus_test (opponent , expected_actions = actions ,
323
+ init_kwargs = init_kwargs )
324
+
325
+ def test_edge_case_d_is_zero (self ):
326
+ # Grudge response is only C, so acts like Cooperator.
327
+ init_kwargs = {'d' : 0 }
328
+
329
+ opponent = axl .Defector ()
330
+ actions = [(C , D )] * 5
331
+ self .versus_test (opponent , expected_actions = actions ,
332
+ init_kwargs = init_kwargs )
333
+
334
+ opponent = axl .Alternator ()
335
+ actions = [(C , C ), (C , D )] * 5
336
+ self .versus_test (opponent , expected_actions = actions ,
337
+ init_kwargs = init_kwargs )
338
+
339
+ def test_edge_case_c_is_zero (self ):
340
+ # Grudge response is a set number of D's (defaults to 4)
341
+ init_kwargs = {'c' : 0 }
342
+
343
+ opponent = axl .Defector ()
344
+ actions = [(C , D )] + [(D , D )] * 10
345
+ self .versus_test (opponent , expected_actions = actions ,
346
+ init_kwargs = init_kwargs )
347
+
348
+ opponent_actions = [C ] * 10 + [D ]
349
+ opponent = axl .MockPlayer (actions = opponent_actions )
350
+ actions_start = [(C , C )] * 10 + [(C , D )]
351
+ subsequent = [(D , C )] * 4 + [(C , C )] * 6 + [(C , D )]
352
+ actions = actions_start + subsequent * 5
353
+ self .versus_test (opponent , expected_actions = actions ,
354
+ init_kwargs = init_kwargs )
355
+
308
356
def test_repr (self ):
309
357
default_player = self .player ()
310
358
self .assertEqual (repr (default_player ),
0 commit comments