예제 #1
0
 internal Genome BuildGenome()
 {
     var outputs = new Node[_numOutputs];
     for (int i = 0; i < _numInputs; i++) {
         outputs[i] = RampedHalfAndHalf();
     }
     return new Genome(outputs, this);
 }
예제 #2
0
 internal override Node Clone(Stack<Node> chainToReplace, Node newNode)
 {
     var replacedChild = chainToReplace.Pop();
     if (chainToReplace.Count == 0) {
         return replacedChild == Left ? new AddOperator(newNode, Right) : new AddOperator(Left, newNode);
     }
     return replacedChild == Left ? new AddOperator(Left.Clone(chainToReplace, newNode), Right) : new AddOperator(Left, Right.Clone(chainToReplace, newNode));
 }
예제 #3
0
 internal override bool Find(Stack<Node> stack, Node target)
 {
     bool result =  this == target || Left.Find(stack, target) || Right.Find(stack, target);
     if (result) {
         stack.Push(this);
     }
     return result;
 }
예제 #4
0
 internal BinaryOperator(Node left, Node right)
     : base(2)
 {
     Left = left;
     Right = right;
 }
예제 #5
0
 internal override bool Find(Stack<Node> stack, Node target)
 {
     if (this == target) {
         stack.Push(this);
         return true;
     }
     return false;
 }
예제 #6
0
 internal override Node Clone(Stack<Node> chainToReplace, Node newNode)
 {
     Debugger.Break();
     throw new Exception("Can't replace child of a terminal");
 }
예제 #7
0
 internal SubtractOperator(Node left, Node right)
     : base(left, right)
 {
 }
예제 #8
0
 internal CompareOperator(Node a, Node b, Node c, Node d)
     : base(4)
 {
     _a = a;
     _b = b;
     _c = c;
     _d = d;
     _children = new[] {_a, _b, _c, _d};
 }
예제 #9
0
 internal ProtectedDivideOperator(Node left, Node right)
     : base(left, right)
 {
 }
예제 #10
0
 internal abstract bool Find(Stack<Node> stack, Node target);
예제 #11
0
 internal abstract Node Clone(Stack<Node> chainToReplace, Node newNode);
예제 #12
0
 internal MultiplyOperator(Node left, Node right)
     : base(left, right)
 {
 }
예제 #13
0
 internal ExponentOperator(Node left, Node right)
     : base(left, right)
 {
 }
예제 #14
0
 internal override Node Clone(Stack<Node> chainToReplace, Node newNode)
 {
     throw new OperationCanceledException();
     /*
     var replacedChild = chainToReplace.Pop();
     Node a, b, c, d;
     return chainToReplace.Count == 0 ? (
             replacedChild == Left ?
                 new ExponentOperator(newNode, Right) :
                 new ExponentOperator(Left, newNode)) :
             replacedChild == Left ?
                 new ExponentOperator(Left.Clone(chainToReplace, newNode), Right) :
                 new ExponentOperator(Left, Right.Clone(chainToReplace, newNode));
      */
 }
예제 #15
0
 internal Genome(Node[] outputs, God god)
 {
     _outputs = outputs;
     Head = outputs[0];
     _god = god;
 }
예제 #16
0
 internal override Node Clone(Stack<Node> chainToReplace, Node newNode)
 {
     var replacedChild = chainToReplace.Pop();
     return chainToReplace.Count == 0 ? (
             replacedChild == Left ?
                 new ProtectedDivideOperator(newNode, Right) :
                 new ProtectedDivideOperator(Left, newNode)) :
             replacedChild == Left
                 ? new ProtectedDivideOperator(Left.Clone(chainToReplace, newNode), Right)
                 : new ProtectedDivideOperator(Left, Right.Clone(chainToReplace, newNode));
 }
예제 #17
0
 private Node ReplaceRandomWith(Node newNode)
 {
     var result = GetRandomChain();
     return result.Count == 0 ? newNode : Head.Clone(result, newNode);
 }
예제 #18
0
 internal AddOperator(Node left, Node right)
     : base(left, right)
 {
 }