Changeset 10011 for branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Logical Expressions/Conjunction.cs
- Timestamp:
- 10/01/13 12:08:25 (11 years ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Logical Expressions/Conjunction.cs
r9999 r10011 20 20 #endregion 21 21 22 using System; 23 using System.Collections.Generic; 24 using System.Linq; 22 25 using HeuristicLab.Common; 23 26 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; … … 27 30 [StorableClass] 28 31 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; } } 31 34 32 35 [Storable] … … 37 40 38 41 [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) { } 43 44 44 45 public Conjunction() 45 46 : base("Conjunction", "Conjunction comparator.") { 46 this.Prefix = "&&";47 this.Suffix = "";47 Prefix = "("; 48 Suffix = ")"; 48 49 } 49 50 … … 52 53 } 53 54 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; 56 61 } 57 62 }
Note: See TracChangeset
for help on using the changeset viewer.