Beispiel #1
0
 void Breed()
 {
     for (int i = 0; i < nnAgents.Count; i++)
     {
         geneticAlgorithm.SetGenomeFitness(nnAgents[i].fitness, i);
     }
     geneticAlgorithm.BreedPopulation();
 }
Beispiel #2
0
    /// <summary>
    /// Creates a new population by evolution.
    /// </summary>
    void BreedPopulation()
    {
        for (int i = 0; i < _agents.Count; i++)
        {//sets fitness to the genomes for all agents
            _geneticAlgorithm.SetGenomeFitness(_agents[i].fitness, i);
        }

        //breeds a new population
        _geneticAlgorithm.BreedPopulation();
    }
Beispiel #3
0
 private void GoToNextGenome()
 {
     if (m_geneticAlg.GetCurrentGenomeIndex() == m_populationCount - 1)
     {
         m_geneticAlg.BreedPopulation();
         NextTestSubject();
         m_currentGenerationIndex++;
         m_currentGenomeIndex = m_geneticAlg.GetCurrentGenomeIndex();
         ChangeScene();
         return;
     }
     NextTestSubject();
     m_currentGenomeIndex = m_geneticAlg.GetCurrentGenomeIndex();
     ChangeScene();
 }
 // Update is called once per frame
 void Update()
 {
     if (testAgent.HasFailed())
     {
         if (genAlg.GetCurrentGenomeIndex() == POPULATION_SIZE - 1)
         {
             genAlg.BreedPopulation();
             NextTestSubject();
             return;
         }
         NextTestSubject();
     }
     currentAgentFitness = testAgent.FitnessFunction();
     if (currentAgentFitness > bestFitness)
     {
         bestFitness = currentAgentFitness;
     }
 }