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/Back.cs

    r9790 r10011  
    2020#endregion
    2121
    22 
     22using System.Collections.Generic;
    2323using HeuristicLab.Common;
    2424using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
     
    3838
    3939    [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) { }
    4342
    4443    public Back()
    4544      : base("Back", "Immediately moves your robot backward by distance measured in pixels.") {
    46       this.Prefix = "setBack(";
    47       this.Suffix = ");";
     45      Prefix = "setBack(";
     46      Suffix = ");";
    4847    }
    4948
     
    5251    }
    5352
    54     public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
     53    public override string Interpret(ISymbolicExpressionTreeNode node, IEnumerable<ISymbolicExpressionTreeNode> children) {
    5554      var enumerator = children.GetEnumerator();
     55      if (!enumerator.MoveNext()) throw new System.Exception("Back was not given a child.");
    5656
    57       if (!enumerator.MoveNext()) throw new System.Exception("Back was not given a child.");
    5857      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) + ".");
    6561
    6662      string result = ((CodeNode)symbol).Interpret(enumerator.Current, enumerator.Current.Subtrees);
    6763      if (enumerator.MoveNext()) throw new System.Exception("Back was given more than one child.");
    6864
    69       return this.Prefix + result + this.Suffix;
     65      return Prefix + result + Suffix;
    7066    }
    7167  }
Note: See TracChangeset for help on using the changeset viewer.