Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/01/13 12:08:25 (11 years ago)
Author:
jkarder
Message:

#2069:

  • refactored grammar and symbols
  • fixed cloning and storable ctors
  • fixed plugin dependencies
File:
1 edited

Legend:

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

    r9790 r10011  
    2020#endregion
    2121
    22 
     22using System;
     23using System.Linq;
    2324using HeuristicLab.Common;
    2425using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
     
    2930  public class Block : CodeNode {
    3031    public override int MinimumArity { get { return 1; } }
    31     public override int MaximumArity { get { return 10; } }
     32    public override int MaximumArity { get { return byte.MaxValue; } }
    3233
    3334    [Storable]
     
    3839
    3940    [StorableConstructor]
    40     private Block(bool deserializing) : base(deserializing) { }
    41     private Block(Block original, Cloner cloner)
    42       : base(original, cloner) {
    43     }
     41    protected Block(bool deserializing) : base(deserializing) { }
     42    protected Block(Block original, Cloner cloner) : base(original, cloner) { }
    4443
    4544    public Block()
    4645      : base("Block", "A group of statements.") {
    47       this.Prefix = "{\r\n\t";
    48       this.Suffix = "\r\nexecute();\r\n}\r\n";
     46      Prefix = "{";
     47      Suffix = "}";
    4948    }
    5049
     
    5453
    5554    public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
    56       string result = "";
    57       foreach (ISymbolicExpressionTreeNode c in children)
    58         result += "\r\n" + ((CodeNode)c.Symbol).Interpret(c, c.Subtrees);
    59       return this.Prefix + "\r\n" + result + "\r\n" + this.Suffix;
     55      string result = children.Aggregate(string.Empty, (current, c) => current + (Environment.NewLine + ((CodeNode)c.Symbol).Interpret(c, c.Subtrees)));
     56      return Prefix + result + Environment.NewLine + Suffix;
    6057    }
    6158  }
Note: See TracChangeset for help on using the changeset viewer.