Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/01/13 12:08:25 (10 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/TurnGunRight.cs

    r9790 r10011  
    2020#endregion
    2121
    22 
     22using System.Collections.Generic;
    2323using HeuristicLab.Common;
    2424using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
     
    3838
    3939    [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) { }
    4542
    4643    public TurnGunRight()
    4744      : 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 = ");";
    5047    }
    5148
     
    5451    }
    5552
    56     public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
     53    public override string Interpret(ISymbolicExpressionTreeNode node, IEnumerable<ISymbolicExpressionTreeNode> children) {
    5754      var enumerator = children.GetEnumerator();
     55      if (!enumerator.MoveNext()) throw new System.Exception("TurnGunRight was not given a child.");
    5856
    59       if (!enumerator.MoveNext()) throw new System.Exception("TurnGunRight was not given a child.");
    6057      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) + ".");
    6761
    6862      string result = ((CodeNode)symbol).Interpret(enumerator.Current, enumerator.Current.Subtrees);
    6963      if (enumerator.MoveNext()) throw new System.Exception("TurnGunRight was given more than one child.");
    7064
    71       return this.Prefix + result + this.Suffix;
     65      return Prefix + result + Suffix;
    7266    }
    7367  }
Note: See TracChangeset for help on using the changeset viewer.