6uint showTree(
string& output,
Tree::Tree* tree, uint iNode = 0, uint prefix = 0)
8 Tree::PrimitiveP prim = tree->at(iNode)->primitive_;
9 int arity = prim->getNumberOfArguments();
14 else if(prim->getName() ==
"P2") {
17 iNode = showTree(output, tree, iNode, prefix);
20 iNode = showTree(output, tree, iNode, prefix);
23 else if(prim->getName() ==
"ADD" ||
24 prim->getName() ==
"AND" ||
25 prim->getName() ==
"NAND" ||
26 prim->getName() ==
"AND2" ||
27 prim->getName() ==
"XOR" ||
28 prim->getName() ==
"XNOR" ||
29 prim->getName() ==
"NOR" ||
30 prim->getName() ==
"OR") {
33 iNode = showTree(output, tree, iNode, prefix);
34 output +=
" " + prim->getName() +
" ";
36 iNode = showTree(output, tree, iNode, prefix);
39 else if(prim->getName() ==
"MUL") {
42 iNode = showTree(output, tree, iNode, prefix);
45 iNode = showTree(output, tree, iNode, prefix);
48 else if(prim->getName() ==
"NOT") {
51 for(
int child = 0; child < arity; child++) {
53 iNode = showTree(output, tree, iNode, prefix);
57 else if(prim->getName() ==
"IF") {
60 iNode = showTree(output, tree, iNode, prefix);
63 iNode = showTree(output, tree, iNode, prefix);
66 iNode = showTree(output, tree, iNode, prefix);
72 iNode = showTree(output, tree, iNode, prefix);
73 output +=
" " + prim->getName() +
" ";
75 iNode = showTree(output, tree, iNode, prefix);
79 output += prim->getName();
81 for(
int child = 0; child < arity; child++) {
83 iNode = showTree(output, tree, iNode, prefix);
std::string getName()
Return genotype's name (each genotype is uniquely identified with its name).
Tree class - implements genotype as a tree.