Added the termination features

This commit is contained in:
danielwilczak101
2020-09-30 00:05:39 -04:00
parent d531888d78
commit 625143da7d
10 changed files with 72 additions and 30 deletions

View File

@ -1 +1,2 @@
from .default_fitness_example import default_fitness_example
# FROM (. means local) file_name IMPORT function_name
from .is_the_value_5 import is_the_value_5

View File

@ -1,2 +0,0 @@
def default_fitness_example():
pass

View File

@ -0,0 +1,14 @@
def is_the_value_5(chromosome):
"""A very simple case test function - If the chromosomes gene value is a 5 add one
to the chromosomes overall fitness value."""
# Overall fitness value
fitness = 0
# For each gene in the chromosome
for gene in chromosome.genes:
# Check if its value = 5
if(gene.value == 5):
# If its value is 5 then add one to
# the overal fitness of the chromosome.
fitness += 1
return fitness