Changeset 5517 for branches/DataAnalysis Refactoring/HeuristicLab.Problems.ArtificialAnt/3.4/AntInterpreter.cs
- Timestamp:
- 02/18/11 14:50:19 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataAnalysis Refactoring/HeuristicLab.Problems.ArtificialAnt/3.4/AntInterpreter.cs
r5473 r5517 25 25 using HeuristicLab.Data; 26 26 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 27 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;28 27 using HeuristicLab.Problems.ArtificialAnt.Symbols; 29 28 … … 65 64 private int currentAntLocationColumn; 66 65 private int nFoodItems; 67 private Stack< SymbolicExpressionTreeNode> nodeStack = new Stack<SymbolicExpressionTreeNode>();66 private Stack<ISymbolicExpressionTreeNode> nodeStack = new Stack<ISymbolicExpressionTreeNode>(); 68 67 69 68 private void CountFoodItems() { … … 94 93 // expression evaluated completly => start at root again 95 94 if (nodeStack.Count == 0) { 96 nodeStack.Push(Expression.Root. SubTrees[0].SubTrees[0]);95 nodeStack.Push(Expression.Root.GetSubTree(0).GetSubTree(0)); 97 96 } 98 97 … … 115 114 NextField(out nextAntLocationRow, out nextAntLocationColumn); 116 115 if (World[nextAntLocationRow, nextAntLocationColumn]) { 117 nodeStack.Push(currentNode. SubTrees[0]);116 nodeStack.Push(currentNode.GetSubTree(0)); 118 117 } else { 119 nodeStack.Push(currentNode. SubTrees[1]);118 nodeStack.Push(currentNode.GetSubTree(1)); 120 119 } 121 120 } else if (currentNode.Symbol is Prog2) { 122 nodeStack.Push(currentNode. SubTrees[1]);123 nodeStack.Push(currentNode. SubTrees[0]);121 nodeStack.Push(currentNode.GetSubTree(1)); 122 nodeStack.Push(currentNode.GetSubTree(0)); 124 123 return; 125 124 } else if (currentNode.Symbol is Prog3) { 126 nodeStack.Push(currentNode. SubTrees[2]);127 nodeStack.Push(currentNode. SubTrees[1]);128 nodeStack.Push(currentNode. SubTrees[0]);125 nodeStack.Push(currentNode.GetSubTree(2)); 126 nodeStack.Push(currentNode.GetSubTree(1)); 127 nodeStack.Push(currentNode.GetSubTree(0)); 129 128 return; 130 129 } else if (currentNode.Symbol is InvokeFunction) { … … 132 131 var functionDefinition = (SymbolicExpressionTreeNode)FindMatchingFunction(invokeNode.Symbol.FunctionName).Clone(); 133 132 var argumentCutPoints = (from node in functionDefinition.IterateNodesPrefix() 134 where node.SubTrees.Count > 0133 where node.SubTrees.Count() > 0 135 134 from subtree in node.SubTrees 136 135 where subtree is ArgumentTreeNode 137 select new { Parent = node, Argument = subtree.Symbol as Argument, ChildIndex = node. SubTrees.IndexOf(subtree) }).ToList();136 select new { Parent = node, Argument = subtree.Symbol as Argument, ChildIndex = node.IndexOfSubTree(subtree) }).ToList(); 138 137 foreach (var cutPoint in argumentCutPoints) { 139 138 cutPoint.Parent.RemoveSubTree(cutPoint.ChildIndex); 140 cutPoint.Parent.InsertSubTree(cutPoint.ChildIndex, (SymbolicExpressionTreeNode)invokeNode. SubTrees[cutPoint.Argument.ArgumentIndex].Clone());139 cutPoint.Parent.InsertSubTree(cutPoint.ChildIndex, (SymbolicExpressionTreeNode)invokeNode.GetSubTree(cutPoint.Argument.ArgumentIndex).Clone()); 141 140 } 142 nodeStack.Push(functionDefinition. SubTrees[0]);141 nodeStack.Push(functionDefinition.GetSubTree(0)); 143 142 } else { 144 143 throw new InvalidOperationException(currentNode.Symbol.ToString());
Note: See TracChangeset
for help on using the changeset viewer.