Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/01/13 12:08:25 (11 years ago)
Author:
jkarder
Message:

#2069:

  • refactored grammar and symbols
  • fixed cloning and storable ctors
  • fixed plugin dependencies
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Void Methods/TurnGunLeft.cs

    r9790 r10011  
    2020#endregion
    2121
    22 
     22using System.Collections.Generic;
    2323using HeuristicLab.Common;
    2424using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
     
    3838
    3939    [StorableConstructor]
    40     private TurnGunLeft(bool deserializing) : base(deserializing) { }
    41     private TurnGunLeft(TurnGunLeft original, Cloner cloner)
    42       : base(original, cloner) {
    43     }
     40    protected TurnGunLeft(bool deserializing) : base(deserializing) { }
     41    protected TurnGunLeft(TurnGunLeft original, Cloner cloner) : base(original, cloner) { }
    4442
    4543    public TurnGunLeft()
    4644      : base("TurnGunLeft", "Immediately turns the robot's gun to the left by degrees.") {
    47       this.Prefix = "setTurnGunLeft(";
    48       this.Suffix = ");";
     45      Prefix = "setTurnGunLeft(";
     46      Suffix = ");";
    4947    }
    5048
     
    5351    }
    5452
    55     public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
     53    public override string Interpret(ISymbolicExpressionTreeNode node, IEnumerable<ISymbolicExpressionTreeNode> children) {
    5654      var enumerator = children.GetEnumerator();
     55      if (!enumerator.MoveNext()) throw new System.Exception("TurnGunLeft was not given a child.");
    5756
    58       if (!enumerator.MoveNext()) throw new System.Exception("TurnGunLeft was not given a child.");
    5957      var symbol = enumerator.Current.Symbol;
    60 
    61       if (!(symbol is Number || symbol is NumericalOperation || symbol is NumericalExpression))
    62         throw new System.Exception("TurnGunLeft was given a child of type " + symbol.GetType().ToString() +
    63             ". The expected child must be of type " + typeof(Number).ToString() + " or " +
    64             typeof(NumericalOperation).ToString() + " or " +
    65             typeof(NumericalExpression).ToString() + ".");
     58      if (!(symbol is NumericalExpression))
     59        throw new System.Exception("TurnGunLeft was given a child of type " + symbol.GetType() +
     60            ". The expected child must be of type " + typeof(NumericalExpression) + ".");
    6661
    6762      string result = ((CodeNode)symbol).Interpret(enumerator.Current, enumerator.Current.Subtrees);
    6863      if (enumerator.MoveNext()) throw new System.Exception("TurnGunLeft was given more than one child.");
    6964
    70       return this.Prefix + result + this.Suffix;
     65      return Prefix + result + Suffix;
    7166    }
    7267  }
Note: See TracChangeset for help on using the changeset viewer.