コード例 #1
0
        public void PossiblyMutate()
        {
            if (GeneticLogicRoot.RollMutateDice())
            {
                this.conditionalLeftStatement = new ConditionalLeftStatement();
                this.leftStatement            = null;
                return;
            }

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

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

            if (this.leftStatement != null)
            {
                this.leftStatement.PossiblyMutate();
            }
        }
コード例 #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.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.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();
            }
        }
コード例 #3
0
ファイル: Condition.cs プロジェクト: SoftwareWombat/Projects
        /// <summary>
        /// Will possibly mutate this section of logic.
        /// </summary>
        public void PossiblyMutate()
        {
            if (GeneticLogicRoot.RollMutateDice())
            {
                this.rightStatement = new RightStatement(typeof(bool));
                return;
            }

            if (this.rightStatement != null)
            {
                this.rightStatement.PossiblyMutate();
            }
        }
コード例 #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);
                return;
            }

            if (this.rightStatement != null)
            {
                this.rightStatement.PossiblyMutate();
            }
        }
コード例 #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.assignment     = null;
                return;
            }

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

            // Note: Method calls and variables are possibly replaced, but not themselves mutated.
            if (this.assignment != null)
            {
                this.assignment.PossiblyMutate();
            }
        }
コード例 #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.rightHandSide     = new RightStatement(signature.RhsType);
                    return;
                }
            }

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

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

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

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