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/Event Methods/Events/OnHitRobot.cs

    r9790 r10011  
    2020#endregion
    2121
     22using System;
     23using System.Collections.Generic;
     24using System.Linq;
    2225using HeuristicLab.Common;
    2326using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
     
    3740
    3841    [StorableConstructor]
    39     private OnHitRobot(bool deserializing) : base(deserializing) { }
    40     private OnHitRobot(OnHitRobot original, Cloner cloner)
    41       : base(original, cloner) {
    42     }
     42    protected OnHitRobot(bool deserializing) : base(deserializing) { }
     43    protected OnHitRobot(OnHitRobot original, Cloner cloner) : base(original, cloner) { }
    4344
    4445    public OnHitRobot()
    4546      : base("OnHitRobot", "This method is called when your robot collides with another robot.") {
    46       this.Prefix = "\r\npublic void onHitRobot(HitRobotEvent e) {\r\n";
    47       this.Suffix = "\r\nexecute();\r\n}\r\n";
     47      Prefix = "public void onHitRobot(HitRobotEvent e) {";
     48      Suffix =
     49@"execute();
     50}";
    4851    }
    4952
     
    5255    }
    5356
    54     public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
    55       string result = "";
    56       foreach (ISymbolicExpressionTreeNode c in children)
    57         result += "\r\n" + ((CodeNode)c.Symbol).Interpret(c, c.Subtrees);
    58       return this.Prefix + "\r\n" + result + "\r\n" + this.Suffix;
     57    public override string Interpret(ISymbolicExpressionTreeNode node, IEnumerable<ISymbolicExpressionTreeNode> children) {
     58      string result = children.Aggregate(string.Empty, (current, c) => current + (Environment.NewLine + ((CodeNode)c.Symbol).Interpret(c, c.Subtrees)));
     59      return Prefix + result + Environment.NewLine + Suffix;
    5960    }
    6061  }
Note: See TracChangeset for help on using the changeset viewer.