public Population(List <List <float> > initialWeights = null) { Individuals = new List <Individual>(); ParentGameObject = new GameObject(); ParentGameObject.name = "Individuals"; if (initialWeights != null) { for (int i = 0; i < initialWeights.Count; i++) { Individuals.Add(new Individual(new DNA(initialWeights[i]))); Individuals[i].Index = i; Individuals[i].CreateGameObject(); Individuals[i].GameObject.transform.SetParent(ParentGameObject.transform); } } else { initialWeights = new List <List <float> >(); //initializes it so it will be 0 on the for statement below } for (var i = initialWeights.Count; i < ConfigManager.config.geneticAlgorithm.nIndividuals; i++) { Individuals.Add(new Individual(new DNA(NeuralNetworkHelper.GetWeightsNumberFromConfig()))); Individuals[i].Index = i; Individuals[i].CreateGameObject(); Individuals[i].GameObject.transform.SetParent(ParentGameObject.transform); } }