Beispiel #1
0
    def test_parallel_play(self):
        # Test that we get an instance of ResultSet
        tournament = axelrod.Tournament(
            name=self.test_name,
            players=self.players,
            game=self.game,
            turns=axelrod.DEFAULT_TURNS,
            repetitions=self.test_repetitions,
        )
        results = tournament.play(processes=2, progress_bar=False)
        self.assertIsInstance(results, axelrod.ResultSet)
        self.assertEqual(tournament.num_interactions, 75)

        # The following relates to #516
        players = [
            axelrod.Cooperator(),
            axelrod.Defector(),
            axelrod.BackStabber(),
            axelrod.PSOGambler2_2_2(),
            axelrod.ThueMorse(),
            axelrod.DoubleCrosser(),
        ]
        tournament = axelrod.Tournament(
            name=self.test_name,
            players=players,
            game=self.game,
            turns=20,
            repetitions=self.test_repetitions,
        )
        scores = tournament.play(processes=2, progress_bar=False).scores
        self.assertEqual(len(scores), len(players))
Beispiel #2
0
 def test_strategy(self):
     player = self.player()
     # Test against cyclers
     for opponent in [
             axelrod.CyclerCCD(),
             axelrod.CyclerCCCD(),
             axelrod.CyclerCCCCCD(),
             axelrod.Alternator(),
     ]:
         player.reset()
         for i in range(50):
             player.play(opponent)
         self.assertEqual(player.history[-1], D)
     # Test against non-cyclers and cooperators
     axelrod.seed(43)
     for opponent in [
             axelrod.Random(),
             axelrod.AntiCycler(),
             axelrod.DoubleCrosser(),
             axelrod.Cooperator(),
     ]:
         player.reset()
         for i in range(50):
             player.play(opponent)
         self.assertEqual(player.history[-1], C)
Beispiel #3
0
    def test_parallel_play(self):
        # Test that we get an instance of ResultSet
        tournament = axelrod.Tournament(
            name=self.test_name,
            players=self.players,
            game=self.game,
            turns=200,
            repetitions=self.test_repetitions,
            processes=2)
        results = tournament.play()
        self.assertIsInstance(results, axelrod.ResultSet)

        # The following relates to #516
        players = [axelrod.Cooperator(), axelrod.Defector(),
                   axelrod.BackStabber(), axelrod.PSOGambler(),
                   axelrod.ThueMorse(), axelrod.DoubleCrosser()]
        tournament = axelrod.Tournament(
            name=self.test_name,
            players=players,
            game=self.game,
            turns=20,
            repetitions=self.test_repetitions,
            processes=2)
        scores = tournament.play().scores
        self.assertEqual(len(scores), len(players))
Beispiel #4
0
 def test_strategy(self):
     player = self.player()
     # Test against cyclers
     for opponent in [
             axl.CyclerCCD(),
             axl.CyclerCCCD(),
             axl.CyclerCCCCCD(),
             axl.Alternator(),
     ]:
         player.reset()
         match = Match((player, opponent), turns=50)
         match.play()
         self.assertEqual(player.history[-1], D)
     # Test against non-cyclers and cooperators
     for opponent in [
             axl.Random(),
             axl.AntiCycler(),
             axl.DoubleCrosser(),
             axl.Cooperator(),
     ]:
         player.reset()
         match = Match((player, opponent), turns=50, seed=43)
         match.play()
         self.assertEqual(player.history[-1], C)