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

Strategy transformer tests #905

Merged
merged 2 commits into from
Mar 14, 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
2 changes: 1 addition & 1 deletion axelrod/strategy_transformers.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ def joss_ann_wrapper(player, opponent, proposed_action, probability):
action: an axelrod.Action, C or D
"""
if sum(probability) > 1:
probability[:] = [i / sum(probability) for i in probability]
probability = tuple([i / sum(probability) for i in probability])

remaining_probability = max(0, 1 - probability[0] - probability[1])
probability += (remaining_probability,)
Expand Down
7 changes: 7 additions & 0 deletions axelrod/tests/unit/test_strategy_transformers.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,13 @@ def test_jossann_transformer(self):
p1.play(p2)
self.assertEqual(p1.history, [D, C, C, D, D])

probability = (0.6, 0.6)
p1 = JossAnnTransformer(probability)(axelrod.Cooperator)()
p2 = axelrod.Cooperator()
for _ in range(5):
p1.play(p2)
self.assertEqual(p1.history, [D, C, D, D, C])

def test_noisy_transformer(self):
"""Tests that the noisy transformed does flip some moves."""
random.seed(5)
Expand Down