Skip to content

Commit 0b676d2

Browse files
committed
correct NTitsForMTats tests to reflect changes in default values
1 parent 9deeb08 commit 0b676d2

File tree

1 file changed

+34
-11
lines changed

1 file changed

+34
-11
lines changed

axelrod/tests/strategies/test_titfortat.py

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -634,10 +634,10 @@ class TestNTitsForMTats(TestPlayer):
634634
Tests for the N Tit(s) For M Tat(s) strategy
635635
"""
636636

637-
name = 'N Tit(s) For M Tat(s): 1, 1'
637+
name = 'N Tit(s) For M Tat(s): 3, 2'
638638
player = axelrod.NTitsForMTats
639639
expected_classifier = {
640-
'memory_depth': 1,
640+
'memory_depth': 3,
641641
'stochastic': False,
642642
'makes_use_of': set(),
643643
'long_run_time': False,
@@ -650,23 +650,47 @@ class TestNTitsForMTats(TestPlayer):
650650
expected_class_classifier['memory_depth'] = float('inf')
651651

652652
def test_strategy(self):
653-
TestTitForTat.test_strategy(self)
653+
# TitForTat test_strategy
654+
init_kwargs = {'N': 1, 'M': 1}
655+
actions = [(C, C), (C, D), (D, C), (C, D), (D, C)]
656+
self.versus_test(axelrod.Alternator(), expected_actions=actions, init_kwargs=init_kwargs)
657+
actions = [(C, C), (C, C), (C, C), (C, C), (C, C)]
658+
self.versus_test(axelrod.Cooperator(), expected_actions=actions, init_kwargs=init_kwargs)
659+
actions = [(C, D), (D, D), (D, D), (D, D), (D, D)]
660+
self.versus_test(axelrod.Defector(), expected_actions=actions, init_kwargs=init_kwargs)
661+
actions = [(C, C), (C, D), (D, C), (C, D), (D, C)]
662+
self.versus_test(axelrod.Alternator(), expected_actions=actions,
663+
match_attributes={"length": -1}, init_kwargs=init_kwargs)
664+
actions = [(C, D), (D, D), (D, C), (C, C), (C, D)]
665+
self.versus_test(axelrod.Random(), expected_actions=actions,
666+
seed=0, init_kwargs=init_kwargs)
667+
actions = [(C, C), (C, D), (D, D), (D, C)]
668+
self.versus_test(axelrod.Random(), expected_actions=actions,
669+
seed=1, init_kwargs=init_kwargs)
670+
opponent = axelrod.MockPlayer(actions=[C, D])
671+
actions = [(C, C), (C, D), (D, C), (C, D)]
672+
self.versus_test(opponent, expected_actions=actions, init_kwargs=init_kwargs)
673+
opponent = axelrod.MockPlayer(actions=[C, C, D, D, C, D])
674+
actions = [(C, C), (C, C), (C, D), (D, D), (D, C), (C, D)]
675+
self.versus_test(opponent, expected_actions=actions, init_kwargs=init_kwargs)
654676

655677
# TitFor2Tats test_strategy
678+
init_kwargs = {'N': 1, 'M': 2}
656679
opponent = axelrod.MockPlayer(actions=[D, D, D, C, C])
657680
actions = [(C, D), (C, D), (D, D), (D, C), (C, C), (C, D)]
658-
self.versus_test(opponent, expected_actions=actions, init_kwargs={'N': 1, 'M': 2})
681+
self.versus_test(opponent, expected_actions=actions, init_kwargs=init_kwargs)
659682

660683
# TwoTitsForTat test_strategy
684+
init_kwargs = {'N': 2, 'M': 1}
661685
opponent = axelrod.MockPlayer(actions=[D, C, C, D, C])
662686
actions = [(C, D), (D, C), (D, C), (C, D), (D, C)]
663-
self.versus_test(opponent, expected_actions=actions, init_kwargs={'N': 2, 'M': 1})
687+
self.versus_test(opponent, expected_actions=actions, init_kwargs=init_kwargs)
664688
actions = [(C, C), (C, C)]
665689
self.versus_test(opponent=axelrod.Cooperator(),
666-
expected_actions=actions, init_kwargs={'N': 2, 'M': 1})
690+
expected_actions=actions, init_kwargs=init_kwargs)
667691
actions = [(C, D), (D, D), (D, D)]
668692
self.versus_test(opponent=axelrod.Defector(),
669-
expected_actions=actions, init_kwargs={'N': 2, 'M': 1})
693+
expected_actions=actions, init_kwargs=init_kwargs)
670694

671695
# Cooperator test_strategy
672696
actions = [(C, C)] + [(C, D), (C, C)] * 9
@@ -684,13 +708,12 @@ def test_strategy(self):
684708
self.versus_test(opponent=axelrod.Alternator(),
685709
expected_actions=actions, init_kwargs={'N': 5, 'M': 0})
686710

687-
# Other init args
711+
# Default init args
688712
actions = [(C, C), (C, D), (C, D), (D, C), (D, C), (D, D), (C, C)]
689713
opponent = axelrod.MockPlayer(actions=[acts[1] for acts in actions])
690-
self.versus_test(opponent=opponent,
691-
expected_actions=actions, init_kwargs={'N': 3, 'M': 2})
714+
self.versus_test(opponent=opponent, expected_actions=actions)
692715

693716
def test_varying_memory_depth(self):
694-
self.assertEqual(self.player().classifier['memory_depth'], 1)
717+
self.assertEqual(self.player(1, 1).classifier['memory_depth'], 1)
695718
self.assertEqual(self.player(0, 3).classifier['memory_depth'], 3)
696719
self.assertEqual(self.player(5, 3).classifier['memory_depth'], 5)

0 commit comments

Comments
 (0)