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/Tank.cs

    r9790 r10011  
    2020#endregion
    2121
    22 
     22using System;
     23using System.Collections.Generic;
     24using System.Linq;
    2325using HeuristicLab.Common;
    2426using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
     
    2830  [StorableClass]
    2931  public class Tank : CodeNode {
    30     public override int MinimumArity { get { return 7; } }
     32    public override int MinimumArity { get { return 2; } }
    3133    public override int MaximumArity { get { return 7; } }
    3234
     
    3840
    3941    [StorableConstructor]
    40     private Tank(bool deserializing) : base(deserializing) { }
    41     private Tank(Tank original, Cloner cloner)
    42       : base(original, cloner) {
    43     }
     42    protected Tank(bool deserializing) : base(deserializing) { }
     43    protected Tank(Tank original, Cloner cloner) : base(original, cloner) { }
    4444
    4545    public Tank()
    4646      : base("Tank", "The root of a Robocode Tank program.") {
    47       this.Prefix = "package Evaluation;" +
    48                     "\r\nimport robocode.*;" +
    49                     "\r\nimport robocode.Robot;" +
    50                     "\r\nimport robocode.util.*;" +
    51                     "\r\nimport static robocode.util.Utils.normalRelativeAngleDegrees;" +
    52                     "\r\nimport java.awt.*;" +
    53                     "\r\n\r\n" +
    54                     "\r\npublic class output extends AdvancedRobot {\r\n";
    55       this.Suffix = "\r\n}";
     47      Prefix =
     48@"package Evaluation;
     49import robocode.*;
     50import robocode.Robot;
     51import robocode.util.*;
     52import static robocode.util.Utils.normalRelativeAngleDegrees;
     53import java.awt.*;
     54
     55public class output extends AdvancedRobot {";
     56      Suffix = "}";
    5657    }
    5758
     
    6061    }
    6162
    62     public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
    63       string result = "";
    64       foreach (ISymbolicExpressionTreeNode c in children)
    65         result += "\r\n" + ((CodeNode)c.Symbol).Interpret(c, c.Subtrees);
    66       return this.Prefix + "\r\n" + result + "\r\n" + this.Suffix;
     63    public override string Interpret(ISymbolicExpressionTreeNode node, IEnumerable<ISymbolicExpressionTreeNode> children) {
     64      string result = children.Aggregate(string.Empty, (current, c) => current + (Environment.NewLine + ((CodeNode)c.Symbol).Interpret(c, c.Subtrees)));
     65      return Prefix + result + Environment.NewLine + Suffix;
    6766    }
    6867  }
Note: See TracChangeset for help on using the changeset viewer.