コード例 #1
0
ファイル: test_words.py プロジェクト: m0n0ph1/Fugue-Generator
 def test_halt_expected(self):
     """
     Ensure the function returns true if we're in a halting state.
     """
     g1 = Genome(['c', 'a', 't'])
     g1.fitness = len(TARGET_WORD)
     g2 = Genome(['d', 'o', 'g'])
     g2.fitness = 2
     g3 = Genome(['f', 'o', 'o'])
     g3.fitness = 3
     # Any fittest solution with fitness = length of the target word.
     population = [g1, g2, g3]
     result = halt(population, 1)
     self.assertTrue(result)
コード例 #2
0
ファイル: test_words.py プロジェクト: GitBruno/foox
 def test_halt_expected(self):
     """
     Ensure the function returns true if we're in a halting state.
     """
     g1 = Genome(['c', 'a', 't'])
     g1.fitness = len(TARGET_WORD)
     g2 = Genome(['d', 'o', 'g'])
     g2.fitness = 2
     g3 = Genome(['f', 'o', 'o'])
     g3.fitness = 3
     # Any fittest solution with fitness = length of the target word.
     population = [g1, g2, g3]
     result = halt(population, 1)
     self.assertTrue(result)
コード例 #3
0
ファイル: test_words.py プロジェクト: m0n0ph1/Fugue-Generator
 def test_halt_not(self):
     """
     Ensures if the fittest genome has fitness < 4 then halt doesn't
     succeed.
     """
     g1 = Genome(['c', 'a', 't'])
     g1.fitness = len(TARGET_WORD) - 1
     g2 = Genome(['d', 'o', 'g'])
     g2.fitness = 2
     g3 = Genome(['f', 'o', 'o'])
     g3.fitness = 3
     # Any fittest solution with fitness < target word length means call a
     # halt.
     population = [g1, g2, g3]
     result = halt(population, 1)
     self.assertFalse(result)
コード例 #4
0
ファイル: test_words.py プロジェクト: GitBruno/foox
 def test_halt_not(self):
     """
     Ensures if the fittest genome has fitness < 4 then halt doesn't
     succeed.
     """
     g1 = Genome(['c', 'a', 't'])
     g1.fitness = len(TARGET_WORD) - 1
     g2 = Genome(['d', 'o', 'g'])
     g2.fitness = 2
     g3 = Genome(['f', 'o', 'o'])
     g3.fitness = 3
     # Any fittest solution with fitness < target word length means call a
     # halt.
     population = [g1, g2, g3]
     result = halt(population, 1)
     self.assertFalse(result)