Changeset 10011 for branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Event Methods/Run.cs
- Timestamp:
- 10/01/13 12:08:25 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Event Methods/Run.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; … … 27 30 [StorableClass] 28 31 public class Run : CodeNode { 29 public override int MinimumArity { get { return 2; } }32 public override int MinimumArity { get { return 1; } } 30 33 public override int MaximumArity { get { return 10; } } 31 34 … … 37 40 38 41 [StorableConstructor] 39 private Run(bool deserializing) : base(deserializing) { } 40 private Run(Run original, Cloner cloner) 41 : base(original, cloner) { 42 } 42 protected Run(bool deserializing) : base(deserializing) { } 43 protected Run(Run original, Cloner cloner) : base(original, cloner) { } 43 44 44 45 public Run() 45 46 : base("Run", "The main method in every robot.") { 46 this.Prefix = "\r\npublic void run() {\r\n\tsetAdjustGunForRobotTurn(true);\r\n\tturnRadarRightRadians(Double.POSITIVE_INFINITY);"; 47 this.Suffix = "\r\nexecute();\r\n}\r\n"; 47 Prefix = 48 @"public void run() { 49 setAdjustGunForRobotTurn(true); 50 turnRadarRightRadians(Double.POSITIVE_INFINITY);"; 51 Suffix = 52 @"execute(); 53 }"; 48 54 } 49 55 … … 52 58 } 53 59 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; 60 public override string Interpret(ISymbolicExpressionTreeNode node, IEnumerable<ISymbolicExpressionTreeNode> children) { 61 string result = children.Aggregate(string.Empty, (current, c) => current + (Environment.NewLine + ((CodeNode)c.Symbol).Interpret(c, c.Subtrees))); 62 return Prefix + result + Environment.NewLine + Suffix; 59 63 } 60 64 }
Note: See TracChangeset
for help on using the changeset viewer.