Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor adaptive test for #884. #886

Merged
merged 1 commit into from
Mar 11, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 11 additions & 30 deletions axelrod/tests/strategies/test_adaptive.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,17 @@ class TestAdaptive(TestPlayer):
}

def test_strategy(self):
# Test initial play sequence
self.responses_test([C] * 6 + [D] * 5)
actions = [(C, C)] * 6 + [(D, C)] * 8
self.versus_test(axelrod.Cooperator(), expected_actions=actions)

actions = [(C, D)] * 6 + [(D, D)] * 8
self.versus_test(axelrod.Defector(), expected_actions=actions)

actions = [(C, C), (C, D)] * 3 + [(D, C), (D, D)] * 4
self.versus_test(axelrod.Alternator(), expected_actions=actions)

actions = [(C, C)] * 6 + [(D, C)] + [(D, D)] * 4 + [(C, D), (C, C)]
self.versus_test(axelrod.TitForTat(), expected_actions=actions)

def test_scoring(self):
player = axelrod.Adaptive()
Expand All @@ -34,31 +43,3 @@ def test_scoring(self):
player.set_match_attributes(game=game)
player.play(opponent)
self.assertEqual(0, player.scores[C])


class TestAdaptivevsCooperator(TestMatch):
"""Test TFT vs WSLS"""
def test_rounds(self):
self.versus_test(axelrod.Adaptive(), axelrod.Cooperator(),
[C] * 6 + [D] * 5 + [D] * 3, [C] * 14)


class TestAdaptivevsDefector(TestMatch):
"""Test TFT vs WSLS"""
def test_rounds(self):
self.versus_test(axelrod.Adaptive(), axelrod.Defector(),
[C] * 6 + [D] * 5 + [D] * 3, [D] * 14)


class TestAdaptivevsAlternator(TestMatch):
"""Test TFT vs WSLS"""
def test_rounds(self):
self.versus_test(axelrod.Adaptive(), axelrod.Alternator(),
[C] * 6 + [D] * 5 + [D] * 3, [C, D] * 7)


class TestAdaptivevsTFT(TestMatch):
"""Test TFT vs WSLS"""
def test_rounds(self):
self.versus_test(axelrod.Adaptive(), axelrod.TitForTat(),
[C] * 6 + [D] * 5 + [C, C], [C] * 7 + [D] * 4 + [D, C])