Skip to content

Commit

Permalink
Merge pull request #905 from Axelrod-Python/strategy-transformer-tests
Browse files Browse the repository at this point in the history
Strategy transformer tests
  • Loading branch information
drvinceknight authored Mar 14, 2017
2 parents cb290da + 26e6913 commit 5c9673e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
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

0 comments on commit 5c9673e

Please sign in to comment.