public void ProcessGeneration() { List <NeuralNetwork> newNetworks = new List <NeuralNetwork>(); for (int i = 0; i < this.population.Count(); i++) { NeuralNetwork father = this.population.Keys.Random(nn => this.population[nn]); NeuralNetwork mother = this.population.Keys.Except(new[] { father }).Random(nn => this.population[nn]); NeuralDna childDna = father.Dna.Crossover(mother.Dna); childDna.Mutate(MutationRate); NeuralNetwork child = new NeuralNetwork(childDna, father.NumInputs, father.LayerNums); newNetworks.Add(child); } this.population = newNetworks.ToDictionary(nn => nn, nn => this.fitnessTester.Fitness(nn)); }