reset(threadIndex);
final EcEvolver myFunc = new EcEvolver(source, destination, requiredActions);
evolvers[threadIndex] = myFunc;
final Configuration conf = constructConfiguration(threadIndex, myFunc);
final Genotype population = Genotype.randomInitialGenotype(conf);
//Please justify this code.
//-Lomilar
// if (!firstrun)
// {
// int totalevoSinceDiscoveryOnBest = 0;
// int numBestThreads = 0;
// synchronized (bestScores)
// {
// for (int i = 0; i < bestScores.length; i++)
// {
// if (bestScores[i] >= bestScore)
// {
// numBestThreads++;
// totalevoSinceDiscoveryOnBest += evolutionsSinceDiscovery[i];
// }
// }
// }
//
// if (!(totalevoSinceDiscoveryOnBest > Math.max(stagnationLimit, STAGNATION_LIMIT_MIN) * numBestThreads)
// && numBestThreads < Math.max(Math.ceil(NUM_THREADS / 3), 1))
// {
// loadOldBuildOrders(population, conf, myFunc);
// }
// }
// else
if (firstrun && threadIndex == 0)
{
loadOldBuildOrders(population, conf, myFunc);
}
else if (firstrun && threadIndex == NUM_THREADS - 1)
{
firstrun = false;
}
final Thread thread = new Thread(population);
conf.getEventManager().addEventListener(GeneticEvent.GENOTYPE_EVOLVED_EVENT, new GeneticEventListener()
{
@Override
public void geneticEventFired(GeneticEvent a_firedEvent)
{
Collections.shuffle(conf.getGeneticOperators());
BASE_MUTATION_RATE += .001;
if (BASE_MUTATION_RATE >= (double) CHROMOSOME_LENGTH / 2.0 )
BASE_MUTATION_RATE = 1;
IChromosome fittestChromosome = population.getFittestChromosome();
if (killThreads)