void Genome::crossover(const Genome &with,Genome &baby1,Genome &baby2) { baby1.setFitness(0.0); baby2.setFitness(0.0); int crossoverPoint = NeuralNetRandom::RandomInt(0,numberOfGenes()-1); std::vector<double> newChromosome1; std::vector<double> newChromosome2; std::vector<double>::iterator myGenes = _chromosome.begin(); std::vector<double> otherChromosome = with.chromosome(); std::vector<double>::iterator otherGenes = otherChromosome.begin(); if (crossoverPoint > 0) { newChromosome1.assign(myGenes,myGenes+crossoverPoint+1); newChromosome2.assign(otherGenes,otherGenes+crossoverPoint+1); } newChromosome1.insert(newChromosome1.end(),otherGenes+crossoverPoint,otherChromosome.end()); newChromosome2.insert(newChromosome2.end(),myGenes+crossoverPoint,_chromosome.end()); baby1.setChromosome(newChromosome1); baby2.setChromosome(newChromosome2); }