void Update() { //if (Load) //{ // if (Encrypt) // fullSavePath = Application.persistentDataPath + "/" + SaveName + "_Encrypted.GA2B"; // else // fullSavePath = Application.persistentDataPath + "/" + SaveName + ".GA2B"; // ga.LoadGeneration(fullSavePath, Encrypt); // Load = false; // Finshied = false; //} //if (Save) //{ // if (Encrypt) // fullSavePath = Application.persistentDataPath + "/" + SaveName + "_Encrypted.GA2B"; // else // fullSavePath = Application.persistentDataPath + "/" + SaveName + ".GA2B"; // ga.SaveGeneration(fullSavePath, Encrypt); // Save = false; //} if (Finshied) { return; } int Difference = CurrentPopulationSize - populationSize; ga.NewGeneration(Difference, elitism, mercy, Elitism, bestWorse, crossoverNewDNA); ga.MutationRate = mutationRate; UpdateText(ga.BestGenes, ga.BestFitness, ga.Generation); if (ga.BestFitness == 1) { UpdateAllText(ga.BestGenes, ga.BestFitness, ga.Generation, ga.Population.Count, (j) => ga.Population[j].Genes); Finshied = true; } CurrentPopulationSize = populationSize; }
// Update is called once per frame void Update() { //if (Load) //{ // if (Encrypt) // fullSavePath = Application.persistentDataPath + "/" + SaveName + "_Encrypted.GA2B"; // else // fullSavePath = Application.persistentDataPath + "/" + SaveName + ".GA2B"; // ga.LoadGeneration(fullSavePath, Encrypt); // SpawnSpeedies(populationSize); // Load = false; // Finshied = false; //} //if (Save) //{ // if (Encrypt) // fullSavePath = Application.persistentDataPath + "/" + SaveName + "_Encrypted.GA2B"; // else // fullSavePath = Application.persistentDataPath + "/" + SaveName + ".GA2B"; // ga.SaveGeneration(fullSavePath, Encrypt); // Save = false; //} if (Finshied) { return; } if (GenerationTimer >= GenerationTime) { int Difference = populationSize - CurrentPopulationSize; GenerationTimer = 0; ga.NewGeneration(Difference, elitism, mercy, Elitism, bestWorse, crossoverNewDNA); if (Difference != 0) { if (Difference < 0) { RemoveSpeedies(Difference * -1); } else { SpawnSpeedies(Difference); } } Run(false); ResetSpeedies(); Run(true); CurrentPopulationSize = populationSize; UpdateUI(); } else { GenerationTimer += Time.deltaTime; } ga.MutationRate = mutationRate; if (!RunTest) { UpdateUI(); Finshied = true; } }