From 18f2e2d1d7abb022269e155046935e4e438c6c3d Mon Sep 17 00:00:00 2001 From: Charles McAnany Date: Tue, 31 Aug 2021 13:25:28 -0500 Subject: [PATCH] Fix comparison in randomrank selections The selections for randomrank can overflow off the end of entity_iarray if many entities are selected or crossed over. --- src/ga_select.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ga_select.c b/src/ga_select.c index 72d5a6e6..7b305f6d 100644 --- a/src/ga_select.c +++ b/src/ga_select.c @@ -282,7 +282,7 @@ GAULFUNC boolean ga_select_one_randomrank(population *pop, entity **mother) *mother = NULL; - if ( pop->orig_size < pop->select_state ) + if ( pop->orig_size <= pop->select_state ) { return TRUE; } @@ -316,7 +316,7 @@ GAULFUNC boolean ga_select_two_randomrank(population *pop, entity **mother, enti *mother = NULL; *father = NULL; - if ( pop->orig_size < pop->select_state ) + if ( pop->orig_size <= pop->select_state ) { return TRUE; }