public void ThenThePlantWithHigherLeavesHasAHigherUpwardsPhototropismFitnessValue() { PlantFitness plantFitness = new PlantFitness(new LeafFitness(new SunInformation())); Mock <GeometryRenderSystem> geometryRenderMock = new Mock <GeometryRenderSystem>(); TurtlePen turtlePen = new TurtlePen(geometryRenderMock.Object) { ForwardStep = 1 }; Mock <ILSystem> lSystem1Mock = new Mock <ILSystem>(); lSystem1Mock.Setup(x => x.GetCommandString()).Returns("FO"); PersistentPlantGeometryStorage geometryStorage1 = new PersistentPlantGeometryStorage(); Plant plant1 = new Plant(lSystem1Mock.Object, turtlePen, geometryStorage1, Vector3.zero, Color.black); plant1.Generate(); float plant1Fitness = plantFitness.EvaluateUpwardsPhototrophicFitness(plant1); Mock <ILSystem> lSystem2Mock = new Mock <ILSystem>(); lSystem2Mock.Setup(x => x.GetCommandString()).Returns("FFO"); PersistentPlantGeometryStorage geometryStorage2 = new PersistentPlantGeometryStorage(); Plant plant2 = new Plant(lSystem2Mock.Object, turtlePen, geometryStorage2, Vector3.zero, Color.black); plant2.Generate(); float plant2Fitness = plantFitness.EvaluateUpwardsPhototrophicFitness(plant2); Debug.Log("Small Plant Fitness: " + plant1Fitness); Debug.Log("Larger Plant Fitness: " + plant2Fitness); Assert.That(plant2Fitness, Is.GreaterThan(plant1Fitness)); }
public void ThenTheFitnessIsOneMinusTheBranchVolume() { Mock <ILeafFitness> leafFitnessMock = new Mock <ILeafFitness>(); leafFitnessMock.Setup(x => x.EvaluatePhotosyntheticRate(It.IsAny <Leaf>())) .Returns(1); PlantFitness plantFitness = new PlantFitness(leafFitnessMock.Object); TurtlePen turtlePen = new TurtlePen(new GeometryRenderSystem()) { ForwardStep = 1, RotationStep = 90.0f, BranchDiameter = 0.02f }; Mock <ILSystem> lSystem1Mock = new Mock <ILSystem>(); lSystem1Mock.Setup(x => x.GetCommandString()).Returns("F+O"); PersistentPlantGeometryStorage geometryStorage1 = new PersistentPlantGeometryStorage(); Plant plant1 = new Plant(lSystem1Mock.Object, turtlePen, geometryStorage1, Vector3.zero, Color.black); plant1.Generate(); Fitness plantFitnessObject = plantFitness.EvaluatePhloemTransportationFitness(plant1); float plantFitnessValue = plantFitnessObject.LeafEnergy - plantFitnessObject.BranchCost; Debug.Log("Plant 1 Fitness: " + plantFitnessValue); Assert.That(Math.Abs(plantFitnessValue), Is.EqualTo(1 - plantFitnessObject.BranchCost)); }
public void ThenTheDynamicPhototrophicFitnessIsZero() { PlantFitness plantFitness = new PlantFitness(new LeafFitness(new SunInformation { SummerAltitude = 90, WinterAltitude = 90, Azimuth = 0 })); TurtlePen turtlePen = new TurtlePen(new GeometryRenderSystem()) { ForwardStep = 1, RotationStep = 90.0f, }; Mock <ILSystem> lSystem1Mock = new Mock <ILSystem>(); lSystem1Mock.Setup(x => x.GetCommandString()).Returns("F+O"); PersistentPlantGeometryStorage geometryStorage1 = new PersistentPlantGeometryStorage(); Plant plant1 = new Plant(lSystem1Mock.Object, turtlePen, geometryStorage1, Vector3.zero, Color.black); plant1.Generate(); float plantFitnessValue = plantFitness.EvaluateDynamicPhototrophicFitness(plant1); Debug.Log("Plant 1 Fitness: " + plantFitnessValue); Assert.That(plantFitnessValue, Is.EqualTo(0)); }
public void ThenTheTwoPlantsWillHaveTheSameUpwardsPhototropismFitnessValue() { PlantFitness plantFitness = new PlantFitness(new LeafFitness(new SunInformation())); Mock <GeometryRenderSystem> geometryRenderMock = new Mock <GeometryRenderSystem>(); TurtlePen turtlePen = new TurtlePen(geometryRenderMock.Object) { ForwardStep = 1, RotationStep = 22.5f, }; Mock <ILSystem> lSystem1Mock = new Mock <ILSystem>(); lSystem1Mock.Setup(x => x.GetCommandString()).Returns("-F-FO"); PersistentPlantGeometryStorage geometryStorage1 = new PersistentPlantGeometryStorage(); Plant plant1 = new Plant(lSystem1Mock.Object, turtlePen, geometryStorage1, Vector3.zero, Color.black); plant1.Generate(); float plant1Fitness = plantFitness.EvaluateUpwardsPhototrophicFitness(plant1); Mock <ILSystem> lSystem2Mock = new Mock <ILSystem>(); lSystem2Mock.Setup(x => x.GetCommandString()).Returns("+F+FO"); PersistentPlantGeometryStorage geometryStorage2 = new PersistentPlantGeometryStorage(); Plant plant2 = new Plant(lSystem2Mock.Object, turtlePen, geometryStorage2, Vector3.zero, Color.black); plant2.Generate(); float plant2Fitness = plantFitness.EvaluateUpwardsPhototrophicFitness(plant2); Debug.Log("Plant 1 Fitness: " + plant1Fitness); Debug.Log("Plant 2 Fitness: " + plant2Fitness); Assert.That(plant2Fitness, Is.EqualTo(plant1Fitness)); }
public void SetUp() { _plantFitness = new PlantFitness(new LeafFitness(new SunInformation())); Mock <GeometryRenderSystem> geometryRenderMock = new Mock <GeometryRenderSystem>(); TurtlePen turtlePen = new TurtlePen(geometryRenderMock.Object) { ForwardStep = 1 }; Mock <ILSystem> lSystem1Mock = new Mock <ILSystem>(); lSystem1Mock.Setup(x => x.GetCommandString()).Returns("FF"); PersistentPlantGeometryStorage geometryStorage1 = new PersistentPlantGeometryStorage(); _plant = new Plant(lSystem1Mock.Object, turtlePen, geometryStorage1, Vector3.zero, Color.black); _plant.Generate(); }
public void ThenTheDynamicPhototrophicFitnessIsHigherForTheLeafPointingDirectlyAtTheSun() { PlantFitness plantFitness = new PlantFitness(new LeafFitness(new SunInformation { SummerAltitude = 90, WinterAltitude = 90, Azimuth = 0 })); Vector3 rightVector = new Vector3(0, 1, 0); TurtlePen turtlePen = new TurtlePen(new GeometryRenderSystem()) { ForwardStep = 1, RotationStep = 90.0f, }; Mock <ILSystem> lSystem1Mock = new Mock <ILSystem>(); lSystem1Mock.Setup(x => x.GetCommandString()).Returns("F-O"); PersistentPlantGeometryStorage geometryStorage1 = new PersistentPlantGeometryStorage(); Plant plant1 = new Plant(lSystem1Mock.Object, turtlePen, geometryStorage1, Vector3.zero, Color.black); plant1.Generate(); float plant1Fitness = plantFitness.EvaluateDynamicPhototrophicFitness(plant1); Mock <ILSystem> lSystem2Mock = new Mock <ILSystem>(); lSystem2Mock.Setup(x => x.GetCommandString()).Returns("F+O"); PersistentPlantGeometryStorage geometryStorage2 = new PersistentPlantGeometryStorage(); Plant plant2 = new Plant(lSystem2Mock.Object, turtlePen, geometryStorage2, Vector3.zero, Color.black); plant2.Generate(); float plant2Fitness = plantFitness.EvaluateDynamicPhototrophicFitness(plant2); Debug.Log("Plant 1 Fitness: " + plant1Fitness); Debug.Log("Plant 2 Fitness: " + plant2Fitness); Assert.That(plant1Fitness, Is.GreaterThan(plant2Fitness)); }
public void ThenTemp() { Plant plant = new Plant(new LSystem(new RuleSet(new Dictionary <string, List <LSystemRule> > { { "A", new List <LSystemRule> { new LSystemRule { Rule = "![AFAFF]LF\\S", Probability = 1 } } }, { "L", new List <LSystemRule> { new LSystemRule { Rule = "[OO&-O-O]&O^O", Probability = 1 } } }, { "S", new List <LSystemRule> { new LSystemRule { Rule = "!&+[+F^A[!-&!\\F]]!F", Probability = 1 } } }, { "F", new List <LSystemRule> { new LSystemRule { Rule = "-[^FAL-L]L+F", Probability = 1 } } } }), "A"), new TurtlePen(new NullRenderSystem()) { BranchReductionRate = new MinMax <float> { Max = 0.8f, Min = 0.8f }, ForwardStep = 0.1f, RotationStep = 22.5f, BranchDiameter = 0.1f }, new PersistentPlantGeometryStorage(), Vector3.zero, Color.white); for (int i = 0; i < 4; ++i) { plant.Update(); } plant.Generate(); PlantFitness fitnessEval = new PlantFitness(new LeafFitness(new SunInformation { Azimuth = 240, WinterAltitude = 30, SummerAltitude = 60, Light = Color.green })); float fitness = fitnessEval.EvaluateFitness(plant); Debug.Log(fitness); Debug.Log("Leaf Fitness: " + plant.Fitness.LeafEnergy); }