Changeset 10011 for branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Event Methods/Events/OnScannedRobot.cs
- Timestamp:
- 10/01/13 12:08:25 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.