Skip to content

Commit 3933658

Browse files
committed
Rewrite test for TitForTat.
This does it by specifically creating the Matches.
1 parent dcbcf6f commit 3933658

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

axelrod/tests/unit/test_titfortat.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,20 @@ class TestTitForTat(TestPlayer):
3030
}
3131

3232
def test_strategy(self):
33-
# Starts by cooperating.
3433
self.first_play_test(C)
35-
# Repeats last action of opponent history.
3634
self.second_play_test(C, D, C, D)
37-
self.responses_test([C], [C] * 4, [C, C, C, C])
38-
self.responses_test([D], [C] * 5, [C, C, C, C, D])
35+
36+
outcomes = [(C, C), (C, D), (D, C), (C, D)]
37+
match = axelrod.Match((self.player(), axelrod.Alternator()), turns=4)
38+
self.assertEqual(match.play(), outcomes)
39+
40+
outcomes = [(C, C), (C, C), (C, C), (C, C)]
41+
match = axelrod.Match((self.player(), axelrod.Cooperator()), turns=4)
42+
self.assertEqual(match.play(), outcomes)
43+
44+
outcomes = [(C, D), (D, D), (D, D), (D, D)]
45+
match = axelrod.Match((self.player(), axelrod.Defector()), turns=4)
46+
self.assertEqual(match.play(), outcomes)
3947

4048

4149
class TestTitFor2Tats(TestPlayer):

0 commit comments

Comments
 (0)