Example #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))
Example #2
0
 def test_vs(self):
     axelrod.seed(10)
     self.versus_test(axelrod.PSOGambler2_2_2(), axelrod.Alternator(),
                      [C, C, C, C, C, C, C], [C, D, C, D, C, D, C])
Example #3
0
 def test_vs(self):
     self.versus_test(axelrod.PSOGambler2_2_2(), axelrod.TitForTat(),
                      [C, C, C, C], [C, C, C, C])
Example #4
0
 def test_vs(self):
     self.versus_test(axelrod.PSOGambler2_2_2(), axelrod.Cooperator(),
                      [C, C, C, C], [C, C, C, C])
Example #5
0
 def test_vs(self):
     self.versus_test(axelrod.PSOGambler2_2_2(), axelrod.Defector(),
                      [C, C, D, D], [D, D, D, D])
Example #6
0
    outcomes_file = "../data/outcomes.csv"
    output_file = "../data/fixation_validation.csv"
    with open(output_file, "w") as f:
        f.write("Repetitions,N,i,Player 1,Player 2,Theoretic,Simulated\n")

    player_pairs = [(axl.Defector(), axl.Defector()),
                    (axl.Defector(), axl.Alternator()),
                    (axl.Defector(), axl.Cooperator()),
                    (axl.Defector(), axl.TitForTat()),
                    (axl.Defector(), axl.WinStayLoseShift()),
                    (axl.Random(), axl.Random()),
                    (axl.Random(), axl.ZDExtort2()),
                    (axl.Random(), axl.GTFT()),
                    (axl.Random(), axl.ALLCorALLD()),
                    (axl.Random(), axl.PSOGambler2_2_2()),
                    (axl.Cooperator(), axl.Random()),
                    (axl.Cooperator(), axl.ZDExtort2()),
                    (axl.Cooperator(), axl.GTFT()),
                    (axl.Cooperator(), axl.ALLCorALLD()),
                    (axl.Cooperator(), axl.PSOGambler2_2_2()),
                    (axl.Alternator(), axl.Random()),
                    (axl.Alternator(), axl.ZDExtort2()),
                    (axl.Alternator(), axl.GTFT()),
                    (axl.Alternator(), axl.ALLCorALLD()),
                    (axl.Alternator(), axl.PSOGambler2_2_2()),
                    (axl.ALLCorALLD(), axl.Cooperator()),
                    (axl.ALLCorALLD(), axl.Defector()),
                    (axl.ALLCorALLD(), axl.TitForTat()),
                    (axl.Alternator(), axl.Cooperator()),
                    (axl.Alternator(), axl.Defector()),