Beispiel #1
0
    def test_recombination_cookie(self):
        parent_cookies = (Cookie([40, 80]), Cookie([60, 40]))

        cookie = RecombinationCookie(parent_cookies)
        assert cookie.properties[0] == 50
        assert cookie.properties[1] == 60
        assert cookie.parents == parent_cookies
Beispiel #2
0
    def test_mutant_cookie(self, randint, choice):
        randint.return_value = 50
        choice.return_value = True

        parent_cookie = Cookie([50, 60])
        cookie = MutantCookie(parent_cookie)
        assert cookie.properties[0] == 76
        assert cookie.properties[1] == 81
        assert cookie.parents == (parent_cookie, )
Beispiel #3
0
    def test_mutate_step(self, randint, choice):
        randint.return_value = 50
        choice.return_value = True

        self.evolution.ancestors[1].add(Cookie([50, 60]))
        self.evolution.next(self.evolution.ancestors[1].last())
        cookie = self.evolution.ancestors[1].last()
        assert cookie.properties[0] == 76
        assert cookie.properties[1] == 81
Beispiel #4
0
 def test_unset_discontinued(self):
     self.ancestors.discontinued = True
     cookie = Cookie([30, 40])
     self.ancestors.add(cookie)
     assert self.ancestors.discontinued == False
Beispiel #5
0
 def test_add_cookie(self):
     cookie = Cookie([30, 40])
     self.ancestors.add(cookie)
     assert self.ancestors.last() == cookie
Beispiel #6
0
 def test_init(self):
     cookie = Cookie([50, 60])
     assert isinstance(cookie, Cookie)
     assert cookie.properties[0] == 50
     assert cookie.properties[1] == 60
Beispiel #7
0
 def test_add(self):
     g = Graph()
     cookie = Cookie()
     assert isinstance(cookie.vertex, Vertex)