@@ -23,15 +23,18 @@ class TestGolden(TestPlayer):
23
23
def test_strategy (self ):
24
24
# Cooperates initially.
25
25
self .first_play_test (C )
26
- # If the opposing player does not defect initially then strategy
27
- # defects.
28
- self .responses_test ([D ], [C ], [C ])
29
- # If the ratio of Cs to Ds is greater than the golden ratio then
30
- # strategy defects.
31
- self .responses_test ([D ], [C ] * 4 , [C , C , D , D ])
32
- # If the ratio of Cs to Ds is less than the golden ratio then strategy
33
- # co-operates
34
- self .responses_test ([C ], [C ] * 4 , [D ] * 4 )
26
+
27
+ actions = [(C , C ), (D , D ), (C , C ), (D , D ), (C , C )]
28
+ self .versus_test (opponent = axelrod .Alternator (),
29
+ expected_actions = actions )
30
+
31
+ actions = [(C , C ), (D , C ), (D , C ), (D , C ), (D , C )]
32
+ self .versus_test (opponent = axelrod .Cooperator (),
33
+ expected_actions = actions )
34
+
35
+ actions = [(C , D ), (C , D ), (C , D ), (C , D ), (C , D )]
36
+ self .versus_test (opponent = axelrod .Defector (),
37
+ expected_actions = actions )
35
38
36
39
37
40
class TestPi (TestPlayer ):
@@ -51,13 +54,18 @@ class TestPi(TestPlayer):
51
54
def test_strategy (self ):
52
55
# Cooperates initially
53
56
self .first_play_test (C )
54
- # If the opposing player does not defect initially then strategy
55
- # defects.
56
- self .responses_test ([D ], [C ], [C ])
57
- # If the ratio of Cs to Ds is greater than pi then strategy defects.
58
- self .responses_test ([D ], [C ] * 4 , [C , C , C , D ])
59
- # If the ratio of Cs to Ds is less than pi then strategy co-operates.
60
- self .responses_test ([C ], [C ] * 4 , [C , C , D , D ])
57
+
58
+ actions = [(C , C ), (D , D ), (C , C ), (C , D ), (C , C )]
59
+ self .versus_test (opponent = axelrod .Alternator (),
60
+ expected_actions = actions )
61
+
62
+ actions = [(C , C ), (D , C ), (D , C ), (D , C ), (D , C )]
63
+ self .versus_test (opponent = axelrod .Cooperator (),
64
+ expected_actions = actions )
65
+
66
+ actions = [(C , D ), (C , D ), (C , D ), (C , D ), (C , D )]
67
+ self .versus_test (opponent = axelrod .Defector (),
68
+ expected_actions = actions )
61
69
62
70
63
71
class Teste (TestPlayer ):
@@ -77,10 +85,15 @@ class Teste(TestPlayer):
77
85
def test_strategy (self ):
78
86
# Cooperates initially.
79
87
self .first_play_test (C )
80
- # If the opposing player does not defect initially then strategy
81
- # defects.
82
- self .responses_test ([D ], [C ], [C ])
83
- # If the ratio of Cs to Ds is greater than e then strategy defects.
84
- self .responses_test ([D ], [C ] * 4 , [C , C , D , D ])
85
- # If the ratio of Cs to Ds is less than e then strategy co-operates.
86
- self .responses_test ([C ], [C ] * 4 , [C , D , D , D ])
88
+
89
+ actions = [(C , C ), (D , D ), (C , C ), (C , D ), (C , C )]
90
+ self .versus_test (opponent = axelrod .Alternator (),
91
+ expected_actions = actions )
92
+
93
+ actions = [(C , C ), (D , C ), (D , C ), (D , C ), (D , C )]
94
+ self .versus_test (opponent = axelrod .Cooperator (),
95
+ expected_actions = actions )
96
+
97
+ actions = [(C , D ), (C , D ), (C , D ), (C , D ), (C , D )]
98
+ self .versus_test (opponent = axelrod .Defector (),
99
+ expected_actions = actions )
0 commit comments