public void GetTotalFitnessForSpecies_Test() { //Create agents AgentObject agent1 = new CustomAgent(populationManager, new Genome(), 100); AgentObject agent2 = new CustomAgent(populationManager, new Genome(), 200); AgentObject agent3 = new CustomAgent(populationManager, new Genome(), 300); AgentObject agent4 = new CustomAgent(populationManager, new Genome(), 400); //Create two species Species species1 = new Species(0, agent1); species1.Members.Add(agent1); species1.Members.Add(agent2); species1.CalculateTotalSharedFitness(); Species species2 = new Species(0, agent3); species2.Members.Add(agent3); species2.Members.Add(agent4); species2.CalculateTotalSharedFitness(); //Create a list of species List <Species> speciesList = new List <Species>(); speciesList.Add(species1); speciesList.Add(species2); float sum = populationManager.GetTotalFitnessForSpecies(speciesList); Assert.AreEqual(500, sum); }
public void GetAmountOffSpringsForSpecies_Test() { //Create agents AgentObject agent1 = new CustomAgent(populationManager, new Genome(), 1); AgentObject agent2 = new CustomAgent(populationManager, new Genome(), 2); AgentObject agent3 = new CustomAgent(populationManager, new Genome(), 3); AgentObject agent4 = new CustomAgent(populationManager, new Genome(), 3); //Create two species Species species1 = new Species(0, agent1); species1.Members.Add(agent1); species1.Members.Add(agent2); species1.CalculateTotalSharedFitness(); Species species2 = new Species(0, agent3); species2.Members.Add(agent3); species2.Members.Add(agent4); species2.CalculateTotalSharedFitness(); //Create a list of species List <Species> speciesList = new List <Species>(); speciesList.Add(species1); speciesList.Add(species2); Dictionary <Species, int> result = populationManager.GetAmountOffSpringsForSpecies(90, new List <Species>(speciesList)); Assert.AreEqual(30, result[species1]); Assert.AreEqual(60, result[species2]); }
public void CalculateTotalSharedFitness_Test() { species.CalculateTotalSharedFitness(); Assert.AreEqual(2.333f, species.TotalSharedFitness, 0.001f); }