Exemplo n.º 1
0
        public void ThenThePlantHasZeroDynamicPhototrophicFitness()
        {
            float plant1Fitness = _plantFitness.EvaluateDynamicPhototrophicFitness(_plant);

            Debug.Log("Small Plant Fitness: " + plant1Fitness);
            Assert.That(plant1Fitness, Is.EqualTo(0));
        }
Exemplo n.º 2
0
        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 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));
        }
Exemplo n.º 4
0
        public void ThenTheTwoPlantsWillHaveTheSameDynamicPhototropismFitnessValue()
        {
            PlantFitness plantFitness = new PlantFitness(new LeafFitness(new SunInformation
            {
                SummerAltitude = 90,
                WinterAltitude = 90,
                Azimuth        = 0
            }));

            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("FFO");
            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("FFO");
            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(plant2Fitness, Is.EqualTo(plant1Fitness));
        }