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
Location:
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Event Methods/Events
Files:
7 edited

Legend:

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

    r9790 r10011  
    2020#endregion
    2121
     22using System.Collections.Generic;
    2223using HeuristicLab.Common;
    2324using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
     
    3738
    3839    [StorableConstructor]
    39     private EmptyEvent(bool deserializing) : base(deserializing) { }
    40     private EmptyEvent(EmptyEvent original, Cloner cloner)
    41       : base(original, cloner) {
    42     }
     40    protected EmptyEvent(bool deserializing) : base(deserializing) { }
     41    protected EmptyEvent(EmptyEvent original, Cloner cloner) : base(original, cloner) { }
    4342
    44     public EmptyEvent()
    45       : base("EmptyEvent", "This is a placeholder for an empty event.") {
    46       this.Prefix = "";
    47       this.Suffix = "";
    48     }
     43    public EmptyEvent() : base("EmptyEvent", "This is a placeholder for an empty event.") { }
    4944
    5045    public override IDeepCloneable Clone(Cloner cloner) {
     
    5247    }
    5348
    54     public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
    55       return "";
     49    public override string Interpret(ISymbolicExpressionTreeNode node, IEnumerable<ISymbolicExpressionTreeNode> children) {
     50      return ";";
    5651    }
    5752  }
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Event Methods/Events/OnBulletHit.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 OnBulletHit(bool deserializing) : base(deserializing) { }
    40     private OnBulletHit(OnBulletHit original, Cloner cloner)
    41       : base(original, cloner) {
    42 
    43     }
     42    protected OnBulletHit(bool deserializing) : base(deserializing) { }
     43    protected OnBulletHit(OnBulletHit original, Cloner cloner) : base(original, cloner) { }
    4444
    4545    public OnBulletHit()
    4646      : base("OnBulletHit", "This method is called when one of your bullets hits another robot.") {
    47       this.Prefix = "\r\npublic void onBulletHit(BulletHitEvent e) {\r\n";
    48       this.Suffix = "\r\nexecute();\r\n}\r\n";
     47      Prefix = "public void onBulletHit(BulletHitEvent e) {";
     48      Suffix =
     49@"execute();
     50}";
    4951    }
    5052
     
    5355    }
    5456
    55     public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
    56       string result = "";
    57       foreach (ISymbolicExpressionTreeNode c in children)
    58         result += "\r\n" + ((CodeNode)c.Symbol).Interpret(c, c.Subtrees);
    59       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;
    6060    }
    6161  }
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Event Methods/Events/OnBulletMissed.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 OnBulletMissed(bool deserializing) : base(deserializing) { }
    40     private OnBulletMissed(OnBulletMissed original, Cloner cloner)
    41       : base(original, cloner) {
    42 
    43     }
     42    protected OnBulletMissed(bool deserializing) : base(deserializing) { }
     43    protected OnBulletMissed(OnBulletMissed original, Cloner cloner) : base(original, cloner) { }
    4444
    4545    public OnBulletMissed()
    4646      : base("OnBulletMissed", "This method is called when one of your bullets misses, i.e. hits a wall.") {
    47       this.Prefix = "\r\npublic void onBulletMissed(BulletMissedEvent e) {\r\n";
    48       this.Suffix = "\r\nexecute();\r\n}\r\n";
     47      Prefix = "public void onBulletMissed(BulletMissedEvent e) {";
     48      Suffix =
     49@"execute();
     50}";
    4951    }
    5052
     
    5355    }
    5456
    55     public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
    56       string result = "";
    57       foreach (ISymbolicExpressionTreeNode c in children)
    58         result += "\r\n" + ((CodeNode)c.Symbol).Interpret(c, c.Subtrees);
    59       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;
    6060    }
    6161  }
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Event Methods/Events/OnHitByBullet.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 OnHitByBullet(bool deserializing) : base(deserializing) { }
    40     private OnHitByBullet(OnHitByBullet original, Cloner cloner)
    41       : base(original, cloner) {
    42 
    43     }
     42    protected OnHitByBullet(bool deserializing) : base(deserializing) { }
     43    protected OnHitByBullet(OnHitByBullet original, Cloner cloner) : base(original, cloner) { }
    4444
    4545    public OnHitByBullet()
    4646      : base("OnHitByBullet", "This method is called when your robot is hit by a bullet.") {
    47       this.Prefix = "\r\npublic void onHitByBullet(HitByBulletEvent e) {\r\n";
    48       this.Suffix = "\r\nexecute();\r\n}\r\n";
     47      Prefix = "public void onHitByBullet(HitByBulletEvent e) {";
     48      Suffix =
     49@"execute();
     50}";
    4951    }
    5052
     
    5355    }
    5456
    55     public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
    56       string result = "";
    57       foreach (ISymbolicExpressionTreeNode c in children)
    58         result += "\r\n" + ((CodeNode)c.Symbol).Interpret(c, c.Subtrees);
    59       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;
    6060    }
    6161  }
  • 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  }
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Event Methods/Events/OnHitWall.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 OnHitWall(bool deserializing) : base(deserializing) { }
    40     private OnHitWall(OnHitWall original, Cloner cloner)
    41       : base(original, cloner) {
    42 
    43     }
     42    protected OnHitWall(bool deserializing) : base(deserializing) { }
     43    protected OnHitWall(OnHitWall original, Cloner cloner) : base(original, cloner) { }
    4444
    4545    public OnHitWall()
    4646      : base("OnHitWall", "This method is called when your robot collides with a wall.") {
    47       this.Prefix = "\r\npublic void onHitWall(HitWallEvent e) {\r\n";
    48       this.Suffix = "\r\nexecute();\r\n}\r\n";
     47      Prefix = "public void onHitWall(HitWallEvent e) {";
     48      Suffix =
     49@"execute();
     50}";
    4951    }
    5052
     
    5355    }
    5456
    55     public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
    56       string result = "";
    57       foreach (ISymbolicExpressionTreeNode c in children)
    58         result += "\r\n" + ((CodeNode)c.Symbol).Interpret(c, c.Subtrees);
    59       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;
    6060    }
    6161  }
  • 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.