Changeset 5733 for branches/DataAnalysis Refactoring/HeuristicLab.Problems.ArtificialAnt/3.4/AntInterpreter.cs
- Timestamp:
- 03/17/11 14:07:47 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataAnalysis Refactoring/HeuristicLab.Problems.ArtificialAnt/3.4/AntInterpreter.cs
r5517 r5733 51 51 52 52 private SymbolicExpressionTreeNode FindMatchingFunction(string name) { 53 foreach (var defunBranch in expression.Root.Sub Trees.OfType<DefunTreeNode>()) {53 foreach (var defunBranch in expression.Root.Subtrees.OfType<DefunTreeNode>()) { 54 54 if (defunBranch.FunctionName == name) return defunBranch; 55 55 } … … 93 93 // expression evaluated completly => start at root again 94 94 if (nodeStack.Count == 0) { 95 nodeStack.Push(Expression.Root.GetSub Tree(0).GetSubTree(0));95 nodeStack.Push(Expression.Root.GetSubtree(0).GetSubtree(0)); 96 96 } 97 97 … … 114 114 NextField(out nextAntLocationRow, out nextAntLocationColumn); 115 115 if (World[nextAntLocationRow, nextAntLocationColumn]) { 116 nodeStack.Push(currentNode.GetSub Tree(0));116 nodeStack.Push(currentNode.GetSubtree(0)); 117 117 } else { 118 nodeStack.Push(currentNode.GetSub Tree(1));118 nodeStack.Push(currentNode.GetSubtree(1)); 119 119 } 120 120 } else if (currentNode.Symbol is Prog2) { 121 nodeStack.Push(currentNode.GetSub Tree(1));122 nodeStack.Push(currentNode.GetSub Tree(0));121 nodeStack.Push(currentNode.GetSubtree(1)); 122 nodeStack.Push(currentNode.GetSubtree(0)); 123 123 return; 124 124 } else if (currentNode.Symbol is Prog3) { 125 nodeStack.Push(currentNode.GetSub Tree(2));126 nodeStack.Push(currentNode.GetSub Tree(1));127 nodeStack.Push(currentNode.GetSub Tree(0));125 nodeStack.Push(currentNode.GetSubtree(2)); 126 nodeStack.Push(currentNode.GetSubtree(1)); 127 nodeStack.Push(currentNode.GetSubtree(0)); 128 128 return; 129 129 } else if (currentNode.Symbol is InvokeFunction) { … … 131 131 var functionDefinition = (SymbolicExpressionTreeNode)FindMatchingFunction(invokeNode.Symbol.FunctionName).Clone(); 132 132 var argumentCutPoints = (from node in functionDefinition.IterateNodesPrefix() 133 where node.Sub Trees.Count() > 0134 from subtree in node.Sub Trees133 where node.Subtrees.Count() > 0 134 from subtree in node.Subtrees 135 135 where subtree is ArgumentTreeNode 136 select new { Parent = node, Argument = subtree.Symbol as Argument, ChildIndex = node.IndexOfSub Tree(subtree) }).ToList();136 select new { Parent = node, Argument = subtree.Symbol as Argument, ChildIndex = node.IndexOfSubtree(subtree) }).ToList(); 137 137 foreach (var cutPoint in argumentCutPoints) { 138 cutPoint.Parent.RemoveSub Tree(cutPoint.ChildIndex);139 cutPoint.Parent.InsertSub Tree(cutPoint.ChildIndex, (SymbolicExpressionTreeNode)invokeNode.GetSubTree(cutPoint.Argument.ArgumentIndex).Clone());138 cutPoint.Parent.RemoveSubtree(cutPoint.ChildIndex); 139 cutPoint.Parent.InsertSubtree(cutPoint.ChildIndex, (SymbolicExpressionTreeNode)invokeNode.GetSubtree(cutPoint.Argument.ArgumentIndex).Clone()); 140 140 } 141 nodeStack.Push(functionDefinition.GetSub Tree(0));141 nodeStack.Push(functionDefinition.GetSubtree(0)); 142 142 } else { 143 143 throw new InvalidOperationException(currentNode.Symbol.ToString());
Note: See TracChangeset
for help on using the changeset viewer.