Пример #1
0
 def test_init_with_graph_edges_not_including_all_players(self):
     edges = [(0, 1), (1, 2)]
     with self.assertRaises(ValueError):
         axelrod.SpatialMatches(self.players,
                                3,
                                test_game,
                                5,
                                edges,
                                noise=0)
Пример #2
0
    def test_build_match_chunks(self, repetitions, turns, noise):
        edges = [(0, 1), (1, 2), (3, 4)]
        sp = axelrod.SpatialMatches(self.players, turns, test_game,
                                    repetitions, edges, noise)
        chunks = list(sp.build_match_chunks())

        match_definitions = set()

        cache = None
        expected_params = (turns, test_game, cache, noise)
        for index_pair, match_params, repetitions in chunks:
            match_definitions.add(tuple(list(index_pair) + [repetitions]))
            self.assertEqual(match_params, expected_params)

        expected_match_definitions = set(
            (edge[0], edge[1], repetitions) for edge in edges)

        self.assertEqual(match_definitions, expected_match_definitions)
Пример #3
0
 def test_len(self):
     edges = [(0, 1), (1, 2), (3, 4)]
     sp = axelrod.SpatialMatches(self.players, test_turns, test_game,
                                 test_repetitions, edges)
     self.assertEqual(len(sp), len(list(sp.build_match_chunks())))
     self.assertEqual(len(sp), len(edges))