public void FixedUpdate() { Time.timeScale = TimeScale; if (!IsTrialRunning) { if (TrialCount < PopulationSize) { int index = TrialCount; TrialController.StartTrial(leftRules[index], rightRules[index]); IsTrialRunning = true; } else { using (var file = new StreamWriter(FilePath, true)) file.WriteLine(GenerationCount + "," + leftRules.Average(x => x.Fitness) + "," + leftRules.Max(x => x.Fitness) + "," + leftRules.Min(x => x.Fitness)); Debug.Log("BREEDING!"); leftRules = GeneticAlgorithm.BreedNewGeneration(leftRules, MutationChance); rightRules = GeneticAlgorithm.BreedNewGeneration(rightRules, MutationChance); Debug.Log("Finished Breeding!"); TrialCount = 0; GenerationCount++; if (GenerationCount >= GenerationLimit) { TimeScale = 0; } } } }