@@ -112,56 +112,64 @@ class TestProber4(TestPlayer):
112
112
'manipulates_source' : False ,
113
113
'manipulates_state' : False
114
114
}
115
- initial_sequence = [C , C , D , C , D , D , D , C , C , D ,
116
- C , D , C , C , D , C , D , D , C , D ]
115
+ initial_sequence = [
116
+ C , C , D , C , D , D , D , C , C , D , C , D , C , C , D , C , D , D , C , D
117
+ ]
117
118
cooperation_pool = [C ] * 5
118
119
119
120
def test_initial_strategy (self ):
120
121
"""Starts by playing CCDCDDDCCDCDCCDCDDCD."""
121
122
self .responses_test ([], [], self .initial_sequence )
122
123
123
124
def test_strategy (self ):
124
- # Defects forever if the opponent played D for C
125
- # at least 3 times more than D for D
126
- history1 = self .initial_sequence
127
- history2 = self .initial_sequence
128
- responses = [D ] * 10
129
- self .responses_test (history1 , history2 , responses )
125
+ # After playing the initial sequence defects forever
126
+ # if the absolute difference in the number of retaliating
127
+ # and provocative defections of the opponent is smaller or equal to 2
128
+
129
+ provocative_histories = [
130
+ [C , C , C , C , C , C , C , C , C , C , C , C , C , C , C , C , C , C , C , C ],
131
+ [C , D , C , C , C , C , C , C , C , C , C , C , C , C , C , C , C , C , C , C ],
132
+ [C , D , C , D , C , C , C , C , C , C , C , C , C , C , C , C , C , C , C , C ],
133
+ [C , C , D , C , C , C , C , C , C , C , C , C , C , C , C , C , C , C , C , C ],
134
+ [C , C , D , C , D , C , C , C , C , C , C , C , C , C , C , C , C , C , C , C ],
135
+ [D , D , D , D , D , D , D , D , D , D , D , D , D , D , D , D , D , D , D , D ],
136
+ ]
130
137
131
- # or if the opponent played D for D
132
- # at least 3 times more than D for C
133
138
history1 = self .initial_sequence
134
- history2 = list (map (lambda x : D if x is C else C ,
135
- self .initial_sequence ))
136
139
responses = [D ] * 10
137
- self .responses_test (history1 , history2 , responses )
140
+ for history2 in provocative_histories :
141
+ self .responses_test (history1 , history2 , responses )
138
142
139
143
# Otherwise cooperates for 5 rounds
144
+ unprovocative_histories = [
145
+ [C , C , D , C , D , D , D , C , C , D , C , D , C , C , D , C , D , D , C , D ],
146
+ [D , D , C , D , C , C , C , D , D , C , D , C , D , D , C , D , C , C , D , C ],
147
+ [C , C , D , C , D , D , C , C , C , C , C , C , C , C , C , C , C , C , C , C ],
148
+ [C , C , D , C , D , D , C , C , D , C , C , C , C , C , C , D , D , D , C , C ],
149
+ [C , C , C , C , D , D , C , C , D , C , C , D , D , C , D , C , D , C , C , C ],
150
+ ]
151
+
140
152
history1 = self .initial_sequence
141
- history2 = [C ] * len (history1 )
142
153
responses = self .cooperation_pool
143
- self .responses_test (history1 , history2 , responses )
154
+ for history2 in unprovocative_histories :
155
+ self .responses_test (history1 , history2 , responses )
144
156
145
157
# and plays like TFT afterwards
146
- history1 = self .initial_sequence + self .cooperation_pool
147
- history2 = [C ] * (len (history1 ) - 1 ) + [D ]
148
- self .responses_test (history1 , history2 , [D ])
149
-
150
- history1 = self .initial_sequence + self .cooperation_pool + [D ]
151
- history2 = [C ] * len (history1 )
152
- self .responses_test (history1 , history2 , [C ])
158
+ history1 += self .cooperation_pool
159
+ history2 += self .cooperation_pool
160
+ self .responses_test (history1 , history2 , [C ])
153
161
154
- history1 = self . initial_sequence + self . cooperation_pool
155
- history2 = [C ] * len ( history1 )
156
- self .responses_test (history1 , history2 , [C ])
162
+ history1 += [ C ]
163
+ history2 + = [D ]
164
+ self .responses_test (history1 , history2 , [D ])
157
165
158
- history1 = self . initial_sequence + self . cooperation_pool + [ C ]
159
- history2 = [ C ] * ( len ( history1 ) - 1 ) + [ D ]
160
- self .responses_test (history1 , history2 , [D ])
166
+ history1 += [ D ]
167
+ history2 += [ C ]
168
+ self .responses_test (history1 , history2 , [C ])
161
169
162
- history1 = self . initial_sequence + self . cooperation_pool + [C ]
163
- history2 = [ C ] * ( len ( history1 ) - 1 ) + [D ]
164
- self .responses_test (history1 , history2 , [D ])
170
+ history1 += [C ]
171
+ history2 += [D ]
172
+ self .responses_test (history1 , history2 , [D ])
165
173
166
174
167
175
class TestHardProber (TestPlayer ):
0 commit comments