Free cookie consent management tool by TermsFeed Policy Generator

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

#2069 fixed cloning constructors and formatting

Location:
branches/Robocode/HeuristicLab.Problems.Robocode/Symbols/Event Methods/Events
Files:
7 edited

Legend:

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

    r9612 r9630  
    1919    private EmptyEvent(EmptyEvent original, Cloner cloner)
    2020      : base(original, cloner) {
    21       this.Prefix = "";
    22       this.Suffix = "";
    2321    }
    2422
  • branches/Robocode/HeuristicLab.Problems.Robocode/Symbols/Event Methods/Events/OnBulletHit.cs

    r9565 r9630  
    33using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    44
    5 namespace HeuristicLab.Problems.Robocode
    6 {
    7     [StorableClass]
    8     public class OnBulletHit : 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 OnBulletHit : 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 OnBulletHit(bool deserializing) : base(deserializing) { }
    21         private OnBulletHit(OnBulletHit original, Cloner cloner)
    22             : base(original, cloner)
    23         {
    24             this.Prefix = "\r\npublic void onBulletHit(BulletHitEvent e) {\r\n";
    25             this.Suffix = "\r\nexecute();\r\n}\r\n";
    26         }
     17    [StorableConstructor]
     18    private OnBulletHit(bool deserializing) : base(deserializing) { }
     19    private OnBulletHit(OnBulletHit original, Cloner cloner)
     20      : base(original, cloner) {
    2721
    28         public OnBulletHit()
    29             : base("OnBulletHit", "This method is called when one of your bullets hits another robot.")
    30         {
    31             this.Prefix = "\r\npublic void onBulletHit(BulletHitEvent e) {\r\n";
    32             this.Suffix = "\r\nexecute();\r\n}\r\n";
    33         }
     22    }
    3423
    35         public override IDeepCloneable Clone(Cloner cloner)
    36         {
    37             return new OnBulletHit(this, cloner);
    38         }
     24    public OnBulletHit()
     25      : base("OnBulletHit", "This method is called when one of your bullets hits another robot.") {
     26      this.Prefix = "\r\npublic void onBulletHit(BulletHitEvent e) {\r\n";
     27      this.Suffix = "\r\nexecute();\r\n}\r\n";
     28    }
    3929
    40         public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children)
    41         {
    42             string result = "";
    43             foreach (ISymbolicExpressionTreeNode c in children)
    44                 result += "\r\n" + ((CodeNode)c.Symbol).Interpret(c, c.Subtrees);
    45             return this.Prefix + "\r\n" + result + "\r\n" + this.Suffix;
    46         }
     30    public override IDeepCloneable Clone(Cloner cloner) {
     31      return new OnBulletHit(this, cloner);
    4732    }
     33
     34    public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
     35      string result = "";
     36      foreach (ISymbolicExpressionTreeNode c in children)
     37        result += "\r\n" + ((CodeNode)c.Symbol).Interpret(c, c.Subtrees);
     38      return this.Prefix + "\r\n" + result + "\r\n" + this.Suffix;
     39    }
     40  }
    4841}
  • branches/Robocode/HeuristicLab.Problems.Robocode/Symbols/Event Methods/Events/OnBulletMissed.cs

    r9565 r9630  
    33using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    44
    5 namespace HeuristicLab.Problems.Robocode
    6 {
    7     [StorableClass]
    8     public class OnBulletMissed : 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 OnBulletMissed : 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 OnBulletMissed(bool deserializing) : base(deserializing) { }
    21         private OnBulletMissed(OnBulletMissed original, Cloner cloner)
    22             : base(original, cloner)
    23         {
    24             this.Prefix = "\r\npublic void onBulletMissed(BulletMissedEvent e) {\r\n";
    25             this.Suffix = "\r\nexecute();\r\n}\r\n";
    26         }
     17    [StorableConstructor]
     18    private OnBulletMissed(bool deserializing) : base(deserializing) { }
     19    private OnBulletMissed(OnBulletMissed original, Cloner cloner)
     20      : base(original, cloner) {
    2721
    28         public OnBulletMissed()
    29             : base("OnBulletMissed", "This method is called when one of your bullets misses, i.e. hits a wall.")
    30         {
    31             this.Prefix = "\r\npublic void onBulletMissed(BulletMissedEvent e) {\r\n";
    32             this.Suffix = "\r\nexecute();\r\n}\r\n";
    33         }
     22    }
    3423
    35         public override IDeepCloneable Clone(Cloner cloner)
    36         {
    37             return new OnBulletMissed(this, cloner);
    38         }
     24    public OnBulletMissed()
     25      : base("OnBulletMissed", "This method is called when one of your bullets misses, i.e. hits a wall.") {
     26      this.Prefix = "\r\npublic void onBulletMissed(BulletMissedEvent e) {\r\n";
     27      this.Suffix = "\r\nexecute();\r\n}\r\n";
     28    }
    3929
    40         public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children)
    41         {
    42             string result = "";
    43             foreach (ISymbolicExpressionTreeNode c in children)
    44                 result += "\r\n" + ((CodeNode)c.Symbol).Interpret(c, c.Subtrees);
    45             return this.Prefix + "\r\n" + result + "\r\n" + this.Suffix;
    46         }
     30    public override IDeepCloneable Clone(Cloner cloner) {
     31      return new OnBulletMissed(this, cloner);
    4732    }
     33
     34    public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
     35      string result = "";
     36      foreach (ISymbolicExpressionTreeNode c in children)
     37        result += "\r\n" + ((CodeNode)c.Symbol).Interpret(c, c.Subtrees);
     38      return this.Prefix + "\r\n" + result + "\r\n" + this.Suffix;
     39    }
     40  }
    4841}
  • branches/Robocode/HeuristicLab.Problems.Robocode/Symbols/Event Methods/Events/OnHitByBullet.cs

    r9565 r9630  
    33using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    44
    5 namespace HeuristicLab.Problems.Robocode
    6 {
    7     [StorableClass]
    8     public class OnHitByBullet : 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 OnHitByBullet : 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 OnHitByBullet(bool deserializing) : base(deserializing) { }
    21         private OnHitByBullet(OnHitByBullet original, Cloner cloner)
    22             : base(original, cloner)
    23         {
    24             this.Prefix = "\r\npublic void onHitByBullet(HitByBulletEvent e) {\r\n";
    25             this.Suffix = "\r\nexecute();\r\n}\r\n";
    26         }
     17    [StorableConstructor]
     18    private OnHitByBullet(bool deserializing) : base(deserializing) { }
     19    private OnHitByBullet(OnHitByBullet original, Cloner cloner)
     20      : base(original, cloner) {
    2721
    28         public OnHitByBullet()
    29             : base("OnHitByBullet", "This method is called when your robot is hit by a bullet.")
    30         {
    31             this.Prefix = "\r\npublic void onHitByBullet(HitByBulletEvent e) {\r\n";
    32             this.Suffix = "\r\nexecute();\r\n}\r\n";
    33         }
     22    }
    3423
    35         public override IDeepCloneable Clone(Cloner cloner)
    36         {
    37             return new OnHitByBullet(this, cloner);
    38         }
     24    public OnHitByBullet()
     25      : base("OnHitByBullet", "This method is called when your robot is hit by a bullet.") {
     26      this.Prefix = "\r\npublic void onHitByBullet(HitByBulletEvent e) {\r\n";
     27      this.Suffix = "\r\nexecute();\r\n}\r\n";
     28    }
    3929
    40         public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children)
    41         {
    42             string result = "";
    43             foreach (ISymbolicExpressionTreeNode c in children)
    44                 result += "\r\n" + ((CodeNode)c.Symbol).Interpret(c, c.Subtrees);
    45             return this.Prefix + "\r\n" + result + "\r\n" + this.Suffix;
    46         }
     30    public override IDeepCloneable Clone(Cloner cloner) {
     31      return new OnHitByBullet(this, cloner);
    4732    }
     33
     34    public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
     35      string result = "";
     36      foreach (ISymbolicExpressionTreeNode c in children)
     37        result += "\r\n" + ((CodeNode)c.Symbol).Interpret(c, c.Subtrees);
     38      return this.Prefix + "\r\n" + result + "\r\n" + this.Suffix;
     39    }
     40  }
    4841}
  • branches/Robocode/HeuristicLab.Problems.Robocode/Symbols/Event Methods/Events/OnHitRobot.cs

    r9565 r9630  
    33using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    44
    5 namespace HeuristicLab.Problems.Robocode
    6 {
    7     [StorableClass]
    8     public class OnHitRobot : 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 OnHitRobot : 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 OnHitRobot(bool deserializing) : base(deserializing) { }
    21         private OnHitRobot(OnHitRobot original, Cloner cloner)
    22             : base(original, cloner)
    23         {
    24             this.Prefix = "\r\npublic void onHitRobot(HitRobotEvent e) {\r\n";
    25             this.Suffix = "\r\nexecute();\r\n}\r\n";
    26         }
     17    [StorableConstructor]
     18    private OnHitRobot(bool deserializing) : base(deserializing) { }
     19    private OnHitRobot(OnHitRobot original, Cloner cloner)
     20      : base(original, cloner) {
     21    }
    2722
    28         public OnHitRobot()
    29             : base("OnHitRobot", "This method is called when your robot collides with another robot.")
    30         {
    31             this.Prefix = "\r\npublic void onHitRobot(HitRobotEvent e) {\r\n";
    32             this.Suffix = "\r\nexecute();\r\n}\r\n";
    33         }
     23    public OnHitRobot()
     24      : base("OnHitRobot", "This method is called when your robot collides with another robot.") {
     25      this.Prefix = "\r\npublic void onHitRobot(HitRobotEvent e) {\r\n";
     26      this.Suffix = "\r\nexecute();\r\n}\r\n";
     27    }
    3428
    35         public override IDeepCloneable Clone(Cloner cloner)
    36         {
    37             return new OnHitRobot(this, cloner);
    38         }
     29    public override IDeepCloneable Clone(Cloner cloner) {
     30      return new OnHitRobot(this, cloner);
     31    }
    3932
    40         public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children)
    41         {
    42             string result = "";
    43             foreach (ISymbolicExpressionTreeNode c in children)
    44                 result += "\r\n" + ((CodeNode)c.Symbol).Interpret(c, c.Subtrees);
    45             return this.Prefix + "\r\n" + result + "\r\n" + this.Suffix;
    46         }
     33    public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
     34      string result = "";
     35      foreach (ISymbolicExpressionTreeNode c in children)
     36        result += "\r\n" + ((CodeNode)c.Symbol).Interpret(c, c.Subtrees);
     37      return this.Prefix + "\r\n" + result + "\r\n" + this.Suffix;
    4738    }
     39  }
    4840}
  • branches/Robocode/HeuristicLab.Problems.Robocode/Symbols/Event Methods/Events/OnHitWall.cs

    r9565 r9630  
    33using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    44
    5 namespace HeuristicLab.Problems.Robocode
    6 {
    7     [StorableClass]
    8     public class OnHitWall : 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 OnHitWall : 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 OnHitWall(bool deserializing) : base(deserializing) { }
    21         private OnHitWall(OnHitWall original, Cloner cloner)
    22             : base(original, cloner)
    23         {
    24             this.Prefix = "\r\npublic void onHitWall(HitWallEvent e) {\r\n";
    25             this.Suffix = "\r\nexecute();\r\n}\r\n";
    26         }
     17    [StorableConstructor]
     18    private OnHitWall(bool deserializing) : base(deserializing) { }
     19    private OnHitWall(OnHitWall original, Cloner cloner)
     20      : base(original, cloner) {
    2721
    28         public OnHitWall()
    29             : base("OnHitWall", "This method is called when your robot collides with a wall.")
    30         {
    31             this.Prefix = "\r\npublic void onHitWall(HitWallEvent e) {\r\n";
    32             this.Suffix = "\r\nexecute();\r\n}\r\n";
    33         }
     22    }
    3423
    35         public override IDeepCloneable Clone(Cloner cloner)
    36         {
    37             return new OnHitWall(this, cloner);
    38         }
     24    public OnHitWall()
     25      : base("OnHitWall", "This method is called when your robot collides with a wall.") {
     26      this.Prefix = "\r\npublic void onHitWall(HitWallEvent e) {\r\n";
     27      this.Suffix = "\r\nexecute();\r\n}\r\n";
     28    }
    3929
    40         public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children)
    41         {
    42             string result = "";
    43             foreach (ISymbolicExpressionTreeNode c in children)
    44                 result += "\r\n" + ((CodeNode)c.Symbol).Interpret(c, c.Subtrees);
    45             return this.Prefix + "\r\n" + result + "\r\n" + this.Suffix;
    46         }
     30    public override IDeepCloneable Clone(Cloner cloner) {
     31      return new OnHitWall(this, cloner);
    4732    }
     33
     34    public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
     35      string result = "";
     36      foreach (ISymbolicExpressionTreeNode c in children)
     37        result += "\r\n" + ((CodeNode)c.Symbol).Interpret(c, c.Subtrees);
     38      return this.Prefix + "\r\n" + result + "\r\n" + this.Suffix;
     39    }
     40  }
    4841}
  • 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.