Exemplo n.º 1
0
 def test_atomic_mutation_cycler(self):
     axelrod.seed(10)
     cycle_length = 5
     players = [axelrod.EvolvableCycler(cycle_length=cycle_length)
                for _ in range(5)]
     mp = MoranProcess(players, turns=10, mutation_method="atomic")
     population = mp.play()
     self.assertEqual(mp.winning_strategy_name, 'EvolvableCycler: CDCDD, 5, 0.2, 1')
     self.assertEqual(len(mp.populations), 19)
     self.assertTrue(mp.fixated)
Exemplo n.º 2
0
 def test_atomic_mutation_cycler(self):
     cycle_length = 5
     players = [
         axl.EvolvableCycler(cycle_length=cycle_length, seed=4)
         for _ in range(5)
     ]
     mp = MoranProcess(players, turns=10, mutation_method="atomic", seed=10)
     rounds = 10
     for _ in range(rounds):
         next(mp)
     self.assertEqual(
         list(mp.populations[-1].items())[0],
         ('EvolvableCycler: CCDDD, 5, 0.2, 1, 1164244177', 1))
     self.assertEqual(len(mp.populations), 11)
     self.assertFalse(mp.fixated)
Exemplo n.º 3
0
    def test_mutation_method_exceptions(self):
        axelrod.seed(10)
        cycle_length = 5
        players = [axelrod.EvolvableCycler(cycle_length=cycle_length)
                   for _ in range(5)]
        with self.assertRaises(ValueError):
            MoranProcess(players, turns=10, mutation_method="random")

        axelrod.seed(0)
        players = [axelrod.Cycler(cycle="CD" * random.randint(2, 10))
                   for _ in range(10)]

        mp = MoranProcess(players, turns=10, mutation_method="atomic")
        with self.assertRaises(TypeError):
            for _ in range(10):
                next(mp)