1- import filecmp
21import unittest
32
4- from hypothesis import given , settings
3+ import filecmp
54
6- import axelrod
5+ import axelrod as axl
76from axelrod .load_data_ import axl_filename
87from axelrod .strategy_transformers import FinalTransformer
98from axelrod .tests .property import tournaments
109
10+ from hypothesis import given , settings
11+
1112
1213class TestTournament (unittest .TestCase ):
1314 @classmethod
1415 def setUpClass (cls ):
15- cls .game = axelrod .Game ()
16+ cls .game = axl .Game ()
1617 cls .players = [
17- axelrod .Cooperator (),
18- axelrod .TitForTat (),
19- axelrod .Defector (),
20- axelrod .Grudger (),
21- axelrod .GoByMajority (),
18+ axl .Cooperator (),
19+ axl .TitForTat (),
20+ axl .Defector (),
21+ axl .Grudger (),
22+ axl .GoByMajority (),
2223 ]
2324 cls .player_names = [str (p ) for p in cls .players ]
2425 cls .test_name = "test"
@@ -35,7 +36,7 @@ def setUpClass(cls):
3536
3637 @given (
3738 tournaments (
38- strategies = axelrod .short_run_time_strategies ,
39+ strategies = axl .short_run_time_strategies ,
3940 min_size = 10 ,
4041 max_size = 30 ,
4142 min_turns = 2 ,
@@ -54,7 +55,7 @@ def test_big_tournaments(self, tournament):
5455 )
5556
5657 def test_serial_play (self ):
57- tournament = axelrod .Tournament (
58+ tournament = axl .Tournament (
5859 name = self .test_name ,
5960 players = self .players ,
6061 game = self .game ,
@@ -66,7 +67,7 @@ def test_serial_play(self):
6667 self .assertEqual (actual_outcome , self .expected_outcome )
6768
6869 def test_parallel_play (self ):
69- tournament = axelrod .Tournament (
70+ tournament = axl .Tournament (
7071 name = self .test_name ,
7172 players = self .players ,
7273 game = self .game ,
@@ -81,12 +82,12 @@ def test_repeat_tournament_deterministic(self):
8182 """A test to check that tournament gives same results."""
8283 deterministic_players = [
8384 s ()
84- for s in axelrod .short_run_time_strategies
85+ for s in axl .short_run_time_strategies
8586 if not s ().classifier ["stochastic" ]
8687 ]
8788 files = []
8889 for _ in range (2 ):
89- tournament = axelrod .Tournament (
90+ tournament = axl .Tournament (
9091 name = "test" ,
9192 players = deterministic_players ,
9293 game = self .game ,
@@ -105,13 +106,13 @@ def test_repeat_tournament_stochastic(self):
105106 """
106107 files = []
107108 for _ in range (2 ):
108- axelrod .seed (0 )
109+ axl .seed (0 )
109110 stochastic_players = [
110111 s ()
111- for s in axelrod .short_run_time_strategies
112+ for s in axl .short_run_time_strategies
112113 if s ().classifier ["stochastic" ]
113114 ]
114- tournament = axelrod .Tournament (
115+ tournament = axl .Tournament (
115116 name = "test" ,
116117 players = stochastic_players ,
117118 game = self .game ,
@@ -128,14 +129,14 @@ def test_repeat_tournament_stochastic(self):
128129class TestNoisyTournament (unittest .TestCase ):
129130 def test_noisy_tournament (self ):
130131 # Defector should win for low noise
131- players = [axelrod .Cooperator (), axelrod .Defector ()]
132- tournament = axelrod .Tournament (players , turns = 5 , repetitions = 3 , noise = 0.0 )
132+ players = [axl .Cooperator (), axl .Defector ()]
133+ tournament = axl .Tournament (players , turns = 5 , repetitions = 3 , noise = 0.0 )
133134 results = tournament .play (progress_bar = False )
134135 self .assertEqual (results .ranked_names [0 ], "Defector" )
135136
136137 # If the noise is large enough, cooperator should win
137- players = [axelrod .Cooperator (), axelrod .Defector ()]
138- tournament = axelrod .Tournament (players , turns = 5 , repetitions = 3 , noise = 0.75 )
138+ players = [axl .Cooperator (), axl .Defector ()]
139+ tournament = axl .Tournament (players , turns = 5 , repetitions = 3 , noise = 0.75 )
139140 results = tournament .play (progress_bar = False )
140141 self .assertEqual (results .ranked_names [0 ], "Cooperator" )
141142
@@ -145,10 +146,10 @@ def test_players_do_not_know_match_length(self):
145146 """Create two players who should cooperate on last two turns if they
146147 don't know when those last two turns are.
147148 """
148- p1 = FinalTransformer (["D" , "D" ])(axelrod .Cooperator )()
149- p2 = FinalTransformer (["D" , "D" ])(axelrod .Cooperator )()
149+ p1 = FinalTransformer (["D" , "D" ])(axl .Cooperator )()
150+ p2 = FinalTransformer (["D" , "D" ])(axl .Cooperator )()
150151 players = [p1 , p2 ]
151- tournament = axelrod .Tournament (players , prob_end = 0.5 , repetitions = 1 )
152+ tournament = axl .Tournament (players , prob_end = 0.5 , repetitions = 1 )
152153 results = tournament .play (progress_bar = False )
153154 # Check that both plays always cooperated
154155 for rating in results .cooperating_rating :
@@ -159,12 +160,12 @@ def test_matches_have_different_length(self):
159160 A match between two players should have variable length across the
160161 repetitions
161162 """
162- p1 = axelrod .Cooperator ()
163- p2 = axelrod .Cooperator ()
164- p3 = axelrod .Cooperator ()
163+ p1 = axl .Cooperator ()
164+ p2 = axl .Cooperator ()
165+ p3 = axl .Cooperator ()
165166 players = [p1 , p2 , p3 ]
166- axelrod .seed (0 )
167- tournament = axelrod .Tournament (players , prob_end = 0.5 , repetitions = 2 )
167+ axl .seed (0 )
168+ tournament = axl .Tournament (players , prob_end = 0.5 , repetitions = 2 )
168169 results = tournament .play (progress_bar = False )
169170 # Check that match length are different across the repetitions
170171 self .assertNotEqual (results .match_lengths [0 ], results .match_lengths [1 ])
0 commit comments