@@ -11,13 +11,13 @@ class TestGeller(TestPlayer):
11
11
name = "Geller"
12
12
player = axelrod .Geller
13
13
expected_classifier = {
14
- ' memory_depth' : float ("inf" ),
15
- ' stochastic' : True ,
16
- ' makes_use_of' : set (),
17
- ' long_run_time' : False ,
18
- ' inspects_source' : True , # Finds out what opponent will do
19
- ' manipulates_state' : False ,
20
- ' manipulates_source' : False
14
+ " memory_depth" : float ("inf" ),
15
+ " stochastic" : True ,
16
+ " makes_use_of" : set (),
17
+ " long_run_time" : False ,
18
+ " inspects_source" : True , # Finds out what opponent will do
19
+ " manipulates_state" : False ,
20
+ " manipulates_source" : False ,
21
21
}
22
22
23
23
@classmethod
@@ -42,67 +42,85 @@ def test_strategy(self):
42
42
"""Should cooperate against cooperators and defect against defectors."""
43
43
self .versus_test (axelrod .Defector (), expected_actions = [(D , D )] * 5 )
44
44
self .versus_test (axelrod .Cooperator (), expected_actions = [(C , C )] * 5 )
45
- self .versus_test (axelrod .Alternator (), expected_actions = [(C , C ), (D , D )] * 5 )
46
-
45
+ self .versus_test (
46
+ axelrod .Alternator (), expected_actions = [(C , C ), (D , D )] * 5
47
+ )
47
48
48
49
def test_strategy_against_lookerup_players (self ):
49
50
"""
50
51
Regression test for a bug discussed in
51
52
https://github.com/Axelrod-Python/Axelrod/issues/1185
52
53
"""
53
- self .versus_test (axelrod .EvolvedLookerUp1_1_1 (),
54
- expected_actions = [(C , C ), (C , C )])
55
- self .versus_test (axelrod .EvolvedLookerUp2_2_2 (),
56
- expected_actions = [(C , C ), (C , C )])
54
+ self .versus_test (
55
+ axelrod .EvolvedLookerUp1_1_1 (), expected_actions = [(C , C ), (C , C )]
56
+ )
57
+ self .versus_test (
58
+ axelrod .EvolvedLookerUp2_2_2 (), expected_actions = [(C , C ), (C , C )]
59
+ )
57
60
58
61
def test_returns_foil_inspection_strategy_of_opponent (self ):
59
- seed = 2
60
- # each Geller type returns the other's foil_inspection_strategy
61
- self .versus_test (axelrod .GellerDefector (), expected_actions = [(D , D ), (D , D ), (D , C ), (D , C )], seed = seed )
62
+ self .versus_test (
63
+ axelrod .GellerDefector (),
64
+ expected_actions = [(D , D ), (D , D ), (D , C ), (D , C )],
65
+ seed = 2 ,
66
+ )
62
67
63
- self .versus_test (axelrod .Darwin (), expected_actions = [(C , C ), (C , C ), (C , C )])
68
+ self .versus_test (
69
+ axelrod .Darwin (), expected_actions = [(C , C ), (C , C ), (C , C )]
70
+ )
64
71
65
- self .versus_test (axelrod .MindReader (), expected_actions = [(D , D ), (D , C ), (D , D )], seed = seed )
72
+ self .versus_test (
73
+ axelrod .MindReader (),
74
+ expected_actions = [(D , D ), (D , D ), (D , D )],
75
+ seed = 1 ,
76
+ )
66
77
67
78
68
79
class TestGellerCooperator (TestGeller ):
69
80
70
81
name = "Geller Cooperator"
71
82
player = axelrod .GellerCooperator
72
83
expected_classifier = {
73
- ' memory_depth' : float ("inf" ),
74
- ' stochastic' : False ,
75
- ' makes_use_of' : set (),
76
- ' long_run_time' : False ,
77
- ' inspects_source' : True , # Finds out what opponent will do
78
- ' manipulates_source' : False ,
79
- ' manipulates_state' : False
84
+ " memory_depth" : float ("inf" ),
85
+ " stochastic" : False ,
86
+ " makes_use_of" : set (),
87
+ " long_run_time" : False ,
88
+ " inspects_source" : True , # Finds out what opponent will do
89
+ " manipulates_source" : False ,
90
+ " manipulates_state" : False ,
80
91
}
81
92
82
93
def test_foil_strategy_inspection (self ):
83
94
player = self .player ()
84
95
self .assertEqual (player .foil_strategy_inspection (), C )
85
96
86
97
def test_returns_foil_inspection_strategy_of_opponent (self ):
87
- self .versus_test (axelrod .GellerDefector (), expected_actions = [(D , C ), (D , C ), (D , C ), (D , C )])
98
+ self .versus_test (
99
+ axelrod .GellerDefector (),
100
+ expected_actions = [(D , C ), (D , C ), (D , C ), (D , C )],
101
+ )
88
102
89
- self .versus_test (axelrod .Darwin (), expected_actions = [(C , C ), (C , C ), (C , C )])
103
+ self .versus_test (
104
+ axelrod .Darwin (), expected_actions = [(C , C ), (C , C ), (C , C )]
105
+ )
90
106
91
- self .versus_test (axelrod .MindReader (), expected_actions = [(D , D ), (D , D ), (D , D )])
107
+ self .versus_test (
108
+ axelrod .MindReader (), expected_actions = [(D , D ), (D , D ), (D , D )]
109
+ )
92
110
93
111
94
112
class TestGellerDefector (TestGeller ):
95
113
96
114
name = "Geller Defector"
97
115
player = axelrod .GellerDefector
98
116
expected_classifier = {
99
- ' memory_depth' : float ("inf" ),
100
- ' stochastic' : False ,
101
- ' makes_use_of' : set (),
102
- ' long_run_time' : False ,
103
- ' inspects_source' : True , # Finds out what opponent will do
104
- ' manipulates_source' : False ,
105
- ' manipulates_state' : False
117
+ " memory_depth" : float ("inf" ),
118
+ " stochastic" : False ,
119
+ " makes_use_of" : set (),
120
+ " long_run_time" : False ,
121
+ " inspects_source" : True , # Finds out what opponent will do
122
+ " manipulates_source" : False ,
123
+ " manipulates_state" : False ,
106
124
}
107
125
108
126
def test_foil_strategy_inspection (self ):
@@ -111,8 +129,15 @@ def test_foil_strategy_inspection(self):
111
129
112
130
def test_returns_foil_inspection_strategy_of_opponent (self ):
113
131
114
- self .versus_test (axelrod .GellerDefector (), expected_actions = [(D , D ), (D , D ), (D , D ), (D , D )])
132
+ self .versus_test (
133
+ axelrod .GellerDefector (),
134
+ expected_actions = [(D , D ), (D , D ), (D , D ), (D , D )],
135
+ )
115
136
116
- self .versus_test (axelrod .Darwin (), expected_actions = [(C , C ), (C , C ), (C , C )])
137
+ self .versus_test (
138
+ axelrod .Darwin (), expected_actions = [(C , C ), (C , C ), (C , C )]
139
+ )
117
140
118
- self .versus_test (axelrod .MindReader (), expected_actions = [(D , D ), (D , D ), (D , D )])
141
+ self .versus_test (
142
+ axelrod .MindReader (), expected_actions = [(D , D ), (D , D ), (D , D )]
143
+ )
0 commit comments