Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/17/13 12:07:20 (11 years ago)
Author:
ascheibe
Message:

#2069 simplified Interpret methods of symbols

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Logical Expressions/Negation.cs

    r10011 r10046  
    2020#endregion
    2121
     22using System;
    2223using System.Collections.Generic;
     24using System.Linq;
    2325using HeuristicLab.Common;
    2426using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
     
    5254
    5355    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");
    5658
    57       var symbol = enumerator.Current.Symbol;
     59      var exprTree = children.Single();
     60      var symbol = exprTree.Symbol;
    5861      if (!(symbol is LogicalValue || symbol is Conjunction || symbol is Disjunction || symbol is Negation || symbol is ILogicalComparator))
    5962        throw new System.Exception("Negation was given a child of type " + symbol.GetType() +
     
    6467                                           + " or " + typeof(ILogicalComparator) + ".");
    6568
    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;
    7070    }
    7171  }
Note: See TracChangeset for help on using the changeset viewer.