From 1784757f13dc035fcbc9ded001a315c27c01c086 Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Mon, 4 May 2020 13:38:55 +0200 Subject: [PATCH] Remove species that no longer have any organisms. Fixes #19. --- src/population.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/population.rs b/src/population.rs index c18bd2b..14f79f3 100644 --- a/src/population.rs +++ b/src/population.rs @@ -172,6 +172,9 @@ impl Population { self.species.push(new_specie.unwrap()); } } + + // Remove species that no longer have any organisms. + self.species.retain(|s| ! s.organisms.is_empty()); } fn create_organisms(&mut self, population_size: usize) {