updated all code to use .size() methods
This commit is contained in:
@ -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:
|
||||
|
||||
@ -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)
|
||||
Reference in New Issue
Block a user