Import() { Debug.Log("importing phenotypes..."); if (File.Exists("phenotypes.neat")) { string json = File.ReadAllText("phenotypes.neat"); SerializablePhenotypes serializablePhenotypes = JsonUtility.FromJson <SerializablePhenotypes> (json); if (serializablePhenotypes.phenotypes.Count != brains.Count) { Debug.LogError("phenotypes and genomes mismatch error. (" + serializablePhenotypes.phenotypes.Count + " / " + brains.Count + ")"); return; } this.phenotypes = serializablePhenotypes.phenotypes; for (int i = 0; i < brains.Count; i++) { CarBrain brain = brains[i]; brain.AssignPhenotype(phenotypes[i]); brain.runOnlyMode = true; brain.Reset(); } runOnlyMode = true; } }
InstantiatePopulation() { for (int i = 0; i < _params.NumGenomesToSpawn; i++) { GameObject car = Instantiate(carPrefab); CarBrain brain = car.GetComponent <CarBrain> (); brain.genomeID = population.Genomes()[i].ID(); brain.AssignPhenotype(population.Genomes()[i].Phenotype()); brains.Add(brain); Car carController = car.GetComponent <Car> (); carController.sliderLeft = sliderLeft; carController.sliderRight = sliderRight; carController.slowDown = slowDown; carController.progress = progress; carController.avgSpeed = avgSpeed; carController.id.text = "" + brain.genomeID; TrackManager trackMgr = car.GetComponent <TrackManager> (); trackMgr.activeTrack = activeTrack; } }