private void MutateIfNode(IfNode n) { if (PossibleDepth(n) < 1 || PossibleCount(n) < 1) { return; } int kind = _random.Next(3); switch (kind) { case 0: n.Condition = _nodeCreator.RandomNode(PossibleDepth(n), PossibleCount(n)); break; case 1: n.WhenTrue = _nodeCreator.RandomNode(PossibleDepth(n), PossibleCount(n)); break; case 2: n.WhenFalse = _nodeCreator.RandomNode(PossibleDepth(n), PossibleCount(n)); break; default: throw new InvalidOperationException("Not the right kind"); } }
public virtual Node Visit(IfNode n) { var c = VisitNode(n.Condition); var t = VisitNode(n.WhenTrue); var f = VisitNode(n.WhenFalse); return(c != n.Condition || t != n.WhenTrue || f != n.WhenFalse ? new IfNode(c, t, f) : n); }
public override void Visit(IfNode n) { if (!_hasMutation || _mutationPlace < _currentExplorationCount) { return; } Explore(n); if (_mutationPlace == _currentExplorationCount) { MutateIfNode(n); } VisitNode(n.Condition); VisitNode(n.WhenTrue); VisitNode(n.WhenFalse); }
public override Node Visit(IfNode n) { var c = VisitNode(n.Condition); ConstantNode cN = c as ConstantNode; if (cN != null) { return(cN.Value >= 0 ? VisitNode(n.WhenTrue) : VisitNode(n.WhenFalse)); } var t = VisitNode(n.WhenTrue); var f = VisitNode(n.WhenFalse); return(c != n.Condition || t != n.WhenTrue || f != n.WhenFalse ? new IfNode(c, t, f) : n); }
public override void Visit(IfNode n) { AquireTargetIfPossible(n); if (Mode == TargetMode.Get && InteractingNode != null) { _currentExplorationCount = 0; return; } var next = SetTarget(); n.Condition = next ?? n.Condition; if (next != null) { _currentExplorationCount = 0; return; } VisitNode(n.Condition); next = SetTarget(); n.WhenTrue = next ?? n.WhenTrue; if (next != null) { _currentExplorationCount = 0; return; } VisitNode(n.WhenTrue); next = SetTarget(); n.WhenFalse = next ?? n.WhenFalse; if (next != null) { _currentExplorationCount = 0; return; } VisitNode(n.WhenFalse); }
public virtual void Visit(IfNode n) { VisitNode(n.Condition); VisitNode(n.WhenTrue); VisitNode(n.WhenFalse); }
public override void Visit(IfNode n) { VisitNode(n.Condition); VisitNode(_currentValue >= 0 ? n.WhenTrue : n.WhenFalse); }