Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/14/13 11:03:13 (11 years ago)
Author:
ascheibe
Message:

#2069 fixed cloning constructors and formatting

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/Robocode/HeuristicLab.Problems.Robocode/Symbols/Event Methods/Events/OnScannedRobot.cs

    r9565 r9630  
    33using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    44
    5 namespace HeuristicLab.Problems.Robocode
    6 {
    7     [StorableClass]
    8     public class OnScannedRobot : CodeNode
    9     {
    10         public override int MinimumArity { get { return 2; } }
    11         public override int MaximumArity { get { return 10; } }
     5namespace HeuristicLab.Problems.Robocode {
     6  [StorableClass]
     7  public class OnScannedRobot : CodeNode {
     8    public override int MinimumArity { get { return 2; } }
     9    public override int MaximumArity { get { return 10; } }
    1210
    13         [Storable]
    14         public override string Prefix { get; set; }
     11    [Storable]
     12    public override string Prefix { get; set; }
    1513
    16         [Storable]
    17         public override string Suffix { get; set; }
     14    [Storable]
     15    public override string Suffix { get; set; }
    1816
    19         [StorableConstructor]
    20         private OnScannedRobot(bool deserializing) : base(deserializing) { }
    21         private OnScannedRobot(OnScannedRobot original, Cloner cloner)
    22             : base(original, cloner)
    23         {
    24             this.Prefix = "\r\npublic void onScannedRobot(ScannedRobotEvent e) {" +
    25                           "\r\ndouble absoluteBearing = getHeading() + e.getBearing();" +
    26                           "\r\ndouble bearingFromGun = normalRelativeAngleDegrees(absoluteBearing - getGunHeading());" +
    27                           "\r\nsetTurnGunRight(bearingFromGun);\r\n";
    28             this.Suffix = "\r\nexecute();\r\n}\r\n";
    29         }
     17    [StorableConstructor]
     18    private OnScannedRobot(bool deserializing) : base(deserializing) { }
     19    private OnScannedRobot(OnScannedRobot original, Cloner cloner)
     20      : base(original, cloner) {
    3021
    31         public OnScannedRobot()
    32             : base("OnScannedRobot", "This method is called when your robot sees another robot, i.e. when the robot's radar scan \"hits\" another robot.")
    33         {
    34             this.Prefix = "\r\npublic void onScannedRobot(ScannedRobotEvent e) {" +
    35                           "\r\ndouble absoluteBearing = getHeading() + e.getBearing();" +
    36                           "\r\ndouble bearingFromGun = normalRelativeAngleDegrees(absoluteBearing - getGunHeading());" +
    37                           "\r\nsetTurnGunRight(bearingFromGun);\r\n";
    38             this.Suffix = "\r\nexecute();\r\n}\r\n";
    39         }
     22    }
    4023
    41         public override IDeepCloneable Clone(Cloner cloner)
    42         {
    43             return new OnScannedRobot(this, cloner);
    44         }
     24    public OnScannedRobot()
     25      : base("OnScannedRobot", "This method is called when your robot sees another robot, i.e. when the robot's radar scan \"hits\" another robot.") {
     26      this.Prefix = "\r\npublic void onScannedRobot(ScannedRobotEvent e) {" +
     27                    "\r\ndouble absoluteBearing = getHeading() + e.getBearing();" +
     28                    "\r\ndouble bearingFromGun = normalRelativeAngleDegrees(absoluteBearing - getGunHeading());" +
     29                    "\r\nsetTurnGunRight(bearingFromGun);\r\n";
     30      this.Suffix = "\r\nexecute();\r\n}\r\n";
     31    }
    4532
    46         public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children)
    47         {
    48             string result = "";
    49             foreach (ISymbolicExpressionTreeNode c in children)
    50                 result += "\r\n" + ((CodeNode)c.Symbol).Interpret(c, c.Subtrees);
    51             return this.Prefix + "\r\n" + result + "\r\n" + this.Suffix;
    52         }
     33    public override IDeepCloneable Clone(Cloner cloner) {
     34      return new OnScannedRobot(this, cloner);
    5335    }
     36
     37    public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
     38      string result = "";
     39      foreach (ISymbolicExpressionTreeNode c in children)
     40        result += "\r\n" + ((CodeNode)c.Symbol).Interpret(c, c.Subtrees);
     41      return this.Prefix + "\r\n" + result + "\r\n" + this.Suffix;
     42    }
     43  }
    5444}
Note: See TracChangeset for help on using the changeset viewer.