public void CheckIfBestNetwork(NEAT network) { if (network.GetFitness() > NeatEvolverData.bestFitness) { NeatEvolverData.bestFitness = network.GetFitness(); NeatEvolverData.currentBest = new NEAT(network); uiData.UpdateBestFit(NeatEvolverData.bestFitness); } }
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)); }
private void SetAgent(NEAT network) { currentAgent.SetNEAT(network); uiDrawer.DrawNetwork(network); uiData.UpdateSpec(NeatEvolverData.currentSpecies + 1); uiData.UpdateGenom(NeatEvolverData.currenGene); uiData.UpdateFit(network.GetFitness()); }
public int GetFitness() { return(NEATNetowrk.GetFitness()); }