// Update is called once per frame void Update() { //Debug.Log(agents[0].GetComponent<Brain>().GetGenome()); if (updateBestTime >= time) { float sum = 0.0f; for (int i = 0; i < agents.Count; i++) { float fitness = GetComponent <ImplementFunctions>().FitnessFunction(agents[i]); agents[i].GetComponent <Brain>().GetGenome().SetFitness(fitness); sum += fitness; } float avg = sum / agents.Count; agents.Sort((x, y) => x.GetComponent <Brain>().GetGenome().GetFitness().CompareTo(y.GetComponent <Brain>().GetGenome().GetFitness())); agents.Reverse(); thisGenText.text = "Current Gen:\nAvg: " + avg.ToString("F2") + "\nBest: " + agents[0].GetComponent <Brain>().GetGenome().GetFitness().ToString("F2") + "\nno. species: " + numSpecies; time = 0.0f; } time += Time.deltaTime; SetTime(neat.maxTime - neat.GetTimer()); deltaTime += (Time.deltaTime - deltaTime) * 0.1f; float fps = 1.0f / deltaTime; fpsText.text = "fps: " + Mathf.Ceil(fps).ToString(); }