Skip to content

Commit 7841213

Browse files
committed
reverted GeneralSoftGrudger tests
1 parent 9d6ac1d commit 7841213

File tree

1 file changed

+25
-47
lines changed

1 file changed

+25
-47
lines changed

axelrod/tests/strategies/test_grudger.py

Lines changed: 25 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ def test_strategy(self):
244244
self.versus_test(opponent, expected_actions=actions)
245245

246246

247-
class TestGeneralSoftGrudger(TestSoftGrudger):
247+
class TestGeneralSoftGrudger(TestPlayer):
248248

249249
name = "General Soft Grudger: n=1,d=4,c=2"
250250
player = axl.GeneralSoftGrudger
@@ -259,52 +259,30 @@ class TestGeneralSoftGrudger(TestSoftGrudger):
259259
}
260260

261261
def test_strategy(self):
262-
# the default follows SoftGrudger
263-
super(TestGeneralSoftGrudger, self).test_strategy()
264-
265-
def test_set_n(self):
266-
# grudge response only activates if opponent's last 'n' plays were D
267-
init_kwargs = {'n': 3}
268-
grudge_response_d = [(D, D)] * 4 + [(C, D)] * 2
269-
grudge_response_c = [(D, C)] * 4 + [(C, C)] * 2
270-
271-
opponent = axl.Defector()
272-
actions = [(C, D)] * 3 + grudge_response_d * 5
273-
self.versus_test(opponent, expected_actions=actions,
274-
init_kwargs=init_kwargs)
275-
276-
two_defections = [C, D, D]
277-
opponent = axl.MockPlayer(actions=two_defections)
278-
actions = [(C, C), (C, D), (C, D)] * 5
279-
self.versus_test(opponent, expected_actions=actions,
280-
init_kwargs=init_kwargs)
281-
282-
three_defections = [C] * 10 + [D, D, D]
283-
opponent = axl.MockPlayer(actions=three_defections)
284-
actions_start = [(C, C)] * 10 + [(C, D)] * 3
285-
subsequent = grudge_response_c + [(C, C)] * 4 + [(C, D)] * 3
286-
actions = actions_start + subsequent * 5
287-
self.versus_test(opponent, expected_actions=actions,
288-
init_kwargs=init_kwargs)
289-
290-
def test_set_d_and_c(self):
291-
# Sets the number of D's then C's in the grudge response.
292-
init_kwargs = {'d': 3, 'c': 3}
293-
grudge_response_d = [(D, D)] * 3 + [(C, D)] * 3
294-
grudge_response_c = [(D, C)] * 3 + [(C, C)] * 3
295-
296-
opponent = axl.Defector()
297-
actions = [(C, D)] + grudge_response_d * 5
298-
self.versus_test(opponent, expected_actions=actions,
299-
init_kwargs=init_kwargs)
300-
301-
opponent_actions = [C] * 10 + [D]
302-
opponent = axl.MockPlayer(actions=opponent_actions)
303-
actions_start = [(C, C)] * 10 + [(C, D)]
304-
subsequent = grudge_response_c + [(C, C)] * 4 + [(C, D)]
305-
actions = actions_start + subsequent * 5
306-
self.versus_test(opponent, expected_actions=actions,
307-
init_kwargs=init_kwargs)
262+
"""Test strategy with multiple initial parameters"""
263+
264+
# Starts by cooperating.
265+
self.first_play_test(C)
266+
267+
# Testing default parameters of n=1, d=4, c=2 (same as Soft Grudger)
268+
actions = [(C, D), (D, D), (D, C), (D, C), (D, D), (C, D),
269+
(C, C), (C, C)]
270+
self.versus_test(axl.MockPlayer(actions=[D, D, C, C]),
271+
expected_actions=actions)
272+
273+
# Testing n=2, d=4, c=2
274+
actions = [(C, D), (C, D), (D, C), (D, C), (D, D), (D, D),
275+
(C, C), (C, C)]
276+
self.versus_test(axl.MockPlayer(actions=[D, D, C, C]),
277+
expected_actions=actions,
278+
init_kwargs={"n": 2})
279+
280+
# Testing n=1, d=1, c=1
281+
actions = [(C, D), (D, D), (C, C), (C, C), (C, D), (D, D),
282+
(C, C), (C, C)]
283+
self.versus_test(axl.MockPlayer(actions=[D, D, C, C]),
284+
expected_actions=actions,
285+
init_kwargs={"n": 1, "d": 1, "c": 1})
308286

309287
def test_edge_case_n_is_zero(self):
310288
# Always uses grudge response.

0 commit comments

Comments
 (0)