Changeset 10046 for branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Logical Expressions/Negation.cs
- Timestamp:
- 10/17/13 12:07:20 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Logical Expressions/Negation.cs
r10011 r10046 20 20 #endregion 21 21 22 using System; 22 23 using System.Collections.Generic; 24 using System.Linq; 23 25 using HeuristicLab.Common; 24 26 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; … … 52 54 53 55 public override string Interpret(ISymbolicExpressionTreeNode node, IEnumerable<ISymbolicExpressionTreeNode> children) { 54 var enumerator = children.GetEnumerator();55 if (!enumerator.MoveNext()) throw new System.Exception("Negation was not given a child.");56 if (children.Count() != 1) 57 throw new ArgumentException("Expected 1 child in Negation.", "children"); 56 58 57 var symbol = enumerator.Current.Symbol; 59 var exprTree = children.Single(); 60 var symbol = exprTree.Symbol; 58 61 if (!(symbol is LogicalValue || symbol is Conjunction || symbol is Disjunction || symbol is Negation || symbol is ILogicalComparator)) 59 62 throw new System.Exception("Negation was given a child of type " + symbol.GetType() + … … 64 67 + " or " + typeof(ILogicalComparator) + "."); 65 68 66 string result = ((CodeNode)symbol).Interpret(enumerator.Current, enumerator.Current.Subtrees); 67 if (enumerator.MoveNext()) throw new System.Exception("LogicalExpression was given more than one child."); 68 69 return Prefix + result + Suffix; 69 return Prefix + ((CodeNode)symbol).Interpret(exprTree, exprTree.Subtrees) + Suffix; 70 70 } 71 71 }
Note: See TracChangeset
for help on using the changeset viewer.