Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/16/15 10:36:09 (9 years ago)
Author:
gkronber
Message:

#2069 refactored grammar, symbols, and interpreter

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/CodeNode.cs

    r13013 r13017  
    2727namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
    2828  [StorableClass]
    29   public abstract class CodeNode : Symbol {
    30     public abstract string Prefix { get; set; }
    31     public abstract string Suffix { get; set; }
     29  // a symbol that can represent any user-defined fragment of code
     30  public sealed class CodeSymbol : Symbol {
     31    public override int MinimumArity { get { return 1; } }
     32    public override int MaximumArity { get { return 10; } }
     33
     34    public string Prefix { get; set; }
     35    public string Suffix { get; set; }
     36
     37    public override bool CanChangeName { get { return false; } } // cannot change, otherwise we cannot detect these symbols in the interpreter
     38    public override bool CanChangeDescription { get { return false; } }
    3239
    3340    [StorableConstructor]
    34     protected CodeNode(bool deserializing) : base(deserializing) { }
    35     protected CodeNode(CodeNode original, Cloner cloner)
     41    private CodeSymbol(bool deserializing) : base(deserializing) { }
     42    private CodeSymbol(CodeSymbol original, Cloner cloner)
    3643      : base(original, cloner) {
    3744      Prefix = original.Prefix;
    3845      Suffix = original.Suffix;
    3946    }
    40     protected CodeNode(string name, string description)
    41       : base(name, description) {
     47    public CodeSymbol()
     48      : base("CodeSymbol", "The CodeSymbol symbol can represent any user-defined fragment of code.") {
    4249      Prefix = string.Empty;
    4350      Suffix = string.Empty;
    4451    }
    4552
    46     public abstract string Interpret(ISymbolicExpressionTreeNode node, IEnumerable<ISymbolicExpressionTreeNode> children);
     53    public override IDeepCloneable Clone(Cloner cloner) {
     54      return new CodeSymbol(this, cloner);
     55    }
    4756  }
    4857}
Note: See TracChangeset for help on using the changeset viewer.