Exemple #1
0
 public void CheckIfBestNetwork(NEAT network)
 {
     if (network.GetFitness() > NeatEvolverData.bestFitness)
     {
         NeatEvolverData.bestFitness = network.GetFitness();
         NeatEvolverData.currentBest = new NEAT(network);
         uiData.UpdateBestFit(NeatEvolverData.bestFitness);
     }
 }
Exemple #2
0
    private NEAT BreedChild(int speciesIndex)
    {
        if (NeatEvolverData.species[speciesIndex].networks.Count <= 1)
        {
            return(new NEAT(NeatEvolverData.species[speciesIndex].networks[0]));
        }

        int rand1 = Random.Range(0, NeatEvolverData.species[speciesIndex].networks.Count);
        int rand2 = Random.Range(0, NeatEvolverData.species[speciesIndex].networks.Count);

        while (rand1 == rand2 && NeatEvolverData.species[speciesIndex].networks.Count > 1)
        {
            rand2 = Random.Range(0, NeatEvolverData.species[speciesIndex].networks.Count);
        }

        NEAT parentA = NeatEvolverData.species[speciesIndex].networks[rand1];
        NEAT parentB = NeatEvolverData.species[speciesIndex].networks[rand2];

        if (parentA.GetFitness() >= parentB.GetFitness())
        {
            return(Crossover(parentA, parentB));
        }

        return(Crossover(parentB, parentA));
    }
Exemple #3
0
 private void SetAgent(NEAT network)
 {
     currentAgent.SetNEAT(network);
     uiDrawer.DrawNetwork(network);
     uiData.UpdateSpec(NeatEvolverData.currentSpecies + 1);
     uiData.UpdateGenom(NeatEvolverData.currenGene);
     uiData.UpdateFit(network.GetFitness());
 }
Exemple #4
0
 public int GetFitness()
 {
     return(NEATNetowrk.GetFitness());
 }