Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/16/13 15:47:25 (11 years ago)
Author:
ascheibe
Message:

#2069

  • use groups for defining allowed child symbols in grammar
  • split functions group into functions and actions in grammar
  • moved run symbol to event group in grammar
  • fixed a bug in the ifthenelse symbol
  • enemy collection now marks one enemy per default
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Statements/IfThenElseStat.cs

    r10028 r10043  
    5050    public override string Interpret(ISymbolicExpressionTreeNode node, IEnumerable<ISymbolicExpressionTreeNode> children) {
    5151      ISymbolicExpressionTreeNode condition = null, truePart = null, falsePart = null;
     52      string[] parts = new string[3];
    5253      var enumerator = children.GetEnumerator();
    5354      int childCount = 0;
     
    6364      if (childCount < 2) throw new ArgumentException("Unexpected number of children. Expected at least 2 children.");
    6465
    65       var parts = new[] {
    66         ((CodeNode)condition.Symbol).Interpret(condition, condition.Subtrees),
    67         ((CodeNode)truePart.Symbol).Interpret(truePart, truePart.Subtrees),
    68         ((CodeNode)falsePart.Symbol).Interpret(falsePart, falsePart.Subtrees)
    69       };
     66      parts[0] = ((CodeNode)condition.Symbol).Interpret(condition, condition.Subtrees);
     67      parts[1] = ((CodeNode)truePart.Symbol).Interpret(truePart, truePart.Subtrees);
     68      if (childCount == 3) parts[2] = ((CodeNode)falsePart.Symbol).Interpret(falsePart, falsePart.Subtrees);
    7069
    7170      string result = "if (" + parts[0] + ") {" + parts[1] + "}";
Note: See TracChangeset for help on using the changeset viewer.