@@ -366,47 +366,74 @@ def test_strategy(self):
366
366
# punishment co-players for his/her mistake
367
367
opponent_actions = [C ] * 10 + [D ] + [C ] * 10
368
368
opponent = axl .MockPlayer (actions = opponent_actions )
369
- actions = [(C , C )] * 10 + [(C , D )] + [(D , C )] + [(C ,C )] * 9
369
+ actions = [(C , C )] * 10 + [(C , D )] + [(D , C )] + [(C , C )] * 9
370
370
self .versus_test (opponent , expected_actions = actions )
371
371
372
372
# never allow the defection more than once
373
373
opponent_actions = [C ] * 10 + [D ] * 2 + [C ] * 10
374
374
opponent = axl .MockPlayer (actions = opponent_actions )
375
- actions = [(C , C )] * 10 + [(C , D )] + [(D , D )] + [(D ,C )] * 9
375
+ actions = [(C , C )] * 10 + [(C , D )] + [(D , D )] + [(D , C )] * 9
376
376
self .versus_test (opponent , expected_actions = actions )
377
377
378
378
def test_noisy_actions (self ):
379
379
# accept punishment when making a mistake
380
- actions1 = [C ,C , D , C , C , C , C ]
381
- actions2 = [C ,C , C , D , C , C , C ]
380
+ actions1 = [C , C , D , C , C , C , C ]
381
+ actions2 = [C , C , C , D , C , C , C ]
382
382
opponent = axl .MockPlayer (actions = actions2 )
383
- self .versus_test (opponent , expected_actions = list (zip (actions1 ,actions2 )), noise = 0.1 , seed = 20 )
383
+ self .versus_test (
384
+ opponent ,
385
+ expected_actions = list (zip (actions1 , actions2 )),
386
+ noise = 0.1 ,
387
+ seed = 20 ,
388
+ )
384
389
385
390
# recover the cooperation when the opponent cooperated from mutual defection
386
- actions1 = [C ,D , D , D , D , C , C , C ]
387
- actions2 = [D ,D , D , D , C , C , C , C ]
391
+ actions1 = [C , D , D , D , D , C , C , C ]
392
+ actions2 = [D , D , D , D , C , C , C , C ]
388
393
opponent = axl .MockPlayer (actions = actions2 )
389
- self .versus_test (opponent , expected_actions = list (zip (actions1 ,actions2 )), noise = 0 )
394
+ self .versus_test (
395
+ opponent , expected_actions = list (zip (actions1 , actions2 )), noise = 0
396
+ )
390
397
391
398
# recover the cooperation when the player cooperated by mistake from mutual defection
392
- actions1 = [C ,D , D , D , C , C , C , C ]
393
- actions2 = [D ,D , D , D , D , C , C , C ]
399
+ actions1 = [C , D , D , D , C , C , C , C ]
400
+ actions2 = [D , D , D , D , D , C , C , C ]
394
401
opponent = axl .MockPlayer (actions = actions2 )
395
- self .versus_test (opponent , expected_actions = list (zip (actions1 ,actions2 )), noise = 0.1 , seed = 72 )
402
+ self .versus_test (
403
+ opponent ,
404
+ expected_actions = list (zip (actions1 , actions2 )),
405
+ noise = 0.1 ,
406
+ seed = 72 ,
407
+ )
396
408
397
409
# recover the cooperation when the focal and the opponent player cooperated by mistake from mutual defection
398
- actions1 = [C ,D , D , D , C , C , C , C ]
399
- actions2 = [D ,D , D , D , C , C , C , C ]
410
+ actions1 = [C , D , D , D , C , C , C , C ]
411
+ actions2 = [D , D , D , D , C , C , C , C ]
400
412
opponent = axl .MockPlayer (actions = actions2 )
401
- self .versus_test (opponent , expected_actions = list (zip (actions1 ,actions2 )), noise = 0.1 , seed = 72 )
413
+ self .versus_test (
414
+ opponent ,
415
+ expected_actions = list (zip (actions1 , actions2 )),
416
+ noise = 0.1 ,
417
+ seed = 72 ,
418
+ )
402
419
403
420
# in other cases, defect
404
- actions1 = [C ,D , C , C , D , D , D , D ]
405
- actions2 = [D ,D , D , D , D , C , C , D ]
421
+ actions1 = [C , D , C , C , D , D , D , D ]
422
+ actions2 = [D , D , D , D , D , C , C , D ]
406
423
opponent = axl .MockPlayer (actions = actions2 )
407
- self .versus_test (opponent , expected_actions = list (zip (actions1 ,actions2 )), noise = 0.1 , seed = 452 )
424
+ self .versus_test (
425
+ opponent ,
426
+ expected_actions = list (zip (actions1 , actions2 )),
427
+ noise = 0.1 ,
428
+ seed = 452 ,
429
+ )
408
430
409
- actions1 = [C ,D , C , D ]
410
- actions2 = [C ,C , C , D ]
431
+ actions1 = [C , D , C , D ]
432
+ actions2 = [C , C , C , D ]
411
433
opponent = axl .MockPlayer (actions = actions2 )
412
- self .versus_test (opponent , expected_actions = list (zip (actions1 ,actions2 )), noise = 0.1 , seed = 15 )
434
+ self .versus_test (
435
+ opponent ,
436
+ expected_actions = list (zip (actions1 , actions2 )),
437
+ noise = 0.1 ,
438
+ seed = 15 ,
439
+ )
0 commit comments