void Start() { bestCreatureController = FindObjectOfType <BestCreaturesController>(); cameraFollowController = FindObjectOfType <CameraFollowController>(); evolution = FindObjectOfType <Evolution>(); evolutionOverlayView.Delegate = this; bestCreatureOverlayView.Delegate = this; sharedOverlayView.Delegate = this; visibilityOptionsView.Delegate = this; evolution.NewBatchDidBegin += delegate() { Refresh(); }; evolution.SimulationWasSaved += delegate() { sharedOverlayView.ShowSuccessfulSaveAlert(); }; bestCreatureController.PlaybackDidBegin += delegate() { Refresh(); }; evolution.InitializationDidEnd += delegate() { if (!Settings.DontShowV2SimulationDeprecationOverlayAgain && evolution.SimulationData.LastV2SimulatedGeneration > 0) { v2PlaybackNoticePopup.Show(); } }; }
/// <summary> /// Continues the evolution from the save state. /// /// This function call has to replace calls to StartEvolution (and therefore also SetupEvolution) when a simulation would be started /// from the beginning. /// /// </summary> /// <param name="generationNum">The generation number that the simulation should continue at from.</param> /// <param name="timePerGen">The time for each generation simulation.</param> /// <param name="bestChromosomes">The list of best chromosomes of the already simluated generations.</param> /// <param name="currentChromosomes">A list of chromosomes of creatures of the last (current) generation.</param> //public void ContinueEvolution(int generationNum, int timePerGen, List<ChromosomeInfo> bestChromosomes, List<string> currentChromosomes) { public void ContinueEvolution(int generationNum, EvolutionSettings evolutionSettings, NeuralNetworkSettings networkSettings, List <ChromosomeStats> bestChromosomes, List <string> currentChromosomes) { this.settings = evolutionSettings; this.brainSettings = networkSettings; viewController = GameObject.Find("ViewController").GetComponent <ViewController>(); Assert.IsNotNull(viewController); this.currentGenerationNumber = generationNum; this.currentChromosomes = currentChromosomes.ToArray(); creature.RemoveMuscleColliders(); creature.Alive = false; running = true; viewController.UpdateGeneration(generationNum); autoSaver = new AutoSaver(); // Setup Evolution call CalculateDropHeight(); BCController = GameObject.Find("Best Creature Controller").GetComponent <BestCreaturesController>(); BCController.dropHeight = dropHeight; BCController.Creature = creature; BCController.SetBestChromosomes(bestChromosomes); BCController.ShowBCThumbScreen(); BCController.RunBestCreatures(generationNum - 1); currentGeneration = CreateGeneration(); // Batch simulation currentlySimulatingBatch = 1; simulateInBatchesCached = settings.simulateInBatches; batchSizeCached = settings.simulateInBatches ? settings.batchSize : settings.populationSize; var currentBatchSize = Mathf.Min(batchSizeCached, settings.populationSize - ((currentlySimulatingBatch - 1) * batchSizeCached)); currentCreatureBatch = new Creature[currentBatchSize]; Array.Copy(currentGeneration, 0, currentCreatureBatch, 0, currentBatchSize); creature.gameObject.SetActive(false); SimulateGeneration(); var cameraFollow = Camera.main.GetComponent <CameraFollowScript>(); cameraFollow.toFollow = currentGeneration[0]; cameraFollow.currentlyWatchingIndex = 0; RefreshVisibleCreatures(); }
private void SetupEvolution() { CalculateDropHeight(); BCController = GameObject.Find("Best Creature Controller").GetComponent <BestCreaturesController>(); BCController.dropHeight = dropHeight; BCController.Creature = creature; // The first generation will have random brains. currentGeneration = CreateCreatures(); ApplyBrains(currentGeneration, true); // Batch simulation currentlySimulatingBatch = 1; simulateInBatchesCached = settings.simulateInBatches; batchSizeCached = settings.simulateInBatches ? settings.batchSize : settings.populationSize; var currentBatchSize = Mathf.Min(batchSizeCached, settings.populationSize - ((currentlySimulatingBatch - 1) * batchSizeCached)); currentCreatureBatch = new Creature[currentBatchSize]; Array.Copy(currentGeneration, 0, currentCreatureBatch, 0, currentBatchSize); SimulateGeneration(); creature.gameObject.SetActive(false); var cameraFollow = Camera.main.GetComponent <CameraFollowScript>(); cameraFollow.toFollow = currentGeneration[0]; cameraFollow.currentlyWatchingIndex = 0; RefreshVisibleCreatures(); viewController.UpdateGeneration(currentGenerationNumber); autoSaver = new AutoSaver(); }
public PlaybackSceneContext(SimulationData data, BestCreaturesController controller) : base(data) { this.controller = controller; }