public StackMachine(AptNode node) { nodeCount = node.Count(); instructions = new Instruction[nodeCount]; inPtr = 0; BuildInstructions(node); }
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); } }
public void RebuildInstructions(AptNode node) { nodeCount = node.Count(); instructions = new Instruction[nodeCount]; inPtr = 0; BuildInstructions(node); }