Changeset 10011 for branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Event Methods/Events
- Timestamp:
- 10/01/13 12:08:25 (11 years ago)
- 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 20 20 #endregion 21 21 22 using System.Collections.Generic; 22 23 using HeuristicLab.Common; 23 24 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; … … 37 38 38 39 [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) { } 43 42 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.") { } 49 44 50 45 public override IDeepCloneable Clone(Cloner cloner) { … … 52 47 } 53 48 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 ";"; 56 51 } 57 52 } -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Event Methods/Events/OnBulletHit.cs
r9790 r10011 20 20 #endregion 21 21 22 using System; 23 using System.Collections.Generic; 24 using System.Linq; 22 25 using HeuristicLab.Common; 23 26 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; … … 37 40 38 41 [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) { } 44 44 45 45 public OnBulletHit() 46 46 : 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 }"; 49 51 } 50 52 … … 53 55 } 54 56 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; 60 60 } 61 61 } -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Event Methods/Events/OnBulletMissed.cs
r9790 r10011 20 20 #endregion 21 21 22 using System; 23 using System.Collections.Generic; 24 using System.Linq; 22 25 using HeuristicLab.Common; 23 26 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; … … 37 40 38 41 [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) { } 44 44 45 45 public OnBulletMissed() 46 46 : 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 }"; 49 51 } 50 52 … … 53 55 } 54 56 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; 60 60 } 61 61 } -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Event Methods/Events/OnHitByBullet.cs
r9790 r10011 20 20 #endregion 21 21 22 using System; 23 using System.Collections.Generic; 24 using System.Linq; 22 25 using HeuristicLab.Common; 23 26 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; … … 37 40 38 41 [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) { } 44 44 45 45 public OnHitByBullet() 46 46 : 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 }"; 49 51 } 50 52 … … 53 55 } 54 56 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; 60 60 } 61 61 } -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Event Methods/Events/OnHitRobot.cs
r9790 r10011 20 20 #endregion 21 21 22 using System; 23 using System.Collections.Generic; 24 using System.Linq; 22 25 using HeuristicLab.Common; 23 26 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; … … 37 40 38 41 [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) { } 43 44 44 45 public OnHitRobot() 45 46 : 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 }"; 48 51 } 49 52 … … 52 55 } 53 56 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; 59 60 } 60 61 } -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Event Methods/Events/OnHitWall.cs
r9790 r10011 20 20 #endregion 21 21 22 using System; 23 using System.Collections.Generic; 24 using System.Linq; 22 25 using HeuristicLab.Common; 23 26 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; … … 37 40 38 41 [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) { } 44 44 45 45 public OnHitWall() 46 46 : 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 }"; 49 51 } 50 52 … … 53 55 } 54 56 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; 60 60 } 61 61 } -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Event Methods/Events/OnScannedRobot.cs
r9790 r10011 20 20 #endregion 21 21 22 using System; 23 using System.Collections.Generic; 24 using System.Linq; 22 25 using HeuristicLab.Common; 23 26 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; … … 37 40 38 41 [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) { } 44 44 45 45 public OnScannedRobot() 46 46 : 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) { 49 double absoluteBearing = getHeading() + e.getBearing(); 50 double bearingFromGun = normalRelativeAngleDegrees(absoluteBearing - getGunHeading()); 51 setTurnGunRight(bearingFromGun);"; 52 Suffix = 53 @"execute(); 54 }"; 52 55 } 53 56 … … 56 59 } 57 60 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; 63 64 } 64 65 }
Note: See TracChangeset
for help on using the changeset viewer.