Changeset 10046 for branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Void Methods/Fire.cs
- Timestamp:
- 10/17/13 12:07:20 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Void Methods/Fire.cs
r10014 r10046 20 20 #endregion 21 21 22 using System; 22 23 using System.Collections.Generic; 24 using System.Linq; 23 25 using HeuristicLab.Common; 24 26 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; … … 52 54 53 55 public override string Interpret(ISymbolicExpressionTreeNode node, IEnumerable<ISymbolicExpressionTreeNode> children) { 54 var enumerator = children.GetEnumerator();55 if (!enumerator.MoveNext()) throw new System.Exception("Fire was not given a child.");56 if (children.Count() != 1) 57 throw new ArgumentException("Expected 1 child in Fire.", "children"); 56 58 57 var symbol = enumerator.Current.Symbol; 59 var exprTree = children.Single(); 60 var symbol = exprTree.Symbol; 58 61 if (!(symbol is ShotPower)) 59 throw new System.Exception("Fire was given a child of type " + symbol.GetType() +62 throw new Exception("Fire was given a child of type " + symbol.GetType() + 60 63 ". The expected child must be of type " + typeof(ShotPower) + "."); 61 64 62 string result = ((CodeNode)symbol).Interpret(enumerator.Current, enumerator.Current.Subtrees); 63 if (enumerator.MoveNext()) throw new System.Exception("Fire was given more than one child."); 64 65 string result = ((CodeNode)symbol).Interpret(exprTree, exprTree.Subtrees); 65 66 return Prefix + result + Suffix; 66 67 }
Note: See TracChangeset
for help on using the changeset viewer.