void Start() { if (!Debug.isDebugBuild) { Cursor.visible = false; } string[] traits; if (tutorial > 0) { traits = GenFilesManager.LoadTutorial(tutorial).Split('|'); } else { traits = GenFilesManager.LoadPlayer().Split('|'); } foreach (char tempChar in traits[1]) { ApplyFeature(tempChar); } foreach (char tempChar in traits[0]) { ApplyAttribute(tempChar); } }
/// <summary> /// Breeds a new generation and saves it as a .txt file /// </summary> List <string> CreateNextGeneration() { /*Logging details about last generation's individuals*/ GenLogManager.SaveLog(LogType.Individual); List <string> newGeneration = BreedNewGeneration(); GenFilesManager.SaveGeneration(newGeneration); return(newGeneration); }
List <string> RandomizeGeneration() { List <string> newGeneration = new List <string>(); for (int i = 0; i < GenerationSize; i++) { string newIndividual = RandomizeIndividual(); newGeneration.Add(newIndividual.ToString()); } GenFilesManager.SaveGeneration(newGeneration); return(newGeneration); }
List <string> CreateFirstGeneration() { List <string> features = new List <string>(); for (int i = 0; i < (GenerationSize - 1) / featurePermutations.Length; i++) { foreach (string permutation in featurePermutations) { features.Add(permutation); } //features.Add(permutations[0]); //features.Add(permutations[1]); //features.Add(permutations[2]); //features.Add(permutations[3]); } List <string> newGeneration = new List <string>(); for (int i = 0; i < (GenerationSize - 1); i++) { StringBuilder newIndividual = new StringBuilder(); newIndividual.Append(RandomizeAttributes()); newIndividual.Append('|'); int randomIndex = rand.Next(0, features.Count); // Add a random feature permutation and remove it from the selection newIndividual.Append(features[randomIndex]); features.RemoveAt(randomIndex); newGeneration.Add(newIndividual.ToString()); } newGeneration.Add(RandomizeIndividual()); GenFilesManager.SaveGeneration(newGeneration); return(newGeneration); }
public void CompletePlayer() { GenerationManager.Tutorial = false; GenFilesManager.SavePlayer(GetPlayerTraits()); SceneManager.LoadScene(6); }