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

Test: players do not know length in prob end #611

Closed
wants to merge 3 commits into from
Closed
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/tests/integration/test_sample_tournaments.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def get_test_outcome(cls, outcome, turns=10):
# Play the tournament and build the actual outcome tuples.
tournament = axelrod.Tournament(
players=players, game=cls.game, turns=turns, repetitions=1)
results = tournament.play()
results = tournament.play(progress_bar=False)
scores = [score[0] for score in results.scores]
outcome = zip(names, scores)

Expand Down
21 changes: 19 additions & 2 deletions axelrod/tests/integration/test_tournament.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import axelrod
import tempfile

from axelrod.strategy_transformers import FinalTransformer

class TestTournament(unittest.TestCase):

Expand Down Expand Up @@ -66,12 +67,28 @@ def test_noisy_tournament(self):
players = [axelrod.Cooperator(), axelrod.Defector()]
tournament = axelrod.Tournament(players, turns=20, repetitions=10,
with_morality=False, noise=0.)
results = tournament.play()
results = tournament.play(progress_bar=False)
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()
results = tournament.play(progress_bar=False)
self.assertEqual(results.ranked_names[0], "Cooperator")


class TestProbEndTournament(unittest.TestCase):
def test_players_do_not_know_match_length(self):
"""Create two players who should cooperate on last two turns if they
know when those last two turns are.
"""
p1 = FinalTransformer(['D', 'D'])(axelrod.Cooperator)()
p2 = FinalTransformer(['D', 'D'])(axelrod.Cooperator)()
players = [p1, p2]
tournament = axelrod.ProbEndTournament(players, prob_end=.1,
repetitions=1)
results = tournament.play(progress_bar=False)
# Check that both plays always cooperated
for rating in results.cooperating_rating:
self.assertEqual(rating, 1)