Skip to content

Commit

Permalink
Test for noisy tournament functioning
Browse files Browse the repository at this point in the history
  • Loading branch information
marcharper committed May 15, 2016
1 parent 9eb4d29 commit fce7ffb
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions axelrod/tests/integration/test_tournament.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,20 @@ def test_parallel_play(self):
scores = tournament.play(processes=2, progress_bar=False).scores
actual_outcome = sorted(zip(self.player_names, scores))
self.assertEqual(actual_outcome, self.expected_outcome)


class TestTournament(unittest.TestCase):
def test_noisy_tournament(self):
# Defector should win for low noise
players = [axelrod.Cooperator(), axelrod.Defector()]
tournament = axelrod.Tournament(players, turns=20, repetitions=10,
with_morality=False, noise=0.)
results = tournament.play()
self.assertEqual(results.ranked_names[0], "Defector")

# If the noise is large enough, cooperator should win
players = [axelrod.Cooperator(), axelrod.Defector()]
tournament = axelrod.Tournament(players, turns=20, repetitions=10,
with_morality=False, noise=0.75)
results = tournament.play()
self.assertEqual(results.ranked_names[0], "Cooperator")

0 comments on commit fce7ffb

Please sign in to comment.