updated all code to use .size() methods

This commit is contained in:
SimpleArt
2020-10-12 17:05:57 -04:00
parent 8137bb64d9
commit 42c0fdbc10
5 changed files with 16 additions and 29 deletions

View File

@ -9,6 +9,10 @@ class Chromosome:
# If the chromosome has been selected then the flag would switch to true
self.selected = False
def size(self):
"""Returns the number of genes in the chromosome"""
return len(self.gene_list)
def add_gene(self, gene, index = -1):
"""Add a gene to the chromosome at the specified index, defaulted to end of the chromosome"""
if index == -1:

View File

@ -1,13 +0,0 @@
# Imported library
import random
def check_values(low,high):
#Check to make sure its not less then zero
assert low > 0 , "The random gene low can not be less then zero"
# Check to make sure the high value is not
# lower than or equal to low and not 0.
assert high > low , "High value can not be smaller then low value"
assert high != 0, "High value can not be zero"
def random_gene():
return random.randint(1,100)