From 042038dff89fa3a63e6613ade4540c7347cab953 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Thu, 8 Aug 2019 15:30:47 -0700 Subject: More features. --- src/explicitsimulation.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/explicitsimulation.cpp b/src/explicitsimulation.cpp index 3e4edc3..b9693b5 100644 --- a/src/explicitsimulation.cpp +++ b/src/explicitsimulation.cpp @@ -131,11 +131,18 @@ Genetic::PhenotypeId Genetic::ExplicitSimulation::selectWeighted() if( dSel < dRun ) return i.getKey(); } - - sio << "Genetic::ExplicitSimulation::selectWeighted() - failed, picked max" +/* + sio << "Genetic::ExplicitSimulation::selectWeighted() - failed, picked random" << sio.nl; sio << " " << dMinFitness << " - " << dMaxFitness << " -- " << dTotalFitness << " > " << dRun << " > " << dSel << sio.nl; - abort(); +// abort(); +*/ + int iSel = Bu::Random::rand( hFitness.getSize() ); + for( FitnessHash::iterator i = hFitness.begin(); i; i++ ) + { + if( --iSel <= 0 ) + return i.getKey(); + } return uMaxFitness; } -- cgit v1.2.3