void Update() { for (int i = 0; i < population.getPopulationSize(); i++) { evaluateNetwork(Utility.xPositionOfObstacles, Utility.heightOfObstacles, scripts[i], networks[i], ref indexes[i]); } if (scripts.All(x => x.gameObject.GetComponent <SpriteRenderer>().isVisible == false)) { population.setPopulationList(networks); networks = population.GenerateNextGeneration(random); networks.ForEach(network => network.setJumpsMade(0)); population.ReplaceWithNextGeneration(); setAllText(networks); Respawn(); } }
void Start() { scripts = GetComponentsInChildren <NEATPlayerOne>(); population = new GeneratePopulation(50); random = new Random(); Genome initialGenome = generateInitialGenome(); for (int i = 0; i < population.getPopulationSize(); i++) { population.addGenomeToPopulation(new Genome(initialGenome)); } networks = population.GenerateNextGeneration(random); population.ReplaceWithNextGeneration(); setAllText(networks); }