Example #1
0
        public void TestMutate()
        {
            Random.InitState(666);
            var e     = ExperienceExtensions.Load($"Assets/Scripts/Tests/Data/BasicExperience.json", true);
            var child = new Characteristics
            {
                Computation           = 50,
                Life                  = 50,
                Robustness            = 50,
                Energy                = 50,
                ReproductionCost      = 50,
                AnimalCharacteristics = new Characteristics.Types.AnimalCharacteristics
                {
                    Speed = 50,
                    RandomMovementRange = 50,
                    SightRange          = 50,
                    EatRange            = 50,
                    Metabolism          = 50,
                }
            };

            child.Mutate(e.AnimalCharacteristics, e.AnimalCharacteristics,
                         e.AnimalCharacteristicsMinimumBound, e.AnimalCharacteristicsMaximumBound);
            // The offspring should have different characteristics
            Assert.False(AreObjectFloatsEqual(child, e.AnimalCharacteristics)); // TODO: fix this assert
            // TODO: could go further: assert that it stays within a distribution while differing from the initial value
            // TODO: why ? could have hard coded stuff but mutation rate and range might change
        }