Exemplo n.º 1
0
    def test_tournament_manager(self):
        strategies = [s() for s in axelrod.demo_strategies]
        tm = axelrod.TournamentManager("./", False, save_cache=False)
        tm.add_tournament("test",
                          strategies,
                          repetitions=2,
                          turns=10,
                          noise=0.05)
        tm.run_tournaments()

        strategies = [s() for s in axelrod.basic_strategies]
        tm = axelrod.TournamentManager("./",
                                       False,
                                       load_cache=False,
                                       save_cache=True)
        tm.add_tournament("test",
                          strategies,
                          repetitions=2,
                          turns=10,
                          noise=0.)
        tm.run_tournaments()

        tm = axelrod.TournamentManager("./",
                                       False,
                                       load_cache=True,
                                       save_cache=True)
        tm.add_tournament("test",
                          strategies,
                          repetitions=2,
                          turns=10,
                          noise=0.)
        tm.run_tournaments()
Exemplo n.º 2
0
 def test_init(self):
     mgr = axelrod.TournamentManager(self.test_output_directory,
                                     self.test_with_ecological)
     self.assertEqual(mgr._output_directory, self.test_output_directory)
     self.assertEqual(mgr._tournaments, [])
     self.assertEqual(mgr._with_ecological, self.test_with_ecological)
     self.assertTrue(mgr._pass_cache)
Exemplo n.º 3
0
    def test_add_tournaments(self):
        mgr = axelrod.TournamentManager(self.test_output_directory,
                                        self.test_with_ecological)

        self.tmf._add_tournaments(mgr, self.test_exclusions, self.test_kwargs)
        self.assertEqual(len(mgr._tournaments), 2)
        self.assertIsInstance(mgr._tournaments[0], axelrod.Tournament)
        self.assertEqual(mgr._tournaments[0].name, 'strategies')
Exemplo n.º 4
0
 def test_add_tournament(self):
     mgr = axelrod.TournamentManager(self.test_output_directory,
                                     self.test_with_ecological)
     mgr.add_tournament(players=self.test_players,
                        name=self.test_tournament_name)
     self.assertEqual(len(mgr._tournaments), 1)
     self.assertIsInstance(mgr._tournaments[0], axelrod.Tournament)
     self.assertEqual(mgr._tournaments[0].name, self.test_tournament_name)
Exemplo n.º 5
0
 def test_valid_cache(self):
     mgr = axelrod.TournamentManager(
         output_directory=self.test_output_directory,
         with_ecological=self.test_with_ecological,
         load_cache=False)
     mgr.add_tournament(players=self.test_players,
                        name=self.test_tournament_name)
     self.assertTrue(mgr._valid_cache(200))
     mgr._deterministic_cache['test_key'] = 'test_value'
     self.assertFalse(mgr._valid_cache(200))
     mgr._cache_valid_for_turns = 500
     self.assertFalse(mgr._valid_cache(200))
     self.assertTrue(mgr._valid_cache(500))
Exemplo n.º 6
0
 def test_output_file_path(self):
     mgr = axelrod.TournamentManager(self.test_output_directory,
                                     self.test_with_ecological)
     output_file_path = mgr._output_file_path(self.test_file_name,
                                              self.test_file_extenstion)
     self.assertEqual(output_file_path, self.expected_output_file_path)
Exemplo n.º 7
0
 def test_one_player_per_strategy(self):
     mgr = axelrod.TournamentManager(self.test_output_directory,
                                     self.test_with_ecological)
     players = mgr.one_player_per_strategy(self.test_strategies)
     self.assertIsInstance(players[0], axelrod.Defector)
     self.assertIsInstance(players[1], axelrod.Cooperator)