public override void Mutate() { //add if (Tool.Mutate(100)) { MathOp op = new MathOp(); op.Left = BaseOp; BaseOp = op; } BaseOp.Mutate(); }
public override void Mutate() { if (Tool.Mutate(50)) { MutateValue(); } if (Tool.Mutate(100)) { int digits = Tool.GetInt(5); Value = Math.Round(Value, digits); } if (Tool.Mutate(200)) { Value = (int)Value; } }
public override void Mutate() { //swap if (Tool.Mutate(100)) { MathLiteral tmp = Left; Left = Right; Right = tmp; } if (Tool.Mutate(100)) { this.Collapse(); } if (Tool.Mutate(15)) { if (Left.IsStatic()) { MathValue val = new MathValue(); val.Value = Left.Evaluate(null); Left = val; } } if (Tool.Mutate(15)) { if (Right.IsStatic()) { MathValue val = new MathValue(); val.Value = Right.Evaluate(null); Right = val; } } //delete if (Tool.Mutate(15)) { if (Left is MathOp) { MathLiteral grandChild = ((MathOp)Left).Left; Left = grandChild; } } //delete if (Tool.Mutate(15)) { if (Left is MathOp) { MathLiteral grandChild = ((MathOp)Left).Right; Left = grandChild; } } //delete if (Tool.Mutate(15)) { if (Right is MathOp) { MathLiteral grandChild = ((MathOp)Right).Right; Right = grandChild; } } //delete if (Tool.Mutate(15)) { if (Right is MathOp) { MathLiteral grandChild = ((MathOp)Right).Left; Right = grandChild; } } //add if (Tool.Mutate(100)) { MathOp op = new MathOp(); op.Left = Left; Left = op; } //add if (Tool.Mutate(100)) { MathOp op = new MathOp(); op.Right = Right; Right = op; } //replace if (Tool.Mutate(30)) { MathLiteral newLeft = CreateRandomNode(); Left = newLeft; } //replace if (Tool.Mutate(30)) { MathLiteral newRight = CreateRandomNode(); Right = newRight; } Left.Mutate(); Right.Mutate(); if (Tool.Mutate(50)) { MutateOp(); } }