Added chromosome comparison by their genes

This commit is contained in:
SimpleArt
2020-12-06 11:17:15 -05:00
parent 58849e87e6
commit 21a709f5d0

View File

@ -100,6 +100,17 @@ class Chromosome:
return self.gene_list.index(searched_gene)
def __eq__(self, chromosome):
"""
Allows the user to use
chromosome_1 == chromosome_2
chromosome_1 != chromosome_2
to compare two chromosomes based on their genes.
"""
return all(gene_1 == gene_2 for gene_1, gene_2 in zip(self, chromosome))
def __repr__(self):
"""
Allows the user to use