From 14a158aa0bb6a43cf0f40550be2bbe9ef0cd1685 Mon Sep 17 00:00:00 2001 From: SimpleArt <71458112+SimpleArt@users.noreply.github.com> Date: Sat, 23 Jan 2021 20:32:05 -0500 Subject: [PATCH] Fixed edge case for adapt_population --- src/EasyGA.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/EasyGA.py b/src/EasyGA.py index d3692da..6deca53 100644 --- a/src/EasyGA.py +++ b/src/EasyGA.py @@ -211,7 +211,8 @@ class GA(Attributes): # Replace worst chromosomes with new chromosomes, except for the previous best chromosome min_len = min(len(self.population)-1, len(self.population.next_population)) - self.population[-min_len:] = self.population.next_population[:min_len] + if min_len > 0: + self.population[-min_len:] = self.population.next_population[:min_len] self.population.next_population = [] self.population.mating_pool = []