@@ -442,14 +442,15 @@ def test_strategy(self):
442
442
443
443
# Now we have to test the detect-random logic, which doesn't pick up
444
444
# until after 26 turns. So we need a big sample.
445
- actions = [(C , D ), (D , D ), (D , D ), (D , D ), (D , D ), (D , C ), (C , C ), ( C , D ),
446
- (C , C ), (D , D ), (D , C ), (C , C ), (C , D ), (D , D ), ( C , D ), (D , D ),
447
- ( D , C ), (C , C ), (D , C ), (C , C ), (C , D ), ( D , D ), (D , C ), (C , D ),
448
- (D , C ), (C , C ), (C , D ),
445
+ actions = [(C , D ), (D , D ), (D , D ), (D , D ), (D , D ), (D , C ), (C , C ),
446
+ (C , D ), (C , C ), (D , D ), (D , C ), (C , C ), (C , D ), (D , D ),
447
+ ( C , D ), (D , D ), (D , C ), (C , C ), (D , C ), (C , C ), (C , D ),
448
+ ( D , D ), (D , C ), (C , D ), ( D , C ), (C , C ), ( C , D ),
449
449
# Success detect random opponent for remaining turns.
450
- (D , D ),(D , D ),(D , D ),(D , C ),(D , D ),(D , C ),(D , D ),(D , C ),(D , D ),
451
- (D , C ),(D , C ),(D , D ),(D , D ),(D , C ),(D , C ),(D , C ),(D , C ),(D , D ),
452
- (D , C ),(D , C ),(D , C ),(D , C ),(D , D )]
450
+ (D , D ), (D , D ), (D , D ), (D , C ), (D , D ), (D , C ), (D , D ),
451
+ (D , C ), (D , D ), (D , C ), (D , C ), (D , D ), (D , D ), (D , C ),
452
+ (D , C ), (D , C ), (D , C ), (D , D ), (D , C ), (D , C ), (D , C ),
453
+ (D , C ), (D , D )]
453
454
self .versus_test (axelrod .Random (0.5 ), expected_actions = actions , seed = 10 )
454
455
455
456
class TestBorufsen (TestPlayer ):
@@ -475,16 +476,21 @@ def test_strategy(self):
475
476
self .versus_test (axelrod .Defector (), expected_actions = actions )
476
477
477
478
# Alternates with additional coop, every sixth turn
478
- # Won't be labeled as random, since 2/3 of opponent's C follow player's C
479
- # `flip_next_defect` will get set on the sixth turn, which changes the seventh action
479
+ # Won't be labeled as random, since 2/3 of opponent's C follow
480
+ # player's C
481
+ # `flip_next_defect` will get set on the sixth turn, which changes the
482
+ # seventh action
480
483
# Note that the first two turns of each period of six aren't
481
- # marked as echoes, and the third isn't marked that way until the fourth turn.
484
+ # marked as echoes, and the third isn't marked that way until the
485
+ # fourth turn.
482
486
actions = [(C , C ), (C , D ), (D , C ), (C , D ), (D , C ), (C , D )] * 20
483
487
self .versus_test (axelrod .Alternator (), expected_actions = actions )
484
488
485
489
# Basically does tit-for-tat against Win-Shift, Lose-Stay D
486
- # After 26 turns, will detect random since half of opponent's C follow Cs
487
- # Coming out of it, there will be new pattern. Then random is detected again.
490
+ # After 26 turns, will detect random since half of opponent's C follow
491
+ # Cs
492
+ # Coming out of it, there will be new pattern. Then random is detected
493
+ # again.
488
494
actions = [(C , D ), (D , C ), (C , C )] * 8 + \
489
495
[(C , D ), (D , C )] + [(D , C )] * 25 + \
490
496
[(D , C )] + [(C , C ), (C , D ), (D , C )] * 8 + \
@@ -505,7 +511,7 @@ class TestCave(TestPlayer):
505
511
}
506
512
507
513
def test_strategy (self ):
508
- actions = [(C , C )] * 100
514
+ actions = [(C , C )] * 100
509
515
self .versus_test (axelrod .Cooperator (), expected_actions = actions )
510
516
511
517
# It will take until turn 18 to respond decide to repond D->D
@@ -531,16 +537,16 @@ def test_strategy(self):
531
537
532
538
#Here it will take until turn 40 to detect random and defect
533
539
actions = [(C , C )]
534
- actions += [(C , D ), (D , C ), (C , D ), (D , C ), (C , D ), (C , C ), (C , D ),
535
- (C , C ), (C , D ), (D , C ), (C , D ), (D , C ), (C , D ), (D , C ),
536
- (C , D ), (C , C ), (C , D ), (D , C ), (C , D ), (D , C ), (C , D ),
537
- (D , C ), (C , D ), (C , C ), (C , D ), (C , C ), (C , D ), (C , C ),
538
- (C , D ), (D , C ), (C , D ), (D , C ), (C , D ), (D , C ), (C , D )] #Randomly choose
540
+ actions += [(C , D ), (D , C ), (C , D ), (D , C ), (C , D ), (C , C ), (C , D ),
541
+ (C , C ), (C , D ), (D , C ), (C , D ), (D , C ), (C , D ), (D , C ),
542
+ (C , D ), (C , C ), (C , D ), (D , C ), (C , D ), (D , C ), (C , D ),
543
+ (D , C ), (C , D ), (C , C ), (C , D ), (C , C ), (C , D ), (C , C ),
544
+ (C , D ), (D , C ), (C , D ), (D , C ), (C , D ), (D , C ), (C , D )] #Randomly choose
539
545
actions += [(D , C ), (C , D ), (D , C )] # 17 D have come, so tit for tat for a while
540
546
actions += [(D , D ), (D , C )] * 100 # Random finally detected
541
547
self .versus_test (axelrod .Alternator (), expected_actions = actions , seed = 2 )
542
548
543
- class TestCave (TestPlayer ):
549
+ class TestWmAdams (TestPlayer ):
544
550
name = "WmAdams"
545
551
player = axelrod .WmAdams
546
552
expected_classifier = {
@@ -564,18 +570,18 @@ def test_strategy(self):
564
570
self .versus_test (defect_four , expected_actions = actions )
565
571
566
572
actions = [(C , D ), (C , D ), (C , D ), (C , D ), (C , D ), (D , D ), (C , D ),
567
- (C , D ), (D , D ), (C , D ), (D , D ), (C , D ), (D , D ), (D , D ),
568
- (D , D ), (D , D )]
573
+ (C , D ), (D , D ), (C , D ), (D , D ), (C , D ), (D , D ), (D , D ),
574
+ (D , D ), (D , D )]
569
575
self .versus_test (axelrod .Defector (), expected_actions = actions , seed = 1 )
570
576
actions = [(C , D ), (C , D ), (C , D ), (C , D ), (C , D ), (D , D ), (C , D ),
571
- (C , D ), (D , D ), (C , D ), (D , D ), (D , D ), (D , D ), (C , D ),
572
- (D , D ), (D , D )]
577
+ (C , D ), (D , D ), (C , D ), (D , D ), (D , D ), (D , D ), (C , D ),
578
+ (D , D ), (D , D )]
573
579
self .versus_test (axelrod .Defector (), expected_actions = actions , seed = 2 )
574
580
575
581
# After responding to the 11th D (counted as 10 D), just start cooperating
576
582
opponent_actions = [D ] * 11 + [C ] * 100
577
583
changed_man = axelrod .MockPlayer (actions = opponent_actions )
578
584
actions = [(C , D ), (C , D ), (C , D ), (C , D ), (C , D ), (D , D ), (C , D ),
579
- (C , D ), (D , D ), (C , D ), (D , D ), (C , C )]
580
- actions += [(C ,C )] * 99
585
+ (C , D ), (D , D ), (C , D ), (D , D ), (C , C )]
586
+ actions += [(C , C )] * 99
581
587
self .versus_test (changed_man , expected_actions = actions , seed = 1 )
0 commit comments