Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/01/13 12:08:25 (10 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/OnScannedRobot.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 OnScannedRobot(bool deserializing) : base(deserializing) { }
    40     private OnScannedRobot(OnScannedRobot original, Cloner cloner)
    41       : base(original, cloner) {
    42 
    43     }
     42    protected OnScannedRobot(bool deserializing) : base(deserializing) { }
     43    protected OnScannedRobot(OnScannedRobot original, Cloner cloner) : base(original, cloner) { }
    4444
    4545    public OnScannedRobot()
    4646      : base("OnScannedRobot", "This method is called when your robot sees another robot, i.e. when the robot's radar scan \"hits\" another robot.") {
    47       this.Prefix = "\r\npublic void onScannedRobot(ScannedRobotEvent e) {" +
    48                     "\r\ndouble absoluteBearing = getHeading() + e.getBearing();" +
    49                     "\r\ndouble bearingFromGun = normalRelativeAngleDegrees(absoluteBearing - getGunHeading());" +
    50                     "\r\nsetTurnGunRight(bearingFromGun);\r\n";
    51       this.Suffix = "\r\nexecute();\r\n}\r\n";
     47      Prefix =
     48@"public void onScannedRobot(ScannedRobotEvent e) {
     49double absoluteBearing = getHeading() + e.getBearing();
     50double bearingFromGun = normalRelativeAngleDegrees(absoluteBearing - getGunHeading());
     51setTurnGunRight(bearingFromGun);";
     52      Suffix =
     53@"execute();
     54}";
    5255    }
    5356
     
    5659    }
    5760
    58     public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
    59       string result = "";
    60       foreach (ISymbolicExpressionTreeNode c in children)
    61         result += "\r\n" + ((CodeNode)c.Symbol).Interpret(c, c.Subtrees);
    62       return this.Prefix + "\r\n" + result + "\r\n" + this.Suffix;
     61    public override string Interpret(ISymbolicExpressionTreeNode node, IEnumerable<ISymbolicExpressionTreeNode> children) {
     62      string result = children.Aggregate(string.Empty, (current, c) => current + (Environment.NewLine + ((CodeNode)c.Symbol).Interpret(c, c.Subtrees)));
     63      return Prefix + result + Environment.NewLine + Suffix;
    6364    }
    6465  }
Note: See TracChangeset for help on using the changeset viewer.