예제 #1
0
 public StackMachine(AptNode node)
 {
     nodeCount    = node.Count();
     instructions = new Instruction[nodeCount];
     inPtr        = 0;
     BuildInstructions(node);
 }
예제 #2
0
        public AptNode BreedWith(AptNode partner, Random r, bool video)
        {
            var(newNode, _)       = partner.GetNthNode(r.Next(0, partner.Count()));
            var(nodeToReplace, _) = this.GetNthNode(r.Next(0, this.Count()));

            //TODO - this prevents things from getting screwed up by warp nodes
            // But maybe we could allow crossover at warp nodes if we think of a clean way to handle it
            if (newNode.type == NodeType.WARP1 || nodeToReplace.type == NodeType.WARP1)
            {
                return(nodeToReplace);
            }

            newNode.parent = nodeToReplace.parent;

            if (newNode.parent != null)
            {
                for (int i = 0; i < newNode.parent.children.Length; i++)
                {
                    if (newNode.parent.children[i] == nodeToReplace)
                    {
                        newNode.parent.children[i] = newNode;
                    }
                }
                return(null);
            }
            else
            {
                return(newNode);
            }
        }
예제 #3
0
 public void RebuildInstructions(AptNode node)
 {
     nodeCount    = node.Count();
     instructions = new Instruction[nodeCount];
     inPtr        = 0;
     BuildInstructions(node);
 }