示例#1
0
        public void Mutate(double mutationRatio = 0.1)
        {
            var numberOfMutations = (int)(Size * mutationRatio);
            var random            = new Random();

            for (var i = 0; i < numberOfMutations; i++)
            {
                _data[(int)(LemmingUtils.GetRandom(random) * Size)] = LemmingUtils.GenerateNextDirection();
            }
        }
示例#2
0
        public LemmingMovementDirection GetOrGenerateNextMovement(int currentStep)
        {
            if (_data.Count <= currentStep)
            {
                while (_data.Count <= currentStep)
                {
                    _data.Add(LemmingUtils.GenerateNextDirection());
                }
            }

            return(_data[currentStep]);
        }