From 58849e87e6e08e54a53edd9f94fb918ef1a32a9c Mon Sep 17 00:00:00 2001 From: SimpleArt <71458112+SimpleArt@users.noreply.github.com> Date: Sun, 6 Dec 2020 11:15:10 -0500 Subject: [PATCH] Added gene comparison by gene value --- src/structure/gene.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/structure/gene.py b/src/structure/gene.py index cc5ee81..543d709 100644 --- a/src/structure/gene.py +++ b/src/structure/gene.py @@ -3,9 +3,13 @@ from copy import deepcopy class Gene: def __init__(self, value): - """Initialize a gene with fitness of value None and the input value""" + """Initialize a gene with fitness of value None and the input value.""" self.value = deepcopy(value) - self.fitness = None + + + def __eq__(self, gene): + """Comparing two genes by their value.""" + return self.value == gene.value def __repr__(self):