Skip to content

Fix coverage of meta.py #910

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

Merged
merged 8 commits into from
Mar 16, 2017
Merged
Show file tree
Hide file tree
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
9 changes: 5 additions & 4 deletions axelrod/strategies/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,12 @@ class MetaHunterAggressive(MetaPlayer):
'manipulates_state': False
}

def __init__(self):
def __init__(self, team=None):
# This version uses CooperatorHunter
team = [DefectorHunter, AlternatorHunter, RandomHunter,
MathConstantHunter, CycleHunter, EventualCycleHunter,
CooperatorHunter]
if team is None:
team = [DefectorHunter, AlternatorHunter, RandomHunter,
MathConstantHunter, CycleHunter, EventualCycleHunter,
CooperatorHunter]

super().__init__(team=team)

Expand Down
20 changes: 17 additions & 3 deletions axelrod/tests/strategies/test_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,6 @@ def test_strategy(self):
# defection
self.responses_test([D], [C, C, C, C], [C, C, C, C])

# After long histories tit-for-tat should come into play.
self.responses_test([D], [C] * 101, [C] * 100 + [D])

# All these others, however, should trigger a defection for the hunter.
self.responses_test([D], [C] * 4, [D] * 4)
self.responses_test([D], [C] * 6, [C, D] * 3)
Expand All @@ -258,6 +255,23 @@ def test_strategy(self):
self.responses_test([D], [C] * 101, [C] * 101)
self.responses_test([D], [C] * 101, [C] * 100 + [D])

# To test the TFT action of the strategy after 100 turns, we need to
# remove two of the hunters from its team.
# It is almost impossible to identify a history which reaches 100 turns
# without triggering one of the hunters in the default team. As at
# 16-Mar-2017, none of the strategies in the library does so.
team = [
axelrod.DefectorHunter,
axelrod.AlternatorHunter,
axelrod.RandomHunter,
# axelrod.MathConstantHunter,
axelrod.CycleHunter,
axelrod.EventualCycleHunter,
# axelrod.CooperatorHunter
]
self.responses_test(
[D], [C] * 101, [C] * 100 + [D], init_kwargs={'team': team})


class TestMetaMajorityMemoryOne(TestMetaPlayer):
name = "Meta Majority Memory One"
Expand Down