示例#1
0
        public void Mutate()
        {
            if (solver.RandomHelper.Mutate(100))
            {
                Inspirational = solver.AvailableInspirationals[solver.RandomHelper.GetShort(solver.AvailableInspirationals.Length)];
            }

            if (LeftNode != null)
            {
                LeftNode.Mutate();
            }
            if (RightNode != null)
            {
                RightNode.Mutate();
            }

            if (LeftNode == null)
            {
                if (solver.RandomHelper.Mutate(20))
                {
                    LeftNode = CreateRandomNode();
                }
                else if (solver.RandomHelper.Mutate(20))
                {
                    LeftNode = this.Clone(solver);
                }
            }
            else
            {
                if (solver.RandomHelper.Mutate(50))
                {
                    LeftNode = null;
                }
            }

            if (RightNode == null)
            {
                if (solver.RandomHelper.Mutate(20))
                {
                    RightNode = CreateRandomNode();
                }
                else if (solver.RandomHelper.Mutate(20))
                {
                    RightNode = this.Clone(solver);
                }
            }
            else
            {
                if (solver.RandomHelper.Mutate(50))
                {
                    RightNode = null;
                }
            }
        }