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 moved

Legend:

Unmodified
Added
Removed
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Logical Expressions/Conjunction.cs

    r9999 r10011  
    2020#endregion
    2121
     22using System;
     23using System.Collections.Generic;
     24using System.Linq;
    2225using HeuristicLab.Common;
    2326using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
     
    2730  [StorableClass]
    2831  public class Conjunction : CodeNode {
    29     public override int MinimumArity { get { return 0; } }
    30     public override int MaximumArity { get { return 0; } }
     32    public override int MinimumArity { get { return 2; } }
     33    public override int MaximumArity { get { return byte.MaxValue; } }
    3134
    3235    [Storable]
     
    3740
    3841    [StorableConstructor]
    39     private Conjunction(bool deserializing) : base(deserializing) { }
    40     private Conjunction(Conjunction original, Cloner cloner)
    41       : base(original, cloner) {
    42     }
     42    protected Conjunction(bool deserializing) : base(deserializing) { }
     43    protected Conjunction(Conjunction original, Cloner cloner) : base(original, cloner) { }
    4344
    4445    public Conjunction()
    4546      : base("Conjunction", "Conjunction comparator.") {
    46       this.Prefix = "&&";
    47       this.Suffix = "";
     47      Prefix = "(";
     48      Suffix = ")";
    4849    }
    4950
     
    5253    }
    5354
    54     public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
    55       return this.Prefix + " " + this.Suffix;
     55    public override string Interpret(ISymbolicExpressionTreeNode node, IEnumerable<ISymbolicExpressionTreeNode> children) {
     56      if (children.Count() < 2)
     57        throw new ArgumentException("Expected at leaset 2 children.", "children");
     58
     59      string result = string.Join(" && ", children.Select(c => ((CodeNode)c.Symbol).Interpret(c, c.Subtrees)));
     60      return Prefix + result + Suffix;
    5661    }
    5762  }
Note: See TracChangeset for help on using the changeset viewer.