Exemplo n.º 1
0
 public void AdvanceGeneration()
 {
     if (UIStatusWindow.currentStatus == STATUS.SIMULATING)
     {
         BraidSimulationManager.SetShouldBraidsEvaluate(false);
     }
 }
Exemplo n.º 2
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            MenuController.ToggleMenu();
        }

        if (Input.GetKeyDown(KeyCode.R))
        {
            SceneManager.LoadScene(3);
        }

        if (Input.GetKeyDown(KeyCode.Space))
        {
            if (UIStatusWindow.currentStatus == STATUS.SIMULATING)
            {
                BraidSimulationManager.SetShouldBraidsEvaluate(false);
            }
        }

        if (Input.GetKeyDown(KeyCode.Q))
        {
            Camera.main.GetComponent <MouseLook>().SetTarget(sceneCenter.transform.position);
        }

        AddTranslation();
    }
Exemplo n.º 3
0
 public void StopEA()
 {
     if (_ea != null && _ea.RunState == SharpNeat.Core.RunState.Running)
     {
         _ea.Stop();
         Debug.Log("Stoping EA");
         IECManager.SetUIToExitState();
         BraidSimulationManager.SetShouldBraidsEvaluate(false);
     }
 }
    public IEnumerator Evaluate(IBlackBox box)
    {
        if (optimizer != null)
        {
            optimizer.Evaluate(box);
            hasEvaluated = false;
            while (BraidSimulationManager.ShouldBraidsEvaluate())
            {
                //Debug.Log("Evaluating");
                yield return(new WaitForSeconds(0.2f));
            }

            optimizer.StopEvaluation(box);
            float       fit     = optimizer.GetFitness(box);
            FitnessInfo fitness = new FitnessInfo(fit, fit);
            dict.Add(box, fitness);
            BraidSimulationManager.evaluationsMade++;
            hasEvaluated = true;
        }
    }
Exemplo n.º 5
0
        private IEnumerator evaluateList(IList <TGenome> genomeList)
        {
            Debug.Log("---------------------- Evaluating List of genomes ----------------------");

            Dictionary <TGenome, TPhenome>      dict        = new Dictionary <TGenome, TPhenome>();
            Dictionary <TGenome, FitnessInfo[]> fitnessDict = new Dictionary <TGenome, FitnessInfo[]>();

            for (int i = 0; i < m_optimizer.Trials; i++)
            {
                m_phenomeEvaluator.Reset();
                dict = new Dictionary <TGenome, TPhenome>();
                foreach (TGenome genome in genomeList)
                {
                    TPhenome phenome = m_genomeDecoder.Decode(genome);
                    if (i == 0)
                    {
                        fitnessDict.Add(genome, new FitnessInfo[m_optimizer.Trials]);
                    }

                    dict.Add(genome, phenome);
                    Coroutiner.StartCoroutine(m_phenomeEvaluator.Evaluate(phenome));
                }

                Debug.Log("Done creating phenomes...");

                while (!BraidSimulationManager.HasControllersCreatedData())
                {
                    Debug.Log("Waiting on controllers...");
                    yield return(new WaitForSeconds(0.05f));
                }

                ModelMessenger messenger = GameObject.FindObjectOfType <ModelMessenger>();
                messenger.SendMessageToGH();

                while (!BraidSimulationManager.HasControllersEvaluated())
                {
                    yield return(new WaitForSeconds(0.05f));
                }

                BraidSimulationManager.AdvanceGeneration();

                Debug.Log("Getting fitness values...");
                foreach (TGenome genome in dict.Keys)
                {
                    TPhenome phenome = dict[genome];
                    if (phenome != null)
                    {
                        FitnessInfo fitnessInfo = m_phenomeEvaluator.GetLastFitness(phenome);

                        fitnessDict[genome][i] = fitnessInfo;
                    }
                }
                Debug.Log("Done getting fitness values...");
            }


            foreach (TGenome genome in dict.Keys)
            {
                TPhenome phenome = dict[genome];
                if (phenome != null)
                {
                    double fitness = 0;

                    for (int i = 0; i < m_optimizer.Trials; i++)
                    {
                        fitness += fitnessDict[genome][i]._fitness;
                    }

                    fitness /= m_optimizer.Trials; // Averaged fitness

                    genome.EvaluationInfo.SetFitness(fitness);
                    genome.EvaluationInfo.AuxFitnessArr = fitnessDict[genome][0]._auxFitnessArr;
                }
            }

            Debug.Log("---------------------- End of list evaluation ----------------------");
            BraidSimulationManager.evaluationsMade = 0;
        }