Ejemplo n.º 1
0
        public void PossiblyMutate()
        {
            if (GeneticLogicRoot.RollMutateDice())
            {
                this.conditionalLeftStatement = new ConditionalLeftStatement(1);
                this.leftStatement            = null;
                return;
            }

            if (GeneticLogicRoot.RollMutateDice())
            {
                this.conditionalLeftStatement = null;
                this.leftStatement            = new LeftStatement(1);
                return;
            }

            if (this.conditionalLeftStatement != null)
            {
                this.conditionalLeftStatement.PossiblyMutate();
            }

            if (this.leftStatement != null)
            {
                this.leftStatement.PossiblyMutate();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Will possibly mutate this section of logic.
        /// </summary>
        public void PossiblyMutate()
        {
            if (GeneticLogicRoot.RollMutateDice())
            {
                OperatorSignature signature;
                if (RegistrationManager.TrySelectOperatorAtRandom(this.ReturnType, out signature))
                {
                    this.rightStatementOperation = new RightStatementOperation(signature, this.depth + 1);
                    this.readOnlyVariable        = null;
                    this.rightMethodCall         = null;
                    this.literalValue            = null;
                    return;
                }
            }

            if (GeneticLogicRoot.RollMutateDice())
            {
                VariableSignature signature;
                if (RegistrationManager.TrySelectReadOnlyVariableAtRandom(this.ReturnType, out signature))
                {
                    this.rightStatementOperation = null;
                    this.readOnlyVariable        = new ReadOnlyVariable(signature);
                    this.rightMethodCall         = null;
                    this.literalValue            = null;
                    return;
                }
            }

            if (GeneticLogicRoot.RollMutateDice())
            {
                MethodSignature signature;
                if (RegistrationManager.TrySelectRightMethodAtRandom(this.ReturnType, out signature))
                {
                    this.rightStatementOperation = null;
                    this.readOnlyVariable        = null;
                    this.rightMethodCall         = new RightMethodCall(signature, this.depth + 1);
                    this.literalValue            = null;
                    return;
                }
            }

            if (GeneticLogicRoot.RollMutateDice())
            {
                // Create the new literal value first so ReturnType get doesn't reutrn null
                this.literalValue            = new LiteralValue(this.ReturnType);
                this.rightStatementOperation = null;
                this.readOnlyVariable        = null;
                this.rightMethodCall         = null;
                return;
            }

            if (this.rightStatementOperation != null)
            {
                this.rightStatementOperation.PossiblyMutate();
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Will possibly mutate this section of logic.
        /// </summary>
        public void PossiblyMutate()
        {
            if (GeneticLogicRoot.RollMutateDice())
            {
                this.rightStatement = new RightStatement(GeneticTypeEnum.GeneticBool, this.depth + 1);
                return;
            }

            if (this.rightStatement != null)
            {
                this.rightStatement.PossiblyMutate();
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Will possibly mutate this section of logic.
        /// </summary>
        public void PossiblyMutate()
        {
            if (GeneticLogicRoot.RollMutateDice())
            {
                VariableSignature signature = RegistrationManager.SelectReadWriteVariableAtRandom();
                this.readWriteVariable = new ReadWriteVariable(signature);
                this.rightStatement    = new RightStatement(signature.VariableType, this.depth + 1);
                return;
            }

            if (this.rightStatement != null)
            {
                this.rightStatement.PossiblyMutate();
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Will possibly mutate this section of logic.
        /// </summary>
        public void PossiblyMutate()
        {
            if (GeneticLogicRoot.RollMutateDice())
            {
                MethodSignature signature = RegistrationManager.SelectLeftMethodAtRandom();
                this.leftMethodCall = new LeftMethodCall(signature, this.depth + 1);
                this.assignment     = null;
                return;
            }

            if (GeneticLogicRoot.RollMutateDice())
            {
                this.leftMethodCall = null;
                this.assignment     = new Assignment(this.depth + 1);
                return;
            }

            // Note: Method calls and variables are possibly replaced, but not themselves mutated.
            if (this.assignment != null)
            {
                this.assignment.PossiblyMutate();
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Will possibly mutate this section of logic.
        /// </summary>
        public void PossiblyMutate()
        {
            if (GeneticLogicRoot.RollMutateDice())
            {
                OperatorSignature signature;
                if (RegistrationManager.TrySelectOperatorAtRandom(this.ReturnType, out signature))
                {
                    this.operatorSignature = signature;
                    this.leftHandSide      = new RightStatement(signature.LhsType, this.depth + 1);
                    this.rightHandSide     = new RightStatement(signature.RhsType, this.depth + 1);
                    return;
                }
            }

            if (GeneticLogicRoot.RollMutateDice())
            {
                this.rightHandSide = new RightStatement(this.operatorSignature.RhsType, this.depth + 1);
                return;
            }

            if (GeneticLogicRoot.RollMutateDice())
            {
                this.leftHandSide = new RightStatement(this.operatorSignature.LhsType, this.depth + 1);
                return;
            }

            if (this.rightHandSide != null)
            {
                this.rightHandSide.PossiblyMutate();
            }

            if (this.leftHandSide != null)
            {
                this.leftHandSide.PossiblyMutate();
            }
        }