public static void Breed(NNet parent1, NNet parent2, NNet child1, NNet child2) { var p1weights = parent1.GetNeuronWeights(); var p2weights = parent2.GetNeuronWeights(); var c1weights = new List <float>(); var c2weights = new List <float>(); int crossover = (int)UnityEngine.Random.Range(0, p1weights.Count - 1); for (int i = 0; i < crossover; i++) { c1weights.Add(p1weights[i]); c2weights.Add(p2weights[i]); } for (int i = crossover; i < p1weights.Count; i++) { c1weights.Add(p2weights[i]); c2weights.Add(p1weights[i]); } child1.SetWeights(c1weights); child2.SetWeights(c2weights); }