Changeset 10011 for branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Void Methods/Back.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/Void Methods/Back.cs
r9790 r10011 20 20 #endregion 21 21 22 22 using System.Collections.Generic; 23 23 using HeuristicLab.Common; 24 24 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; … … 38 38 39 39 [StorableConstructor] 40 private Back(bool deserializing) : base(deserializing) { } 41 private Back(Back original, Cloner cloner) 42 : base(original, cloner) { } 40 protected Back(bool deserializing) : base(deserializing) { } 41 protected Back(Back original, Cloner cloner) : base(original, cloner) { } 43 42 44 43 public Back() 45 44 : base("Back", "Immediately moves your robot backward by distance measured in pixels.") { 46 this.Prefix = "setBack(";47 this.Suffix = ");";45 Prefix = "setBack("; 46 Suffix = ");"; 48 47 } 49 48 … … 52 51 } 53 52 54 public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {53 public override string Interpret(ISymbolicExpressionTreeNode node, IEnumerable<ISymbolicExpressionTreeNode> children) { 55 54 var enumerator = children.GetEnumerator(); 55 if (!enumerator.MoveNext()) throw new System.Exception("Back was not given a child."); 56 56 57 if (!enumerator.MoveNext()) throw new System.Exception("Back was not given a child.");58 57 var symbol = enumerator.Current.Symbol; 59 60 if (!(symbol is Number || symbol is NumericalOperation || symbol is NumericalExpression)) 61 throw new System.Exception("Back was given a child of type " + symbol.GetType().ToString() + 62 ". The expected child must be of type " + typeof(Number).ToString() + " or " + 63 typeof(NumericalOperation).ToString() + " or " + 64 typeof(NumericalExpression).ToString() + "."); 58 if (!(symbol is NumericalExpression)) 59 throw new System.Exception("Back was given a child of type " + symbol.GetType() + 60 ". The expected child must be of type " + typeof(NumericalExpression) + "."); 65 61 66 62 string result = ((CodeNode)symbol).Interpret(enumerator.Current, enumerator.Current.Subtrees); 67 63 if (enumerator.MoveNext()) throw new System.Exception("Back was given more than one child."); 68 64 69 return this.Prefix + result + this.Suffix;65 return Prefix + result + Suffix; 70 66 } 71 67 }
Note: See TracChangeset
for help on using the changeset viewer.