Changeset 10011 for branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Void Methods/TurnGunRight.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/Void Methods/TurnGunRight.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 TurnGunRight(bool deserializing) : base(deserializing) { } 41 private TurnGunRight(TurnGunRight original, Cloner cloner) 42 : base(original, cloner) { 43 44 } 40 protected TurnGunRight(bool deserializing) : base(deserializing) { } 41 protected TurnGunRight(TurnGunRight original, Cloner cloner) : base(original, cloner) { } 45 42 46 43 public TurnGunRight() 47 44 : base("TurnGunRight", "Immediately turns the robot's gun to the right by degrees.") { 48 this.Prefix = "setTurnGunRight(";49 this.Suffix = ");";45 Prefix = "setTurnGunRight("; 46 Suffix = ");"; 50 47 } 51 48 … … 54 51 } 55 52 56 public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {53 public override string Interpret(ISymbolicExpressionTreeNode node, IEnumerable<ISymbolicExpressionTreeNode> children) { 57 54 var enumerator = children.GetEnumerator(); 55 if (!enumerator.MoveNext()) throw new System.Exception("TurnGunRight was not given a child."); 58 56 59 if (!enumerator.MoveNext()) throw new System.Exception("TurnGunRight was not given a child.");60 57 var symbol = enumerator.Current.Symbol; 61 62 if (!(symbol is Number || symbol is NumericalOperation || symbol is NumericalExpression)) 63 throw new System.Exception("TurnGunRight was given a child of type " + symbol.GetType().ToString() + 64 ". The expected child must be of type " + typeof(Number).ToString() + " or " + 65 typeof(NumericalOperation).ToString() + " or " + 66 typeof(NumericalExpression).ToString() + "."); 58 if (!(symbol is NumericalExpression)) 59 throw new System.Exception("TurnGunRight was given a child of type " + symbol.GetType() + 60 ". The expected child must be of type " + typeof(NumericalExpression) + "."); 67 61 68 62 string result = ((CodeNode)symbol).Interpret(enumerator.Current, enumerator.Current.Subtrees); 69 63 if (enumerator.MoveNext()) throw new System.Exception("TurnGunRight was given more than one child."); 70 64 71 return this.Prefix + result + this.Suffix;65 return Prefix + result + Suffix; 72 66 } 73 67 }
Note: See TracChangeset
for help on using the changeset viewer.