public GSIndividual(string timeStamp, int generation, int indNum) { this.timeStamp = timeStamp; this.generation = generation; this.indNum = indNum; shaderName = timeStamp + "_" + generation + "_" + indNum; red = new GSTree(false); green = new GSTree(false); blue = new GSTree(false); alpha = new GSTree(false); xpos = new GSTree(true); ypos = new GSTree(true); zpos = new GSTree(true); }
public void CrossoverRandom(GSTree treeB) { List <GSTreeNode> nodes = new List <GSTreeNode>(); GSTreeTraverse.GetDoubleArgFunctionNodes(treeB.root, nodes); System.Random rand = new System.Random(); GSTreeNode nodeB = nodes[rand.Next(nodes.Count)]; nodes = new List <GSTreeNode>(); GSTreeTraverse.GetDoubleArgFunctionNodes(root, nodes); rand = new System.Random(); GSTreeNode nodeA = nodes[rand.Next(nodes.Count)]; GSTreeNode newTree = new GSTreeNode(); newTree.left = nodeB.left; newTree.right = nodeA.right; nodeA = (GSTreeNode)newTree.Clone(); }
public GSIndividual Permutate(int iNum) { GSIndividual newInd = new GSIndividual(timeStamp, generation, iNum); newInd.red = GSTree.DeepClone(red); newInd.red.PermutateRandomNode(); newInd.green = GSTree.DeepClone(green); newInd.green.PermutateRandomNode(); newInd.blue = GSTree.DeepClone(blue); newInd.blue.PermutateRandomNode(); newInd.alpha = GSTree.DeepClone(alpha); newInd.alpha.PermutateRandomNode(); newInd.xpos = GSTree.DeepClone(xpos); newInd.xpos.PermutateRandomNode(); newInd.ypos = GSTree.DeepClone(ypos); newInd.ypos.PermutateRandomNode(); newInd.zpos = GSTree.DeepClone(zpos); newInd.zpos.PermutateRandomNode(); return(newInd); }
public GSIndividual Crossover(GSIndividual ind, int iNum) { GSIndividual newInd = new GSIndividual(timeStamp, generation, iNum); newInd.red = GSTree.DeepClone(red); newInd.red.CrossoverRandom(ind.red); newInd.green = GSTree.DeepClone(green); newInd.green.CrossoverRandom(ind.green); newInd.blue = GSTree.DeepClone(blue); newInd.blue.CrossoverRandom(ind.blue); newInd.alpha = GSTree.DeepClone(alpha); newInd.alpha.CrossoverRandom(ind.alpha); newInd.xpos = GSTree.DeepClone(xpos); newInd.xpos.CrossoverRandom(ind.xpos); newInd.ypos = GSTree.DeepClone(ypos); newInd.ypos.CrossoverRandom(ind.ypos); newInd.zpos = GSTree.DeepClone(zpos); newInd.zpos.CrossoverRandom(ind.zpos); return(newInd); }