Free cookie consent management tool by TermsFeed Policy Generator

Changeset 9630 for branches/Robocode


Ignore:
Timestamp:
06/14/13 11:03:13 (11 years ago)
Author:
ascheibe
Message:

#2069 fixed cloning constructors and formatting

Location:
branches/Robocode/HeuristicLab.Problems.Robocode/Symbols
Files:
49 edited

Legend:

Unmodified
Added
Removed
  • branches/Robocode/HeuristicLab.Problems.Robocode/Symbols/Block.cs

    r9565 r9630  
    33using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    44
    5 namespace HeuristicLab.Problems.Robocode
    6 {
    7     [StorableClass]
    8     public class Block : CodeNode
    9     {
    10         public override int MinimumArity { get { return 1; } }
    11         public override int MaximumArity { get { return 10; } }
     5namespace HeuristicLab.Problems.Robocode {
     6  [StorableClass]
     7  public class Block : CodeNode {
     8    public override int MinimumArity { get { return 1; } }
     9    public override int MaximumArity { get { return 10; } }
    1210
    13         [Storable]
    14         public override string Prefix { get; set; }
     11    [Storable]
     12    public override string Prefix { get; set; }
    1513
    16         [Storable]
    17         public override string Suffix { get; set; }
     14    [Storable]
     15    public override string Suffix { get; set; }
    1816
    19         [StorableConstructor]
    20         private Block(bool deserializing) : base(deserializing) { }
    21         private Block(Block original, Cloner cloner)
    22             : base(original, cloner)
    23         {
    24             this.Prefix = "{\r\n\t";
    25             this.Suffix = "\r\nexecute();\r\n}\r\n";
    26         }
     17    [StorableConstructor]
     18    private Block(bool deserializing) : base(deserializing) { }
     19    private Block(Block original, Cloner cloner)
     20      : base(original, cloner) {
     21    }
    2722
    28         public Block()
    29             : base("Block", "A group of statements.")
    30         {
    31             this.Prefix = "{\r\n\t";
    32             this.Suffix = "\r\nexecute();\r\n}\r\n";
    33         }
     23    public Block()
     24      : base("Block", "A group of statements.") {
     25      this.Prefix = "{\r\n\t";
     26      this.Suffix = "\r\nexecute();\r\n}\r\n";
     27    }
    3428
    35         public override IDeepCloneable Clone(Cloner cloner)
    36         {
    37             return new Block(this, cloner);
    38         }
     29    public override IDeepCloneable Clone(Cloner cloner) {
     30      return new Block(this, cloner);
     31    }
    3932
    40         public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children)
    41         {
    42             string result = "";
    43             foreach (ISymbolicExpressionTreeNode c in children)
    44                 result += "\r\n" + ((CodeNode)c.Symbol).Interpret(c, c.Subtrees);
    45             return this.Prefix + "\r\n" + result + "\r\n" + this.Suffix;
    46         }
     33    public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
     34      string result = "";
     35      foreach (ISymbolicExpressionTreeNode c in children)
     36        result += "\r\n" + ((CodeNode)c.Symbol).Interpret(c, c.Subtrees);
     37      return this.Prefix + "\r\n" + result + "\r\n" + this.Suffix;
    4738    }
     39  }
    4840}
  • branches/Robocode/HeuristicLab.Problems.Robocode/Symbols/Branches/ElseStatement.cs

    r9565 r9630  
    33using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    44
    5 namespace HeuristicLab.Problems.Robocode
    6 {
    7     [StorableClass]
    8     public class ElseStatement : CodeNode
    9     {
    10         public override int MinimumArity { get { return 1; } }
    11         public override int MaximumArity { get { return 1; } }
     5namespace HeuristicLab.Problems.Robocode {
     6  [StorableClass]
     7  public class ElseStatement : CodeNode {
     8    public override int MinimumArity { get { return 1; } }
     9    public override int MaximumArity { get { return 1; } }
    1210
    13         [Storable]
    14         public override string Prefix { get; set; }
     11    [Storable]
     12    public override string Prefix { get; set; }
    1513
    16         [Storable]
    17         public override string Suffix { get; set; }
     14    [Storable]
     15    public override string Suffix { get; set; }
    1816
    19         [StorableConstructor]
    20         private ElseStatement(bool deserializing) : base(deserializing) { }
    21         private ElseStatement(ElseStatement original, Cloner cloner)
    22             : base(original, cloner)
    23         {
    24             this.Prefix = "else";
    25             this.Suffix = "";
    26         }
     17    [StorableConstructor]
     18    private ElseStatement(bool deserializing) : base(deserializing) { }
     19    private ElseStatement(ElseStatement original, Cloner cloner)
     20      : base(original, cloner) {
    2721
    28         public ElseStatement()
    29             : base("ElseStatement", "An ElseStatement.")
    30         {
    31             this.Prefix = "else";
    32             this.Suffix = "";
    33         }
     22    }
    3423
    35         public override IDeepCloneable Clone(Cloner cloner)
    36         {
    37             return new ElseStatement(this, cloner);
    38         }
     24    public ElseStatement()
     25      : base("ElseStatement", "An ElseStatement.") {
     26      this.Prefix = "else";
     27      this.Suffix = "";
     28    }
    3929
    40         public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children)
    41         {
    42             string result = "";
    43             foreach (ISymbolicExpressionTreeNode c in children)
    44                 result += "\r\n" + ((CodeNode)c.Symbol).Interpret(c, c.Subtrees);
    45             return (result == "")? "" : this.Prefix + "\r\n" + result + "\r\n" + this.Suffix;
    46         }
     30    public override IDeepCloneable Clone(Cloner cloner) {
     31      return new ElseStatement(this, cloner);
    4732    }
     33
     34    public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
     35      string result = "";
     36      foreach (ISymbolicExpressionTreeNode c in children)
     37        result += "\r\n" + ((CodeNode)c.Symbol).Interpret(c, c.Subtrees);
     38      return (result == "") ? "" : this.Prefix + "\r\n" + result + "\r\n" + this.Suffix;
     39    }
     40  }
    4841}
  • branches/Robocode/HeuristicLab.Problems.Robocode/Symbols/Branches/IfStatement.cs

    r9565 r9630  
    33using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    44
    5 namespace HeuristicLab.Problems.Robocode
    6 {
    7     [StorableClass]
    8     public class IfStatement : CodeNode
    9     {
    10         public override int MinimumArity { get { return 2; } }
    11         public override int MaximumArity { get { return 3; } }
     5namespace HeuristicLab.Problems.Robocode {
     6  [StorableClass]
     7  public class IfStatement : CodeNode {
     8    public override int MinimumArity { get { return 2; } }
     9    public override int MaximumArity { get { return 3; } }
    1210
    13         [Storable]
    14         public override string Prefix { get; set; }
     11    [Storable]
     12    public override string Prefix { get; set; }
    1513
    16         [Storable]
    17         public override string Suffix { get; set; }
     14    [Storable]
     15    public override string Suffix { get; set; }
    1816
    19         [StorableConstructor]
    20         private IfStatement(bool deserializing) : base(deserializing) { }
    21         private IfStatement(IfStatement original, Cloner cloner)
    22             : base(original, cloner)
    23         {
    24             this.Prefix = "if(";
    25             this.Suffix = ")";
    26         }
     17    [StorableConstructor]
     18    private IfStatement(bool deserializing) : base(deserializing) { }
     19    private IfStatement(IfStatement original, Cloner cloner)
     20      : base(original, cloner) {
     21    }
    2722
    28         public IfStatement()
    29             : base("IfStatement", "An IfStatement.")
    30         {
    31             this.Prefix = "if(";
    32             this.Suffix = ")";
    33         }
     23    public IfStatement()
     24      : base("IfStatement", "An IfStatement.") {
     25      this.Prefix = "if(";
     26      this.Suffix = ")";
     27    }
    3428
    35         public override IDeepCloneable Clone(Cloner cloner)
    36         {
    37             return new IfStatement(this, cloner);
    38         }
     29    public override IDeepCloneable Clone(Cloner cloner) {
     30      return new IfStatement(this, cloner);
     31    }
    3932
    40         public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children)
    41         {
    42             string condition = "", ifTrue = "", ifElse = "";
    43             foreach (ISymbolicExpressionTreeNode c in children)
    44             {
    45                 if(c.Symbol is LogicalExpression)
    46                     condition = ((CodeNode)c.Symbol).Interpret(c, c.Subtrees);
    47                 else if(c.Symbol is Block)
    48                     ifTrue = ((CodeNode)c.Symbol).Interpret(c, c.Subtrees);
    49                 else if(c.Symbol is ElseStatement || c.Symbol is DoNothing)
    50                     ifElse = ((CodeNode)c.Symbol).Interpret(c, c.Subtrees);
    51                 else
    52                     throw new System.Exception("Unexpected Child node.");
    53             }
    54             return this.Prefix + " " + condition + " " + this.Suffix +
    55                 "\r\n" + ifTrue + "\r\n" + ifElse + "\r\n";
    56         }
     33    public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
     34      string condition = "", ifTrue = "", ifElse = "";
     35      foreach (ISymbolicExpressionTreeNode c in children) {
     36        if (c.Symbol is LogicalExpression)
     37          condition = ((CodeNode)c.Symbol).Interpret(c, c.Subtrees);
     38        else if (c.Symbol is Block)
     39          ifTrue = ((CodeNode)c.Symbol).Interpret(c, c.Subtrees);
     40        else if (c.Symbol is ElseStatement || c.Symbol is DoNothing)
     41          ifElse = ((CodeNode)c.Symbol).Interpret(c, c.Subtrees);
     42        else
     43          throw new System.Exception("Unexpected Child node.");
     44      }
     45      return this.Prefix + " " + condition + " " + this.Suffix +
     46          "\r\n" + ifTrue + "\r\n" + ifElse + "\r\n";
    5747    }
     48  }
    5849}
  • branches/Robocode/HeuristicLab.Problems.Robocode/Symbols/Branches/WhileLoop.cs

    r9565 r9630  
    33using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    44
    5 namespace HeuristicLab.Problems.Robocode
    6 {
    7     [StorableClass]
    8     public class WhileLoop : CodeNode
    9     {
    10         public override int MinimumArity { get { return 2; } }
    11         public override int MaximumArity { get { return 2; } }
     5namespace HeuristicLab.Problems.Robocode {
     6  [StorableClass]
     7  public class WhileLoop : CodeNode {
     8    public override int MinimumArity { get { return 2; } }
     9    public override int MaximumArity { get { return 2; } }
    1210
    13         [Storable]
    14         public override string Prefix { get; set; }
     11    [Storable]
     12    public override string Prefix { get; set; }
    1513
    16         [Storable]
    17         public override string Suffix { get; set; }
     14    [Storable]
     15    public override string Suffix { get; set; }
    1816
    19         [StorableConstructor]
    20         private WhileLoop(bool deserializing) : base(deserializing) { }
    21         private WhileLoop(WhileLoop original, Cloner cloner)
    22             : base(original, cloner)
    23         {
    24             this.Prefix = "while(";
    25             this.Suffix = ")";
    26         }
     17    [StorableConstructor]
     18    private WhileLoop(bool deserializing) : base(deserializing) { }
     19    private WhileLoop(WhileLoop original, Cloner cloner)
     20      : base(original, cloner) {
    2721
    28         public WhileLoop()
    29             : base("WhileLoop", "A WhileLoop.")
    30         {
    31             this.Prefix = "while(";
    32             this.Suffix = ")";
    33         }
     22    }
    3423
    35         public override IDeepCloneable Clone(Cloner cloner)
    36         {
    37             return new WhileLoop(this, cloner);
    38         }
     24    public WhileLoop()
     25      : base("WhileLoop", "A WhileLoop.") {
     26      this.Prefix = "while(";
     27      this.Suffix = ")";
     28    }
    3929
    40         public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children)
    41         {
    42             string condition = "", ifTrue = "";
    43             foreach (ISymbolicExpressionTreeNode c in children)
    44             {
    45                 if (c.Symbol is LogicalExpression)
    46                     condition = ((CodeNode)c.Symbol).Interpret(c, c.Subtrees);
    47                 else if (c.Symbol is Block)
    48                     ifTrue = ((CodeNode)c.Symbol).Interpret(c, c.Subtrees);
    49                 else
    50                     throw new System.Exception("Unexpected Child node.");
    51             }
    52             return this.Prefix + " " + condition + " " + this.Suffix +
    53                 "\r\n" + ifTrue + "\r\n";
    54         }
     30    public override IDeepCloneable Clone(Cloner cloner) {
     31      return new WhileLoop(this, cloner);
    5532    }
     33
     34    public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
     35      string condition = "", ifTrue = "";
     36      foreach (ISymbolicExpressionTreeNode c in children) {
     37        if (c.Symbol is LogicalExpression)
     38          condition = ((CodeNode)c.Symbol).Interpret(c, c.Subtrees);
     39        else if (c.Symbol is Block)
     40          ifTrue = ((CodeNode)c.Symbol).Interpret(c, c.Subtrees);
     41        else
     42          throw new System.Exception("Unexpected Child node.");
     43      }
     44      return this.Prefix + " " + condition + " " + this.Suffix +
     45          "\r\n" + ifTrue + "\r\n";
     46    }
     47  }
    5648}
  • branches/Robocode/HeuristicLab.Problems.Robocode/Symbols/CodeNode.cs

    r9565 r9630  
    11using HeuristicLab.Common;
    2 using HeuristicLab.Core;
    32using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    43using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    54
    6 namespace HeuristicLab.Problems.Robocode
    7 {
    8     [StorableClass]
    9     public abstract class CodeNode : Symbol
    10     {
    11         public abstract string Prefix { get; set; }
    12         public abstract string Suffix { get; set; }
     5namespace HeuristicLab.Problems.Robocode {
     6  [StorableClass]
     7  public abstract class CodeNode : Symbol {
     8    public abstract string Prefix { get; set; }
     9    public abstract string Suffix { get; set; }
    1310
    14         [StorableConstructor]
    15         protected CodeNode(bool deserializing) : base(deserializing) { }
    16         protected CodeNode(CodeNode original, Cloner cloner)
    17             : base(original, cloner) { }
    18         protected CodeNode(string name, string description)
    19             : base(name, description)
    20         {
    21         }
     11    [StorableConstructor]
     12    protected CodeNode(bool deserializing) : base(deserializing) { }
     13    protected CodeNode(CodeNode original, Cloner cloner)
     14      : base(original, cloner) {
     15      this.Prefix = original.Prefix;
     16      this.Suffix = original.Suffix;
     17    }
     18    protected CodeNode(string name, string description)
     19      : base(name, description) {
     20    }
    2221
    23         public override IDeepCloneable Clone(Cloner cloner)
    24         {
    25             throw new System.NotImplementedException();
    26         }
     22    public override IDeepCloneable Clone(Cloner cloner) {
     23      throw new System.NotImplementedException();
     24    }
    2725
    28         public override int MaximumArity
    29         {
    30             get { throw new System.NotImplementedException(); }
    31         }
     26    public override int MaximumArity {
     27      get { throw new System.NotImplementedException(); }
     28    }
    3229
    33         public override int MinimumArity
    34         {
    35             get { throw new System.NotImplementedException(); }
    36         }
     30    public override int MinimumArity {
     31      get { throw new System.NotImplementedException(); }
     32    }
    3733
    38         public abstract string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children);
    39     }
     34    public abstract string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children);
     35  }
    4036}
  • branches/Robocode/HeuristicLab.Problems.Robocode/Symbols/Event Methods/Events/EmptyEvent.cs

    r9612 r9630  
    1919    private EmptyEvent(EmptyEvent original, Cloner cloner)
    2020      : base(original, cloner) {
    21       this.Prefix = "";
    22       this.Suffix = "";
    2321    }
    2422
  • branches/Robocode/HeuristicLab.Problems.Robocode/Symbols/Event Methods/Events/OnBulletHit.cs

    r9565 r9630  
    33using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    44
    5 namespace HeuristicLab.Problems.Robocode
    6 {
    7     [StorableClass]
    8     public class OnBulletHit : CodeNode
    9     {
    10         public override int MinimumArity { get { return 2; } }
    11         public override int MaximumArity { get { return 10; } }
     5namespace HeuristicLab.Problems.Robocode {
     6  [StorableClass]
     7  public class OnBulletHit : CodeNode {
     8    public override int MinimumArity { get { return 2; } }
     9    public override int MaximumArity { get { return 10; } }
    1210
    13         [Storable]
    14         public override string Prefix { get; set; }
     11    [Storable]
     12    public override string Prefix { get; set; }
    1513
    16         [Storable]
    17         public override string Suffix { get; set; }
     14    [Storable]
     15    public override string Suffix { get; set; }
    1816
    19         [StorableConstructor]
    20         private OnBulletHit(bool deserializing) : base(deserializing) { }
    21         private OnBulletHit(OnBulletHit original, Cloner cloner)
    22             : base(original, cloner)
    23         {
    24             this.Prefix = "\r\npublic void onBulletHit(BulletHitEvent e) {\r\n";
    25             this.Suffix = "\r\nexecute();\r\n}\r\n";
    26         }
     17    [StorableConstructor]
     18    private OnBulletHit(bool deserializing) : base(deserializing) { }
     19    private OnBulletHit(OnBulletHit original, Cloner cloner)
     20      : base(original, cloner) {
    2721
    28         public OnBulletHit()
    29             : base("OnBulletHit", "This method is called when one of your bullets hits another robot.")
    30         {
    31             this.Prefix = "\r\npublic void onBulletHit(BulletHitEvent e) {\r\n";
    32             this.Suffix = "\r\nexecute();\r\n}\r\n";
    33         }
     22    }
    3423
    35         public override IDeepCloneable Clone(Cloner cloner)
    36         {
    37             return new OnBulletHit(this, cloner);
    38         }
     24    public OnBulletHit()
     25      : base("OnBulletHit", "This method is called when one of your bullets hits another robot.") {
     26      this.Prefix = "\r\npublic void onBulletHit(BulletHitEvent e) {\r\n";
     27      this.Suffix = "\r\nexecute();\r\n}\r\n";
     28    }
    3929
    40         public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children)
    41         {
    42             string result = "";
    43             foreach (ISymbolicExpressionTreeNode c in children)
    44                 result += "\r\n" + ((CodeNode)c.Symbol).Interpret(c, c.Subtrees);
    45             return this.Prefix + "\r\n" + result + "\r\n" + this.Suffix;
    46         }
     30    public override IDeepCloneable Clone(Cloner cloner) {
     31      return new OnBulletHit(this, cloner);
    4732    }
     33
     34    public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
     35      string result = "";
     36      foreach (ISymbolicExpressionTreeNode c in children)
     37        result += "\r\n" + ((CodeNode)c.Symbol).Interpret(c, c.Subtrees);
     38      return this.Prefix + "\r\n" + result + "\r\n" + this.Suffix;
     39    }
     40  }
    4841}
  • branches/Robocode/HeuristicLab.Problems.Robocode/Symbols/Event Methods/Events/OnBulletMissed.cs

    r9565 r9630  
    33using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    44
    5 namespace HeuristicLab.Problems.Robocode
    6 {
    7     [StorableClass]
    8     public class OnBulletMissed : CodeNode
    9     {
    10         public override int MinimumArity { get { return 2; } }
    11         public override int MaximumArity { get { return 10; } }
     5namespace HeuristicLab.Problems.Robocode {
     6  [StorableClass]
     7  public class OnBulletMissed : CodeNode {
     8    public override int MinimumArity { get { return 2; } }
     9    public override int MaximumArity { get { return 10; } }
    1210
    13         [Storable]
    14         public override string Prefix { get; set; }
     11    [Storable]
     12    public override string Prefix { get; set; }
    1513
    16         [Storable]
    17         public override string Suffix { get; set; }
     14    [Storable]
     15    public override string Suffix { get; set; }
    1816
    19         [StorableConstructor]
    20         private OnBulletMissed(bool deserializing) : base(deserializing) { }
    21         private OnBulletMissed(OnBulletMissed original, Cloner cloner)
    22             : base(original, cloner)
    23         {
    24             this.Prefix = "\r\npublic void onBulletMissed(BulletMissedEvent e) {\r\n";
    25             this.Suffix = "\r\nexecute();\r\n}\r\n";
    26         }
     17    [StorableConstructor]
     18    private OnBulletMissed(bool deserializing) : base(deserializing) { }
     19    private OnBulletMissed(OnBulletMissed original, Cloner cloner)
     20      : base(original, cloner) {
    2721
    28         public OnBulletMissed()
    29             : base("OnBulletMissed", "This method is called when one of your bullets misses, i.e. hits a wall.")
    30         {
    31             this.Prefix = "\r\npublic void onBulletMissed(BulletMissedEvent e) {\r\n";
    32             this.Suffix = "\r\nexecute();\r\n}\r\n";
    33         }
     22    }
    3423
    35         public override IDeepCloneable Clone(Cloner cloner)
    36         {
    37             return new OnBulletMissed(this, cloner);
    38         }
     24    public OnBulletMissed()
     25      : base("OnBulletMissed", "This method is called when one of your bullets misses, i.e. hits a wall.") {
     26      this.Prefix = "\r\npublic void onBulletMissed(BulletMissedEvent e) {\r\n";
     27      this.Suffix = "\r\nexecute();\r\n}\r\n";
     28    }
    3929
    40         public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children)
    41         {
    42             string result = "";
    43             foreach (ISymbolicExpressionTreeNode c in children)
    44                 result += "\r\n" + ((CodeNode)c.Symbol).Interpret(c, c.Subtrees);
    45             return this.Prefix + "\r\n" + result + "\r\n" + this.Suffix;
    46         }
     30    public override IDeepCloneable Clone(Cloner cloner) {
     31      return new OnBulletMissed(this, cloner);
    4732    }
     33
     34    public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
     35      string result = "";
     36      foreach (ISymbolicExpressionTreeNode c in children)
     37        result += "\r\n" + ((CodeNode)c.Symbol).Interpret(c, c.Subtrees);
     38      return this.Prefix + "\r\n" + result + "\r\n" + this.Suffix;
     39    }
     40  }
    4841}
  • branches/Robocode/HeuristicLab.Problems.Robocode/Symbols/Event Methods/Events/OnHitByBullet.cs

    r9565 r9630  
    33using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    44
    5 namespace HeuristicLab.Problems.Robocode
    6 {
    7     [StorableClass]
    8     public class OnHitByBullet : CodeNode
    9     {
    10         public override int MinimumArity { get { return 2; } }
    11         public override int MaximumArity { get { return 10; } }
     5namespace HeuristicLab.Problems.Robocode {
     6  [StorableClass]
     7  public class OnHitByBullet : CodeNode {
     8    public override int MinimumArity { get { return 2; } }
     9    public override int MaximumArity { get { return 10; } }
    1210
    13         [Storable]
    14         public override string Prefix { get; set; }
     11    [Storable]
     12    public override string Prefix { get; set; }
    1513
    16         [Storable]
    17         public override string Suffix { get; set; }
     14    [Storable]
     15    public override string Suffix { get; set; }
    1816
    19         [StorableConstructor]
    20         private OnHitByBullet(bool deserializing) : base(deserializing) { }
    21         private OnHitByBullet(OnHitByBullet original, Cloner cloner)
    22             : base(original, cloner)
    23         {
    24             this.Prefix = "\r\npublic void onHitByBullet(HitByBulletEvent e) {\r\n";
    25             this.Suffix = "\r\nexecute();\r\n}\r\n";
    26         }
     17    [StorableConstructor]
     18    private OnHitByBullet(bool deserializing) : base(deserializing) { }
     19    private OnHitByBullet(OnHitByBullet original, Cloner cloner)
     20      : base(original, cloner) {
    2721
    28         public OnHitByBullet()
    29             : base("OnHitByBullet", "This method is called when your robot is hit by a bullet.")
    30         {
    31             this.Prefix = "\r\npublic void onHitByBullet(HitByBulletEvent e) {\r\n";
    32             this.Suffix = "\r\nexecute();\r\n}\r\n";
    33         }
     22    }
    3423
    35         public override IDeepCloneable Clone(Cloner cloner)
    36         {
    37             return new OnHitByBullet(this, cloner);
    38         }
     24    public OnHitByBullet()
     25      : base("OnHitByBullet", "This method is called when your robot is hit by a bullet.") {
     26      this.Prefix = "\r\npublic void onHitByBullet(HitByBulletEvent e) {\r\n";
     27      this.Suffix = "\r\nexecute();\r\n}\r\n";
     28    }
    3929
    40         public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children)
    41         {
    42             string result = "";
    43             foreach (ISymbolicExpressionTreeNode c in children)
    44                 result += "\r\n" + ((CodeNode)c.Symbol).Interpret(c, c.Subtrees);
    45             return this.Prefix + "\r\n" + result + "\r\n" + this.Suffix;
    46         }
     30    public override IDeepCloneable Clone(Cloner cloner) {
     31      return new OnHitByBullet(this, cloner);
    4732    }
     33
     34    public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
     35      string result = "";
     36      foreach (ISymbolicExpressionTreeNode c in children)
     37        result += "\r\n" + ((CodeNode)c.Symbol).Interpret(c, c.Subtrees);
     38      return this.Prefix + "\r\n" + result + "\r\n" + this.Suffix;
     39    }
     40  }
    4841}
  • branches/Robocode/HeuristicLab.Problems.Robocode/Symbols/Event Methods/Events/OnHitRobot.cs

    r9565 r9630  
    33using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    44
    5 namespace HeuristicLab.Problems.Robocode
    6 {
    7     [StorableClass]
    8     public class OnHitRobot : CodeNode
    9     {
    10         public override int MinimumArity { get { return 2; } }
    11         public override int MaximumArity { get { return 10; } }
     5namespace HeuristicLab.Problems.Robocode {
     6  [StorableClass]
     7  public class OnHitRobot : CodeNode {
     8    public override int MinimumArity { get { return 2; } }
     9    public override int MaximumArity { get { return 10; } }
    1210
    13         [Storable]
    14         public override string Prefix { get; set; }
     11    [Storable]
     12    public override string Prefix { get; set; }
    1513
    16         [Storable]
    17         public override string Suffix { get; set; }
     14    [Storable]
     15    public override string Suffix { get; set; }
    1816
    19         [StorableConstructor]
    20         private OnHitRobot(bool deserializing) : base(deserializing) { }
    21         private OnHitRobot(OnHitRobot original, Cloner cloner)
    22             : base(original, cloner)
    23         {
    24             this.Prefix = "\r\npublic void onHitRobot(HitRobotEvent e) {\r\n";
    25             this.Suffix = "\r\nexecute();\r\n}\r\n";
    26         }
     17    [StorableConstructor]
     18    private OnHitRobot(bool deserializing) : base(deserializing) { }
     19    private OnHitRobot(OnHitRobot original, Cloner cloner)
     20      : base(original, cloner) {
     21    }
    2722
    28         public OnHitRobot()
    29             : base("OnHitRobot", "This method is called when your robot collides with another robot.")
    30         {
    31             this.Prefix = "\r\npublic void onHitRobot(HitRobotEvent e) {\r\n";
    32             this.Suffix = "\r\nexecute();\r\n}\r\n";
    33         }
     23    public OnHitRobot()
     24      : base("OnHitRobot", "This method is called when your robot collides with another robot.") {
     25      this.Prefix = "\r\npublic void onHitRobot(HitRobotEvent e) {\r\n";
     26      this.Suffix = "\r\nexecute();\r\n}\r\n";
     27    }
    3428
    35         public override IDeepCloneable Clone(Cloner cloner)
    36         {
    37             return new OnHitRobot(this, cloner);
    38         }
     29    public override IDeepCloneable Clone(Cloner cloner) {
     30      return new OnHitRobot(this, cloner);
     31    }
    3932
    40         public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children)
    41         {
    42             string result = "";
    43             foreach (ISymbolicExpressionTreeNode c in children)
    44                 result += "\r\n" + ((CodeNode)c.Symbol).Interpret(c, c.Subtrees);
    45             return this.Prefix + "\r\n" + result + "\r\n" + this.Suffix;
    46         }
     33    public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
     34      string result = "";
     35      foreach (ISymbolicExpressionTreeNode c in children)
     36        result += "\r\n" + ((CodeNode)c.Symbol).Interpret(c, c.Subtrees);
     37      return this.Prefix + "\r\n" + result + "\r\n" + this.Suffix;
    4738    }
     39  }
    4840}
  • branches/Robocode/HeuristicLab.Problems.Robocode/Symbols/Event Methods/Events/OnHitWall.cs

    r9565 r9630  
    33using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    44
    5 namespace HeuristicLab.Problems.Robocode
    6 {
    7     [StorableClass]
    8     public class OnHitWall : CodeNode
    9     {
    10         public override int MinimumArity { get { return 2; } }
    11         public override int MaximumArity { get { return 10; } }
     5namespace HeuristicLab.Problems.Robocode {
     6  [StorableClass]
     7  public class OnHitWall : CodeNode {
     8    public override int MinimumArity { get { return 2; } }
     9    public override int MaximumArity { get { return 10; } }
    1210
    13         [Storable]
    14         public override string Prefix { get; set; }
     11    [Storable]
     12    public override string Prefix { get; set; }
    1513
    16         [Storable]
    17         public override string Suffix { get; set; }
     14    [Storable]
     15    public override string Suffix { get; set; }
    1816
    19         [StorableConstructor]
    20         private OnHitWall(bool deserializing) : base(deserializing) { }
    21         private OnHitWall(OnHitWall original, Cloner cloner)
    22             : base(original, cloner)
    23         {
    24             this.Prefix = "\r\npublic void onHitWall(HitWallEvent e) {\r\n";
    25             this.Suffix = "\r\nexecute();\r\n}\r\n";
    26         }
     17    [StorableConstructor]
     18    private OnHitWall(bool deserializing) : base(deserializing) { }
     19    private OnHitWall(OnHitWall original, Cloner cloner)
     20      : base(original, cloner) {
    2721
    28         public OnHitWall()
    29             : base("OnHitWall", "This method is called when your robot collides with a wall.")
    30         {
    31             this.Prefix = "\r\npublic void onHitWall(HitWallEvent e) {\r\n";
    32             this.Suffix = "\r\nexecute();\r\n}\r\n";
    33         }
     22    }
    3423
    35         public override IDeepCloneable Clone(Cloner cloner)
    36         {
    37             return new OnHitWall(this, cloner);
    38         }
     24    public OnHitWall()
     25      : base("OnHitWall", "This method is called when your robot collides with a wall.") {
     26      this.Prefix = "\r\npublic void onHitWall(HitWallEvent e) {\r\n";
     27      this.Suffix = "\r\nexecute();\r\n}\r\n";
     28    }
    3929
    40         public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children)
    41         {
    42             string result = "";
    43             foreach (ISymbolicExpressionTreeNode c in children)
    44                 result += "\r\n" + ((CodeNode)c.Symbol).Interpret(c, c.Subtrees);
    45             return this.Prefix + "\r\n" + result + "\r\n" + this.Suffix;
    46         }
     30    public override IDeepCloneable Clone(Cloner cloner) {
     31      return new OnHitWall(this, cloner);
    4732    }
     33
     34    public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
     35      string result = "";
     36      foreach (ISymbolicExpressionTreeNode c in children)
     37        result += "\r\n" + ((CodeNode)c.Symbol).Interpret(c, c.Subtrees);
     38      return this.Prefix + "\r\n" + result + "\r\n" + this.Suffix;
     39    }
     40  }
    4841}
  • branches/Robocode/HeuristicLab.Problems.Robocode/Symbols/Event Methods/Events/OnScannedRobot.cs

    r9565 r9630  
    33using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    44
    5 namespace HeuristicLab.Problems.Robocode
    6 {
    7     [StorableClass]
    8     public class OnScannedRobot : CodeNode
    9     {
    10         public override int MinimumArity { get { return 2; } }
    11         public override int MaximumArity { get { return 10; } }
     5namespace HeuristicLab.Problems.Robocode {
     6  [StorableClass]
     7  public class OnScannedRobot : CodeNode {
     8    public override int MinimumArity { get { return 2; } }
     9    public override int MaximumArity { get { return 10; } }
    1210
    13         [Storable]
    14         public override string Prefix { get; set; }
     11    [Storable]
     12    public override string Prefix { get; set; }
    1513
    16         [Storable]
    17         public override string Suffix { get; set; }
     14    [Storable]
     15    public override string Suffix { get; set; }
    1816
    19         [StorableConstructor]
    20         private OnScannedRobot(bool deserializing) : base(deserializing) { }
    21         private OnScannedRobot(OnScannedRobot original, Cloner cloner)
    22             : base(original, cloner)
    23         {
    24             this.Prefix = "\r\npublic void onScannedRobot(ScannedRobotEvent e) {" +
    25                           "\r\ndouble absoluteBearing = getHeading() + e.getBearing();" +
    26                           "\r\ndouble bearingFromGun = normalRelativeAngleDegrees(absoluteBearing - getGunHeading());" +
    27                           "\r\nsetTurnGunRight(bearingFromGun);\r\n";
    28             this.Suffix = "\r\nexecute();\r\n}\r\n";
    29         }
     17    [StorableConstructor]
     18    private OnScannedRobot(bool deserializing) : base(deserializing) { }
     19    private OnScannedRobot(OnScannedRobot original, Cloner cloner)
     20      : base(original, cloner) {
    3021
    31         public OnScannedRobot()
    32             : base("OnScannedRobot", "This method is called when your robot sees another robot, i.e. when the robot's radar scan \"hits\" another robot.")
    33         {
    34             this.Prefix = "\r\npublic void onScannedRobot(ScannedRobotEvent e) {" +
    35                           "\r\ndouble absoluteBearing = getHeading() + e.getBearing();" +
    36                           "\r\ndouble bearingFromGun = normalRelativeAngleDegrees(absoluteBearing - getGunHeading());" +
    37                           "\r\nsetTurnGunRight(bearingFromGun);\r\n";
    38             this.Suffix = "\r\nexecute();\r\n}\r\n";
    39         }
     22    }
    4023
    41         public override IDeepCloneable Clone(Cloner cloner)
    42         {
    43             return new OnScannedRobot(this, cloner);
    44         }
     24    public OnScannedRobot()
     25      : base("OnScannedRobot", "This method is called when your robot sees another robot, i.e. when the robot's radar scan \"hits\" another robot.") {
     26      this.Prefix = "\r\npublic void onScannedRobot(ScannedRobotEvent e) {" +
     27                    "\r\ndouble absoluteBearing = getHeading() + e.getBearing();" +
     28                    "\r\ndouble bearingFromGun = normalRelativeAngleDegrees(absoluteBearing - getGunHeading());" +
     29                    "\r\nsetTurnGunRight(bearingFromGun);\r\n";
     30      this.Suffix = "\r\nexecute();\r\n}\r\n";
     31    }
    4532
    46         public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children)
    47         {
    48             string result = "";
    49             foreach (ISymbolicExpressionTreeNode c in children)
    50                 result += "\r\n" + ((CodeNode)c.Symbol).Interpret(c, c.Subtrees);
    51             return this.Prefix + "\r\n" + result + "\r\n" + this.Suffix;
    52         }
     33    public override IDeepCloneable Clone(Cloner cloner) {
     34      return new OnScannedRobot(this, cloner);
    5335    }
     36
     37    public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
     38      string result = "";
     39      foreach (ISymbolicExpressionTreeNode c in children)
     40        result += "\r\n" + ((CodeNode)c.Symbol).Interpret(c, c.Subtrees);
     41      return this.Prefix + "\r\n" + result + "\r\n" + this.Suffix;
     42    }
     43  }
    5444}
  • branches/Robocode/HeuristicLab.Problems.Robocode/Symbols/Event Methods/Run.cs

    r9565 r9630  
    33using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    44
    5 namespace HeuristicLab.Problems.Robocode
    6 {
    7     [StorableClass]
    8     public class Run : CodeNode
    9     {
    10         public override int MinimumArity { get { return 2; } }
    11         public override int MaximumArity { get { return 10; } }
    12        
    13         [Storable]
    14         public override string Prefix { get; set; }
    15        
    16         [Storable]
    17         public override string Suffix { get; set; }
     5namespace HeuristicLab.Problems.Robocode {
     6  [StorableClass]
     7  public class Run : CodeNode {
     8    public override int MinimumArity { get { return 2; } }
     9    public override int MaximumArity { get { return 10; } }
    1810
    19         [StorableConstructor]
    20         private Run(bool deserializing) : base(deserializing) { }
    21         private Run(Run original, Cloner cloner)
    22             : base(original, cloner)
    23         {
    24             this.Prefix = "\r\npublic void run() {\r\n\tsetAdjustGunForRobotTurn(true);\r\n\tturnRadarRightRadians(Double.POSITIVE_INFINITY);";
    25             this.Suffix = "\r\nexecute();\r\n}\r\n";
    26         }
     11    [Storable]
     12    public override string Prefix { get; set; }
    2713
    28         public Run()
    29             : base("Run", "The main method in every robot.")
    30         {
    31             this.Prefix = "\r\npublic void run() {\r\n\tsetAdjustGunForRobotTurn(true);\r\n\tturnRadarRightRadians(Double.POSITIVE_INFINITY);";
    32             this.Suffix = "\r\nexecute();\r\n}\r\n";
    33         }
     14    [Storable]
     15    public override string Suffix { get; set; }
    3416
    35         public override IDeepCloneable Clone(Cloner cloner)
    36         {
    37             return new Run(this, cloner);
    38         }
     17    [StorableConstructor]
     18    private Run(bool deserializing) : base(deserializing) { }
     19    private Run(Run original, Cloner cloner)
     20      : base(original, cloner) {
     21    }
    3922
    40         public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children)
    41         {
    42             string result = "";
    43             foreach (ISymbolicExpressionTreeNode c in children)
    44                 result += "\r\n" + ((CodeNode)c.Symbol).Interpret(c, c.Subtrees);
    45             return this.Prefix + "\r\n" + result + "\r\n" + this.Suffix;
    46         }
     23    public Run()
     24      : base("Run", "The main method in every robot.") {
     25      this.Prefix = "\r\npublic void run() {\r\n\tsetAdjustGunForRobotTurn(true);\r\n\tturnRadarRightRadians(Double.POSITIVE_INFINITY);";
     26      this.Suffix = "\r\nexecute();\r\n}\r\n";
    4727    }
     28
     29    public override IDeepCloneable Clone(Cloner cloner) {
     30      return new Run(this, cloner);
     31    }
     32
     33    public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
     34      string result = "";
     35      foreach (ISymbolicExpressionTreeNode c in children)
     36        result += "\r\n" + ((CodeNode)c.Symbol).Interpret(c, c.Subtrees);
     37      return this.Prefix + "\r\n" + result + "\r\n" + this.Suffix;
     38    }
     39  }
    4840}
  • branches/Robocode/HeuristicLab.Problems.Robocode/Symbols/Logical Expressions/Logical Comparators/Conjunction.cs

    r9565 r9630  
    33using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    44
    5 namespace HeuristicLab.Problems.Robocode
    6 {
    7     [StorableClass]
    8     public class Conjunction : CodeNode
    9     {
    10         public override int MinimumArity { get { return 0; } }
    11         public override int MaximumArity { get { return 0; } }
     5namespace HeuristicLab.Problems.Robocode {
     6  [StorableClass]
     7  public class Conjunction : CodeNode {
     8    public override int MinimumArity { get { return 0; } }
     9    public override int MaximumArity { get { return 0; } }
    1210
    13         [Storable]
    14         public override string Prefix { get; set; }
     11    [Storable]
     12    public override string Prefix { get; set; }
    1513
    16         [Storable]
    17         public override string Suffix { get; set; }
     14    [Storable]
     15    public override string Suffix { get; set; }
    1816
    19         [StorableConstructor]
    20         private Conjunction(bool deserializing) : base(deserializing) { }
    21         private Conjunction(Conjunction original, Cloner cloner)
    22             : base(original, cloner)
    23         {
    24             this.Prefix = "&&";
    25             this.Suffix = "";
    26         }
     17    [StorableConstructor]
     18    private Conjunction(bool deserializing) : base(deserializing) { }
     19    private Conjunction(Conjunction original, Cloner cloner)
     20      : base(original, cloner) {
     21    }
    2722
    28         public Conjunction()
    29             : base("Conjunction", "Conjunction comparator.")
    30         {
    31             this.Prefix = "&&";
    32             this.Suffix = "";
    33         }
     23    public Conjunction()
     24      : base("Conjunction", "Conjunction comparator.") {
     25      this.Prefix = "&&";
     26      this.Suffix = "";
     27    }
    3428
    35         public override IDeepCloneable Clone(Cloner cloner)
    36         {
    37             return new Conjunction(this, cloner);
    38         }
     29    public override IDeepCloneable Clone(Cloner cloner) {
     30      return new Conjunction(this, cloner);
     31    }
    3932
    40         public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children)
    41         {
    42             return this.Prefix + " " + this.Suffix;
    43         }
     33    public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
     34      return this.Prefix + " " + this.Suffix;
    4435    }
     36  }
    4537}
  • branches/Robocode/HeuristicLab.Problems.Robocode/Symbols/Logical Expressions/Logical Comparators/Disjunction.cs

    r9565 r9630  
    33using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    44
    5 namespace HeuristicLab.Problems.Robocode
    6 {
    7     [StorableClass]
    8     public class Disjunction : CodeNode
    9     {
    10         public override int MinimumArity { get { return 0; } }
    11         public override int MaximumArity { get { return 0; } }
     5namespace HeuristicLab.Problems.Robocode {
     6  [StorableClass]
     7  public class Disjunction : CodeNode {
     8    public override int MinimumArity { get { return 0; } }
     9    public override int MaximumArity { get { return 0; } }
    1210
    13         [Storable]
    14         public override string Prefix { get; set; }
     11    [Storable]
     12    public override string Prefix { get; set; }
    1513
    16         [Storable]
    17         public override string Suffix { get; set; }
     14    [Storable]
     15    public override string Suffix { get; set; }
    1816
    19         [StorableConstructor]
    20         private Disjunction(bool deserializing) : base(deserializing) { }
    21         private Disjunction(Disjunction original, Cloner cloner)
    22             : base(original, cloner)
    23         {
    24             this.Prefix = "||";
    25             this.Suffix = "";
    26         }
     17    [StorableConstructor]
     18    private Disjunction(bool deserializing) : base(deserializing) { }
     19    private Disjunction(Disjunction original, Cloner cloner)
     20      : base(original, cloner) {
     21    }
    2722
    28         public Disjunction()
    29             : base("Disjunction", "Disjunction comparator.")
    30         {
    31             this.Prefix = "||";
    32             this.Suffix = "";
    33         }
     23    public Disjunction()
     24      : base("Disjunction", "Disjunction comparator.") {
     25      this.Prefix = "||";
     26      this.Suffix = "";
     27    }
    3428
    35         public override IDeepCloneable Clone(Cloner cloner)
    36         {
    37             return new Disjunction(this, cloner);
    38         }
     29    public override IDeepCloneable Clone(Cloner cloner) {
     30      return new Disjunction(this, cloner);
     31    }
    3932
    40         public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children)
    41         {
    42             return this.Prefix + " " + this.Suffix;
    43         }
     33    public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
     34      return this.Prefix + " " + this.Suffix;
    4435    }
     36  }
    4537}
  • branches/Robocode/HeuristicLab.Problems.Robocode/Symbols/Logical Expressions/Logical Comparators/Equal.cs

    r9565 r9630  
    33using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    44
    5 namespace HeuristicLab.Problems.Robocode
    6 {
    7     [StorableClass]
    8     public class Equal : CodeNode
    9     {
    10         public override int MinimumArity { get { return 0; } }
    11         public override int MaximumArity { get { return 0; } }
     5namespace HeuristicLab.Problems.Robocode {
     6  [StorableClass]
     7  public class Equal : CodeNode {
     8    public override int MinimumArity { get { return 0; } }
     9    public override int MaximumArity { get { return 0; } }
    1210
    13         [Storable]
    14         public override string Prefix { get; set; }
     11    [Storable]
     12    public override string Prefix { get; set; }
    1513
    16         [Storable]
    17         public override string Suffix { get; set; }
     14    [Storable]
     15    public override string Suffix { get; set; }
    1816
    19         [StorableConstructor]
    20         private Equal(bool deserializing) : base(deserializing) { }
    21         private Equal(Equal original, Cloner cloner)
    22             : base(original, cloner)
    23         {
    24             this.Prefix = "==";
    25             this.Suffix = "";
    26         }
     17    [StorableConstructor]
     18    private Equal(bool deserializing) : base(deserializing) { }
     19    private Equal(Equal original, Cloner cloner)
     20      : base(original, cloner) {
     21    }
    2722
    28         public Equal()
    29             : base("Equal", "Equal comparator.")
    30         {
    31             this.Prefix = "==";
    32             this.Suffix = "";
    33         }
     23    public Equal()
     24      : base("Equal", "Equal comparator.") {
     25      this.Prefix = "==";
     26      this.Suffix = "";
     27    }
    3428
    35         public override IDeepCloneable Clone(Cloner cloner)
    36         {
    37             return new Equal(this, cloner);
    38         }
     29    public override IDeepCloneable Clone(Cloner cloner) {
     30      return new Equal(this, cloner);
     31    }
    3932
    40         public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children)
    41         {
    42             return this.Prefix + " " + this.Suffix;
    43         }
     33    public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
     34      return this.Prefix + " " + this.Suffix;
    4435    }
     36  }
    4537}
  • branches/Robocode/HeuristicLab.Problems.Robocode/Symbols/Logical Expressions/Logical Comparators/GreaterThan.cs

    r9565 r9630  
    33using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    44
    5 namespace HeuristicLab.Problems.Robocode
    6 {
    7     [StorableClass]
    8     public class GreaterThan : CodeNode
    9     {
    10         public override int MinimumArity { get { return 0; } }
    11         public override int MaximumArity { get { return 0; } }
     5namespace HeuristicLab.Problems.Robocode {
     6  [StorableClass]
     7  public class GreaterThan : CodeNode {
     8    public override int MinimumArity { get { return 0; } }
     9    public override int MaximumArity { get { return 0; } }
    1210
    13         [Storable]
    14         public override string Prefix { get; set; }
     11    [Storable]
     12    public override string Prefix { get; set; }
    1513
    16         [Storable]
    17         public override string Suffix { get; set; }
     14    [Storable]
     15    public override string Suffix { get; set; }
    1816
    19         [StorableConstructor]
    20         private GreaterThan(bool deserializing) : base(deserializing) { }
    21         private GreaterThan(GreaterThan original, Cloner cloner)
    22             : base(original, cloner)
    23         {
    24             this.Prefix = ">";
    25             this.Suffix = "";
    26         }
     17    [StorableConstructor]
     18    private GreaterThan(bool deserializing) : base(deserializing) { }
     19    private GreaterThan(GreaterThan original, Cloner cloner)
     20      : base(original, cloner) {
     21    }
    2722
    28         public GreaterThan()
    29             : base("GreaterThan", "GreaterThan comparator.")
    30         {
    31             this.Prefix = ">";
    32             this.Suffix = "";
    33         }
     23    public GreaterThan()
     24      : base("GreaterThan", "GreaterThan comparator.") {
     25      this.Prefix = ">";
     26      this.Suffix = "";
     27    }
    3428
    35         public override IDeepCloneable Clone(Cloner cloner)
    36         {
    37             return new GreaterThan(this, cloner);
    38         }
     29    public override IDeepCloneable Clone(Cloner cloner) {
     30      return new GreaterThan(this, cloner);
     31    }
    3932
    40         public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children)
    41         {
    42             return this.Prefix + " " + this.Suffix;
    43         }
     33    public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
     34      return this.Prefix + " " + this.Suffix;
    4435    }
     36  }
    4537}
  • branches/Robocode/HeuristicLab.Problems.Robocode/Symbols/Logical Expressions/Logical Comparators/GreaterThanOrEqual.cs

    r9565 r9630  
    33using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    44
    5 namespace HeuristicLab.Problems.Robocode
    6 {
    7     [StorableClass]
    8     public class GreaterThanOrEqual : CodeNode
    9     {
    10         public override int MinimumArity { get { return 0; } }
    11         public override int MaximumArity { get { return 0; } }
     5namespace HeuristicLab.Problems.Robocode {
     6  [StorableClass]
     7  public class GreaterThanOrEqual : CodeNode {
     8    public override int MinimumArity { get { return 0; } }
     9    public override int MaximumArity { get { return 0; } }
    1210
    13         [Storable]
    14         public override string Prefix { get; set; }
     11    [Storable]
     12    public override string Prefix { get; set; }
    1513
    16         [Storable]
    17         public override string Suffix { get; set; }
     14    [Storable]
     15    public override string Suffix { get; set; }
    1816
    19         [StorableConstructor]
    20         private GreaterThanOrEqual(bool deserializing) : base(deserializing) { }
    21         private GreaterThanOrEqual(GreaterThanOrEqual original, Cloner cloner)
    22             : base(original, cloner)
    23         {
    24             this.Prefix = ">=";
    25             this.Suffix = "";
    26         }
     17    [StorableConstructor]
     18    private GreaterThanOrEqual(bool deserializing) : base(deserializing) { }
     19    private GreaterThanOrEqual(GreaterThanOrEqual original, Cloner cloner)
     20      : base(original, cloner) {
     21    }
    2722
    28         public GreaterThanOrEqual()
    29             : base("GreaterThanOrEqual", "GreaterThanOrEqual comparator.")
    30         {
    31             this.Prefix = ">=";
    32             this.Suffix = "";
    33         }
     23    public GreaterThanOrEqual()
     24      : base("GreaterThanOrEqual", "GreaterThanOrEqual comparator.") {
     25      this.Prefix = ">=";
     26      this.Suffix = "";
     27    }
    3428
    35         public override IDeepCloneable Clone(Cloner cloner)
    36         {
    37             return new GreaterThanOrEqual(this, cloner);
    38         }
     29    public override IDeepCloneable Clone(Cloner cloner) {
     30      return new GreaterThanOrEqual(this, cloner);
     31    }
    3932
    40         public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children)
    41         {
    42             return this.Prefix + " " + this.Suffix;
    43         }
     33    public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
     34      return this.Prefix + " " + this.Suffix;
    4435    }
     36  }
    4537}
  • branches/Robocode/HeuristicLab.Problems.Robocode/Symbols/Logical Expressions/Logical Comparators/LessThan.cs

    r9565 r9630  
    33using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    44
    5 namespace HeuristicLab.Problems.Robocode
    6 {
    7     [StorableClass]
    8     public class LessThan : CodeNode
    9     {
    10         public override int MinimumArity { get { return 0; } }
    11         public override int MaximumArity { get { return 0; } }
     5namespace HeuristicLab.Problems.Robocode {
     6  [StorableClass]
     7  public class LessThan : CodeNode {
     8    public override int MinimumArity { get { return 0; } }
     9    public override int MaximumArity { get { return 0; } }
    1210
    13         [Storable]
    14         public override string Prefix { get; set; }
     11    [Storable]
     12    public override string Prefix { get; set; }
    1513
    16         [Storable]
    17         public override string Suffix { get; set; }
     14    [Storable]
     15    public override string Suffix { get; set; }
    1816
    19         [StorableConstructor]
    20         private LessThan(bool deserializing) : base(deserializing) { }
    21         private LessThan(LessThan original, Cloner cloner)
    22             : base(original, cloner)
    23         {
    24             this.Prefix = "<";
    25             this.Suffix = "";
    26         }
     17    [StorableConstructor]
     18    private LessThan(bool deserializing) : base(deserializing) { }
     19    private LessThan(LessThan original, Cloner cloner)
     20      : base(original, cloner) {
    2721
    28         public LessThan()
    29             : base("LessThan", "LessThan comparator.")
    30         {
    31             this.Prefix = "<";
    32             this.Suffix = "";
    33         }
     22    }
    3423
    35         public override IDeepCloneable Clone(Cloner cloner)
    36         {
    37             return new LessThan(this, cloner);
    38         }
     24    public LessThan()
     25      : base("LessThan", "LessThan comparator.") {
     26      this.Prefix = "<";
     27      this.Suffix = "";
     28    }
    3929
    40         public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children)
    41         {
    42             return this.Prefix + " " + this.Suffix;
    43         }
     30    public override IDeepCloneable Clone(Cloner cloner) {
     31      return new LessThan(this, cloner);
    4432    }
     33
     34    public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
     35      return this.Prefix + " " + this.Suffix;
     36    }
     37  }
    4538}
  • branches/Robocode/HeuristicLab.Problems.Robocode/Symbols/Logical Expressions/Logical Comparators/LessThanOrEqual.cs

    r9565 r9630  
    33using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    44
    5 namespace HeuristicLab.Problems.Robocode
    6 {
    7     [StorableClass]
    8     public class LessThanOrEqual : CodeNode
    9     {
    10         public override int MinimumArity { get { return 0; } }
    11         public override int MaximumArity { get { return 0; } }
     5namespace HeuristicLab.Problems.Robocode {
     6  [StorableClass]
     7  public class LessThanOrEqual : CodeNode {
     8    public override int MinimumArity { get { return 0; } }
     9    public override int MaximumArity { get { return 0; } }
    1210
    13         [Storable]
    14         public override string Prefix { get; set; }
     11    [Storable]
     12    public override string Prefix { get; set; }
    1513
    16         [Storable]
    17         public override string Suffix { get; set; }
     14    [Storable]
     15    public override string Suffix { get; set; }
    1816
    19         [StorableConstructor]
    20         private LessThanOrEqual(bool deserializing) : base(deserializing) { }
    21         private LessThanOrEqual(LessThanOrEqual original, Cloner cloner)
    22             : base(original, cloner)
    23         {
    24             this.Prefix = "<=";
    25             this.Suffix = "";
    26         }
     17    [StorableConstructor]
     18    private LessThanOrEqual(bool deserializing) : base(deserializing) { }
     19    private LessThanOrEqual(LessThanOrEqual original, Cloner cloner)
     20      : base(original, cloner) {
     21    }
    2722
    28         public LessThanOrEqual()
    29             : base("LessThanOrEqual", "LessThanOrEqual comparator.")
    30         {
    31             this.Prefix = "<=";
    32             this.Suffix = "";
    33         }
     23    public LessThanOrEqual()
     24      : base("LessThanOrEqual", "LessThanOrEqual comparator.") {
     25      this.Prefix = "<=";
     26      this.Suffix = "";
     27    }
    3428
    35         public override IDeepCloneable Clone(Cloner cloner)
    36         {
    37             return new LessThanOrEqual(this, cloner);
    38         }
     29    public override IDeepCloneable Clone(Cloner cloner) {
     30      return new LessThanOrEqual(this, cloner);
     31    }
    3932
    40         public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children)
    41         {
    42             return this.Prefix + " " + this.Suffix;
    43         }
     33    public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
     34      return this.Prefix + " " + this.Suffix;
    4435    }
     36  }
    4537}
  • branches/Robocode/HeuristicLab.Problems.Robocode/Symbols/Logical Expressions/LogicalComparison.cs

    r9565 r9630  
    33using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    44
    5 namespace HeuristicLab.Problems.Robocode
    6 {
    7     [StorableClass]
    8     public class LogicalComparison : CodeNode
    9     {
    10         public override int MinimumArity { get { return 3; } }
    11         public override int MaximumArity { get { return 3; } }
     5namespace HeuristicLab.Problems.Robocode {
     6  [StorableClass]
     7  public class LogicalComparison : CodeNode {
     8    public override int MinimumArity { get { return 3; } }
     9    public override int MaximumArity { get { return 3; } }
    1210
    13         [Storable]
    14         public override string Prefix { get; set; }
     11    [Storable]
     12    public override string Prefix { get; set; }
    1513
    16         [Storable]
    17         public override string Suffix { get; set; }
     14    [Storable]
     15    public override string Suffix { get; set; }
    1816
    19         [StorableConstructor]
    20         private LogicalComparison(bool deserializing) : base(deserializing) { }
    21         private LogicalComparison(LogicalComparison original, Cloner cloner)
    22             : base(original, cloner)
    23         {
    24             this.Prefix = "(";
    25             this.Suffix = ")";
     17    [StorableConstructor]
     18    private LogicalComparison(bool deserializing) : base(deserializing) { }
     19    private LogicalComparison(LogicalComparison original, Cloner cloner)
     20      : base(original, cloner) {
     21    }
     22
     23    public LogicalComparison()
     24      : base("LogicalComparison", "A LogicalComparison.") {
     25      this.Prefix = "(";
     26      this.Suffix = ")";
     27    }
     28
     29    public override IDeepCloneable Clone(Cloner cloner) {
     30      return new LogicalComparison(this, cloner);
     31    }
     32
     33    public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
     34      ISymbolicExpressionTreeNode condition = null, lhs = null, rhs = null;
     35      var enumerator = children.GetEnumerator();
     36      int childCount = 0;
     37      while (enumerator.MoveNext()) {
     38        childCount++;
     39        switch (childCount) {
     40          case 1: condition = enumerator.Current; break;
     41          case 2: lhs = enumerator.Current; break;
     42          case 3: rhs = enumerator.Current; break;
     43          default: throw new System.Exception("Unexpected number of children. Expected 3 children.");
    2644        }
     45      }
     46      if (childCount < 3) throw new System.Exception("Unexpected number of children. Expected 3 children.");
    2747
    28         public LogicalComparison()
    29             : base("LogicalComparison", "A LogicalComparison.")
    30         {
    31             this.Prefix = "(";
    32             this.Suffix = ")";
    33         }
     48      if (!(condition.Symbol is Conjunction || condition.Symbol is Disjunction))
     49        throw new System.Exception("Unexpected first child for LogicalComparison of type: " +
     50            condition.GetType().ToString() + ". Expected " + typeof(Conjunction).ToString() +
     51            " or " + typeof(Disjunction).ToString() + ".");
    3452
    35         public override IDeepCloneable Clone(Cloner cloner)
    36         {
    37             return new LogicalComparison(this, cloner);
    38         }
     53      // TODO Check children 2 & 3 for correct types
    3954
    40         public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children)
    41         {
    42             ISymbolicExpressionTreeNode condition = null, lhs = null, rhs = null;
    43             var enumerator = children.GetEnumerator();
    44             int childCount = 0;
    45             while (enumerator.MoveNext())
    46             {
    47                 childCount++;
    48                 switch (childCount)
    49                 {
    50                     case 1: condition = enumerator.Current; break;
    51                     case 2: lhs = enumerator.Current; break;
    52                     case 3: rhs = enumerator.Current; break;
    53                     default: throw new System.Exception("Unexpected number of children. Expected 3 children.");
    54                 }
    55             }
    56             if (childCount < 3) throw new System.Exception("Unexpected number of children. Expected 3 children.");
    57 
    58             if (!(condition.Symbol is Conjunction || condition.Symbol is Disjunction))
    59                 throw new System.Exception("Unexpected first child for LogicalComparison of type: " +
    60                     condition.GetType().ToString() + ". Expected " + typeof(Conjunction).ToString() +
    61                     " or " + typeof(Disjunction).ToString() + ".");
    62 
    63             // TODO Check children 2 & 3 for correct types
    64 
    65             string[] result = new string[]
     55      string[] result = new string[]
    6656            {
    6757                ((CodeNode)condition.Symbol).Interpret(condition, condition.Subtrees),
     
    7060            };
    7161
    72             return this.Prefix + " " + result[1] + " " + result[0] + " " + result[2] + " " + this.Suffix;
    73         }
     62      return this.Prefix + " " + result[1] + " " + result[0] + " " + result[2] + " " + this.Suffix;
    7463    }
     64  }
    7565}
  • branches/Robocode/HeuristicLab.Problems.Robocode/Symbols/Logical Expressions/LogicalExpression.cs

    r9565 r9630  
    33using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    44
    5 namespace HeuristicLab.Problems.Robocode
    6 {
    7     [StorableClass]
    8     public class LogicalExpression : CodeNode
    9     {
    10         public override int MinimumArity { get { return 1; } }
    11         public override int MaximumArity { get { return 1; } }
     5namespace HeuristicLab.Problems.Robocode {
     6  [StorableClass]
     7  public class LogicalExpression : CodeNode {
     8    public override int MinimumArity { get { return 1; } }
     9    public override int MaximumArity { get { return 1; } }
    1210
    13         [Storable]
    14         public override string Prefix { get; set; }
     11    [Storable]
     12    public override string Prefix { get; set; }
    1513
    16         [Storable]
    17         public override string Suffix { get; set; }
     14    [Storable]
     15    public override string Suffix { get; set; }
    1816
    19         [StorableConstructor]
    20         private LogicalExpression(bool deserializing) : base(deserializing) { }
    21         private LogicalExpression(LogicalExpression original, Cloner cloner)
    22             : base(original, cloner)
    23         {
    24             this.Prefix = "";
    25             this.Suffix = "";
    26         }
     17    [StorableConstructor]
     18    private LogicalExpression(bool deserializing) : base(deserializing) { }
     19    private LogicalExpression(LogicalExpression original, Cloner cloner)
     20      : base(original, cloner) {
     21    }
    2722
    28         public LogicalExpression()
    29             : base("LogicalExpression", "A LogicalExpression.")
    30         {
    31             this.Prefix = "";
    32             this.Suffix = "";
    33         }
     23    public LogicalExpression()
     24      : base("LogicalExpression", "A LogicalExpression.") {
     25      this.Prefix = "";
     26      this.Suffix = "";
     27    }
    3428
    35         public override IDeepCloneable Clone(Cloner cloner)
    36         {
    37             return new LogicalExpression(this, cloner);
    38         }
     29    public override IDeepCloneable Clone(Cloner cloner) {
     30      return new LogicalExpression(this, cloner);
     31    }
    3932
    40         public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children)
    41         {
    42             var enumerator = children.GetEnumerator();
     33    public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
     34      var enumerator = children.GetEnumerator();
    4335
    44             if (!enumerator.MoveNext()) throw new System.Exception("LogicalExpression was not given a child.");
    45             var symbol = enumerator.Current.Symbol;
     36      if (!enumerator.MoveNext()) throw new System.Exception("LogicalExpression was not given a child.");
     37      var symbol = enumerator.Current.Symbol;
    4638
    47             if(!(symbol is LogicalValue || symbol is LogicalComparison ||
    48                 symbol is NumericalComparison || symbol is Negation))
    49                 throw new System.Exception("LogicalExpression was given a child of type " + symbol.GetType().ToString() +
    50                     ". The expected child must be of type " + typeof(LogicalValue).ToString() + " or " +
    51                     typeof(LogicalComparison).ToString() + " or " + typeof(NumericalComparison).ToString() + " or " +
    52                     typeof(Negation).ToString() + ".");
     39      if (!(symbol is LogicalValue || symbol is LogicalComparison ||
     40          symbol is NumericalComparison || symbol is Negation))
     41        throw new System.Exception("LogicalExpression was given a child of type " + symbol.GetType().ToString() +
     42            ". The expected child must be of type " + typeof(LogicalValue).ToString() + " or " +
     43            typeof(LogicalComparison).ToString() + " or " + typeof(NumericalComparison).ToString() + " or " +
     44            typeof(Negation).ToString() + ".");
    5345
    54             string result = ((CodeNode)symbol).Interpret(enumerator.Current, enumerator.Current.Subtrees);
    55             if (enumerator.MoveNext()) throw new System.Exception("LogicalExpression was given more than one child.");
     46      string result = ((CodeNode)symbol).Interpret(enumerator.Current, enumerator.Current.Subtrees);
     47      if (enumerator.MoveNext()) throw new System.Exception("LogicalExpression was given more than one child.");
    5648
    57             return this.Prefix + result + this.Suffix;
    58         }
     49      return this.Prefix + result + this.Suffix;
    5950    }
     51  }
    6052}
  • branches/Robocode/HeuristicLab.Problems.Robocode/Symbols/Logical Expressions/LogicalValue.cs

    r9565 r9630  
    33using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    44
    5 namespace HeuristicLab.Problems.Robocode
    6 {
    7     [StorableClass]
    8     public class LogicalValue : CodeNode
    9     {
    10         public override int MinimumArity { get { return 0; } }
    11         public override int MaximumArity { get { return 0; } }
     5namespace HeuristicLab.Problems.Robocode {
     6  [StorableClass]
     7  public class LogicalValue : CodeNode {
     8    public override int MinimumArity { get { return 0; } }
     9    public override int MaximumArity { get { return 0; } }
    1210
    13         [Storable]
    14         public override string Prefix { get; set; }
     11    [Storable]
     12    public override string Prefix { get; set; }
    1513
    16         [Storable]
    17         public override string Suffix { get; set; }
     14    [Storable]
     15    public override string Suffix { get; set; }
    1816
    19         [StorableConstructor]
    20         private LogicalValue(bool deserializing) : base(deserializing) { }
    21         private LogicalValue(LogicalValue original, Cloner cloner)
    22             : base(original, cloner)
    23         {
    24             this.Prefix = "";
    25             this.Suffix = "";
    26         }
     17    [StorableConstructor]
     18    private LogicalValue(bool deserializing) : base(deserializing) { }
     19    private LogicalValue(LogicalValue original, Cloner cloner)
     20      : base(original, cloner) {
     21    }
    2722
    28         public LogicalValue()
    29             : base("LogicalValue", "A LogicalValue.")
    30         {
    31             this.Prefix = "";
    32             this.Suffix = "";
    33         }
     23    public LogicalValue()
     24      : base("LogicalValue", "A LogicalValue.") {
     25      this.Prefix = "";
     26      this.Suffix = "";
     27    }
    3428
    35         public override ISymbolicExpressionTreeNode CreateTreeNode()
    36         {
     29    public override ISymbolicExpressionTreeNode CreateTreeNode() {
    3730
    38             return new BooleanTreeNode();
    39         }
     31      return new BooleanTreeNode();
     32    }
    4033
    41         public override IDeepCloneable Clone(Cloner cloner)
    42         {
    43             return new LogicalValue(this, cloner);
    44         }
     34    public override IDeepCloneable Clone(Cloner cloner) {
     35      return new LogicalValue(this, cloner);
     36    }
    4537
    46         public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children)
    47         {
    48             return " " + ((BooleanTreeNode)node).Value.ToString().ToLower() + " ";
    49         }
     38    public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
     39      return " " + ((BooleanTreeNode)node).Value.ToString().ToLower() + " ";
    5040    }
     41  }
    5142}
  • branches/Robocode/HeuristicLab.Problems.Robocode/Symbols/Logical Expressions/Negation.cs

    r9565 r9630  
    33using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    44
    5 namespace HeuristicLab.Problems.Robocode
    6 {
    7     [StorableClass]
    8     public class Negation : CodeNode
    9     {
    10         public override int MinimumArity { get { return 1; } }
    11         public override int MaximumArity { get { return 1; } }
     5namespace HeuristicLab.Problems.Robocode {
     6  [StorableClass]
     7  public class Negation : CodeNode {
     8    public override int MinimumArity { get { return 1; } }
     9    public override int MaximumArity { get { return 1; } }
    1210
    13         [Storable]
    14         public override string Prefix { get; set; }
     11    [Storable]
     12    public override string Prefix { get; set; }
    1513
    16         [Storable]
    17         public override string Suffix { get; set; }
     14    [Storable]
     15    public override string Suffix { get; set; }
    1816
    19         [StorableConstructor]
    20         private Negation(bool deserializing) : base(deserializing) { }
    21         private Negation(Negation original, Cloner cloner)
    22             : base(original, cloner)
    23         {
    24             this.Prefix = "!(";
    25             this.Suffix = ")";
    26         }
     17    [StorableConstructor]
     18    private Negation(bool deserializing) : base(deserializing) { }
     19    private Negation(Negation original, Cloner cloner)
     20      : base(original, cloner) {
     21    }
    2722
    28         public Negation()
    29             : base("Negation", "A Negation.")
    30         {
    31             this.Prefix = "!(";
    32             this.Suffix = ")";
    33         }
     23    public Negation()
     24      : base("Negation", "A Negation.") {
     25      this.Prefix = "!(";
     26      this.Suffix = ")";
     27    }
    3428
    35         public override IDeepCloneable Clone(Cloner cloner)
    36         {
    37             return new Negation(this, cloner);
    38         }
     29    public override IDeepCloneable Clone(Cloner cloner) {
     30      return new Negation(this, cloner);
     31    }
    3932
    40         public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children)
    41         {
    42             var enumerator = children.GetEnumerator();
    43             if (!enumerator.MoveNext()) throw new System.Exception("Negation was not given a child.");
    44            
    45             var symbol = enumerator.Current.Symbol;
    46             if (!(symbol is LogicalValue || symbol is LogicalComparison ||
    47                 symbol is NumericalComparison || symbol is Negation))
    48                 throw new System.Exception("Negation was given a child of type " + symbol.GetType().ToString() +
    49                     ". The expected child must be of type " + typeof(LogicalValue).ToString() + " or " +
    50                     typeof(LogicalComparison).ToString() + " or " + typeof(NumericalComparison).ToString() + " or " +
    51                     typeof(Negation).ToString() + ".");
     33    public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
     34      var enumerator = children.GetEnumerator();
     35      if (!enumerator.MoveNext()) throw new System.Exception("Negation was not given a child.");
    5236
    53             string result = ((CodeNode)symbol).Interpret(enumerator.Current, enumerator.Current.Subtrees);
    54             if (enumerator.MoveNext()) throw new System.Exception("LogicalExpression was given more than one child.");
     37      var symbol = enumerator.Current.Symbol;
     38      if (!(symbol is LogicalValue || symbol is LogicalComparison ||
     39          symbol is NumericalComparison || symbol is Negation))
     40        throw new System.Exception("Negation was given a child of type " + symbol.GetType().ToString() +
     41            ". The expected child must be of type " + typeof(LogicalValue).ToString() + " or " +
     42            typeof(LogicalComparison).ToString() + " or " + typeof(NumericalComparison).ToString() + " or " +
     43            typeof(Negation).ToString() + ".");
    5544
    56             return this.Prefix + result + this.Suffix;
    57         }
     45      string result = ((CodeNode)symbol).Interpret(enumerator.Current, enumerator.Current.Subtrees);
     46      if (enumerator.MoveNext()) throw new System.Exception("LogicalExpression was given more than one child.");
     47
     48      return this.Prefix + result + this.Suffix;
    5849    }
     50  }
    5951}
  • branches/Robocode/HeuristicLab.Problems.Robocode/Symbols/Logical Expressions/NumericalComparison.cs

    r9565 r9630  
    33using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    44
    5 namespace HeuristicLab.Problems.Robocode
    6 {
    7     [StorableClass]
    8     public class NumericalComparison : CodeNode
    9     {
    10         public override int MinimumArity { get { return 3; } }
    11         public override int MaximumArity { get { return 3; } }
     5namespace HeuristicLab.Problems.Robocode {
     6  [StorableClass]
     7  public class NumericalComparison : CodeNode {
     8    public override int MinimumArity { get { return 3; } }
     9    public override int MaximumArity { get { return 3; } }
    1210
    13         [Storable]
    14         public override string Prefix { get; set; }
     11    [Storable]
     12    public override string Prefix { get; set; }
    1513
    16         [Storable]
    17         public override string Suffix { get; set; }
     14    [Storable]
     15    public override string Suffix { get; set; }
    1816
    19         [StorableConstructor]
    20         private NumericalComparison(bool deserializing) : base(deserializing) { }
    21         private NumericalComparison(NumericalComparison original, Cloner cloner)
    22             : base(original, cloner)
    23         {
    24             this.Prefix = "(";
    25             this.Suffix = ")";
     17    [StorableConstructor]
     18    private NumericalComparison(bool deserializing) : base(deserializing) { }
     19    private NumericalComparison(NumericalComparison original, Cloner cloner)
     20      : base(original, cloner) {
     21    }
     22
     23    public NumericalComparison()
     24      : base("NumericalComparison", "A NumericalComparison.") {
     25      this.Prefix = "(";
     26      this.Suffix = ")";
     27    }
     28
     29    public override IDeepCloneable Clone(Cloner cloner) {
     30      return new NumericalComparison(this, cloner);
     31    }
     32
     33    public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
     34      ISymbolicExpressionTreeNode condition = null, lhs = null, rhs = null;
     35      var enumerator = children.GetEnumerator();
     36      int childCount = 0;
     37      while (enumerator.MoveNext()) {
     38        childCount++;
     39        switch (childCount) {
     40          case 1: condition = enumerator.Current; break;
     41          case 2: lhs = enumerator.Current; break;
     42          case 3: rhs = enumerator.Current; break;
     43          default: throw new System.Exception("Unexpected number of children. Expected 3 children.");
    2644        }
     45      }
     46      if (childCount < 3) throw new System.Exception("Unexpected number of children. Expected 3 children.");
    2747
    28         public NumericalComparison()
    29             : base("NumericalComparison", "A NumericalComparison.")
    30         {
    31             this.Prefix = "(";
    32             this.Suffix = ")";
    33         }
     48      if (!(condition.Symbol is Equal || condition.Symbol is GreaterThan ||
     49          condition.Symbol is GreaterThanOrEqual || condition.Symbol is LessThan || condition.Symbol is LessThanOrEqual))
     50        throw new System.Exception("Unexpected first child for NumericalComparison of type: " +
     51            condition.GetType().ToString() + ". Expected " + typeof(Equal).ToString() +
     52            " or " + typeof(GreaterThan).ToString() +
     53            " or " + typeof(GreaterThanOrEqual).ToString() +
     54            " or " + typeof(LessThan).ToString() +
     55            " or " + typeof(LessThanOrEqual).ToString() + ".");
    3456
    35         public override IDeepCloneable Clone(Cloner cloner)
    36         {
    37             return new NumericalComparison(this, cloner);
    38         }
     57      // TODO Check children 2 & 3 for correct types
    3958
    40         public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children)
    41         {
    42             ISymbolicExpressionTreeNode condition = null, lhs = null, rhs = null;
    43             var enumerator = children.GetEnumerator();
    44             int childCount = 0;
    45             while (enumerator.MoveNext())
    46             {
    47                 childCount++;
    48                 switch (childCount)
    49                 {
    50                     case 1: condition = enumerator.Current; break;
    51                     case 2: lhs = enumerator.Current; break;
    52                     case 3: rhs = enumerator.Current; break;
    53                     default: throw new System.Exception("Unexpected number of children. Expected 3 children.");
    54                 }
    55             }
    56             if (childCount < 3) throw new System.Exception("Unexpected number of children. Expected 3 children.");
    57 
    58             if (!(condition.Symbol is Equal || condition.Symbol is GreaterThan ||
    59                 condition.Symbol is GreaterThanOrEqual || condition.Symbol is LessThan || condition.Symbol is LessThanOrEqual))
    60                 throw new System.Exception("Unexpected first child for NumericalComparison of type: " +
    61                     condition.GetType().ToString() + ". Expected " + typeof(Equal).ToString() +
    62                     " or " + typeof(GreaterThan).ToString() +
    63                     " or " + typeof(GreaterThanOrEqual).ToString() +
    64                     " or " + typeof(LessThan).ToString() +
    65                     " or " + typeof(LessThanOrEqual).ToString() + ".");
    66 
    67             // TODO Check children 2 & 3 for correct types
    68 
    69             string[] result = new string[]
     59      string[] result = new string[]
    7060            {
    7161                ((CodeNode)condition.Symbol).Interpret(condition, condition.Subtrees),
     
    7464            };
    7565
    76             return this.Prefix + " " + result[1] + " " + result[0] + " " + result[2] + " " + this.Suffix;
    77         }
     66      return this.Prefix + " " + result[1] + " " + result[0] + " " + result[2] + " " + this.Suffix;
    7867    }
     68  }
    7969}
  • branches/Robocode/HeuristicLab.Problems.Robocode/Symbols/Numerical Expressions/Number.cs

    r9565 r9630  
    33using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    44
    5 namespace HeuristicLab.Problems.Robocode
    6 {
    7     [StorableClass]
    8     public class Number : CodeNode
    9     {
    10         public override int MinimumArity { get { return 0; } }
    11         public override int MaximumArity { get { return 0; } }
     5namespace HeuristicLab.Problems.Robocode {
     6  [StorableClass]
     7  public class Number : CodeNode {
     8    public override int MinimumArity { get { return 0; } }
     9    public override int MaximumArity { get { return 0; } }
    1210
    13         [Storable]
    14         public override string Prefix { get; set; }
     11    [Storable]
     12    public override string Prefix { get; set; }
    1513
    16         [Storable]
    17         public override string Suffix { get; set; }
     14    [Storable]
     15    public override string Suffix { get; set; }
    1816
    19         [StorableConstructor]
    20         private Number(bool deserializing) : base(deserializing) { }
    21         private Number(Number original, Cloner cloner)
    22             : base(original, cloner)
    23         {
    24             this.Prefix = "";
    25             this.Suffix = "";
    26         }
     17    [StorableConstructor]
     18    private Number(bool deserializing) : base(deserializing) { }
     19    private Number(Number original, Cloner cloner)
     20      : base(original, cloner) {
     21    }
    2722
    28         public Number()
    29             : base("Number", "A Number.")
    30         {
    31             this.Prefix = "";
    32             this.Suffix = "";
    33         }
     23    public Number()
     24      : base("Number", "A Number.") {
     25      this.Prefix = "";
     26      this.Suffix = "";
     27    }
    3428
    35         public override ISymbolicExpressionTreeNode CreateTreeNode()
    36         {
    37            
    38             return new NumberTreeNode();
    39         }
     29    public override ISymbolicExpressionTreeNode CreateTreeNode() {
    4030
    41         public override IDeepCloneable Clone(Cloner cloner)
    42         {
    43             return new Number(this, cloner);
    44         }
     31      return new NumberTreeNode();
     32    }
    4533
    46         public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children)
    47         {
    48             return " " + ((NumberTreeNode)node).Value + " ";
    49         }
     34    public override IDeepCloneable Clone(Cloner cloner) {
     35      return new Number(this, cloner);
    5036    }
     37
     38    public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
     39      return " " + ((NumberTreeNode)node).Value + " ";
     40    }
     41  }
    5142}
  • branches/Robocode/HeuristicLab.Problems.Robocode/Symbols/Numerical Expressions/Numerical Operators/Addition.cs

    r9565 r9630  
    33using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    44
    5 namespace HeuristicLab.Problems.Robocode
    6 {
    7     [StorableClass]
    8     public class Addition : CodeNode
    9     {
    10         public override int MinimumArity { get { return 0; } }
    11         public override int MaximumArity { get { return 0; } }
     5namespace HeuristicLab.Problems.Robocode {
     6  [StorableClass]
     7  public class Addition : CodeNode {
     8    public override int MinimumArity { get { return 0; } }
     9    public override int MaximumArity { get { return 0; } }
    1210
    13         [Storable]
    14         public override string Prefix { get; set; }
     11    [Storable]
     12    public override string Prefix { get; set; }
    1513
    16         [Storable]
    17         public override string Suffix { get; set; }
     14    [Storable]
     15    public override string Suffix { get; set; }
    1816
    19         [StorableConstructor]
    20         private Addition(bool deserializing) : base(deserializing) { }
    21         private Addition(Addition original, Cloner cloner)
    22             : base(original, cloner)
    23         {
    24             this.Prefix = "+";
    25             this.Suffix = "";
    26         }
     17    [StorableConstructor]
     18    private Addition(bool deserializing) : base(deserializing) { }
     19    private Addition(Addition original, Cloner cloner)
     20      : base(original, cloner) {
    2721
    28         public Addition()
    29             : base("Addition", "Addition operator.")
    30         {
    31             this.Prefix = "+";
    32             this.Suffix = "";
    33         }
     22    }
    3423
    35         public override IDeepCloneable Clone(Cloner cloner)
    36         {
    37             return new Addition(this, cloner);
    38         }
     24    public Addition()
     25      : base("Addition", "Addition operator.") {
     26      this.Prefix = "+";
     27      this.Suffix = "";
     28    }
    3929
    40         public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children)
    41         {
    42             return this.Prefix + this.Suffix;
    43         }
     30    public override IDeepCloneable Clone(Cloner cloner) {
     31      return new Addition(this, cloner);
    4432    }
     33
     34    public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
     35      return this.Prefix + this.Suffix;
     36    }
     37  }
    4538}
  • branches/Robocode/HeuristicLab.Problems.Robocode/Symbols/Numerical Expressions/Numerical Operators/Division.cs

    r9565 r9630  
    33using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    44
    5 namespace HeuristicLab.Problems.Robocode
    6 {
    7     [StorableClass]
    8     public class Division : CodeNode
    9     {
    10         public override int MinimumArity { get { return 0; } }
    11         public override int MaximumArity { get { return 0; } }
     5namespace HeuristicLab.Problems.Robocode {
     6  [StorableClass]
     7  public class Division : CodeNode {
     8    public override int MinimumArity { get { return 0; } }
     9    public override int MaximumArity { get { return 0; } }
    1210
    13         [Storable]
    14         public override string Prefix { get; set; }
     11    [Storable]
     12    public override string Prefix { get; set; }
    1513
    16         [Storable]
    17         public override string Suffix { get; set; }
     14    [Storable]
     15    public override string Suffix { get; set; }
    1816
    19         [StorableConstructor]
    20         private Division(bool deserializing) : base(deserializing) { }
    21         private Division(Division original, Cloner cloner)
    22             : base(original, cloner)
    23         {
    24             this.Prefix = "/";
    25             this.Suffix = "";
    26         }
     17    [StorableConstructor]
     18    private Division(bool deserializing) : base(deserializing) { }
     19    private Division(Division original, Cloner cloner)
     20      : base(original, cloner) {
    2721
    28         public Division()
    29             : base("Division", "Division operator.")
    30         {
    31             this.Prefix = "/";
    32             this.Suffix = "";
    33         }
     22    }
    3423
    35         public override IDeepCloneable Clone(Cloner cloner)
    36         {
    37             return new Division(this, cloner);
    38         }
     24    public Division()
     25      : base("Division", "Division operator.") {
     26      this.Prefix = "/";
     27      this.Suffix = "";
     28    }
    3929
    40         public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children)
    41         {
    42             return this.Prefix + this.Suffix;
    43         }
     30    public override IDeepCloneable Clone(Cloner cloner) {
     31      return new Division(this, cloner);
    4432    }
     33
     34    public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
     35      return this.Prefix + this.Suffix;
     36    }
     37  }
    4538}
  • branches/Robocode/HeuristicLab.Problems.Robocode/Symbols/Numerical Expressions/Numerical Operators/Modulus.cs

    r9565 r9630  
    33using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    44
    5 namespace HeuristicLab.Problems.Robocode
    6 {
    7     [StorableClass]
    8     public class Modulus : CodeNode
    9     {
    10         public override int MinimumArity { get { return 0; } }
    11         public override int MaximumArity { get { return 0; } }
     5namespace HeuristicLab.Problems.Robocode {
     6  [StorableClass]
     7  public class Modulus : CodeNode {
     8    public override int MinimumArity { get { return 0; } }
     9    public override int MaximumArity { get { return 0; } }
    1210
    13         [Storable]
    14         public override string Prefix { get; set; }
     11    [Storable]
     12    public override string Prefix { get; set; }
    1513
    16         [Storable]
    17         public override string Suffix { get; set; }
     14    [Storable]
     15    public override string Suffix { get; set; }
    1816
    19         [StorableConstructor]
    20         private Modulus(bool deserializing) : base(deserializing) { }
    21         private Modulus(Modulus original, Cloner cloner)
    22             : base(original, cloner)
    23         {
    24             this.Prefix = "%";
    25             this.Suffix = "";
    26         }
     17    [StorableConstructor]
     18    private Modulus(bool deserializing) : base(deserializing) { }
     19    private Modulus(Modulus original, Cloner cloner)
     20      : base(original, cloner) {
    2721
    28         public Modulus()
    29             : base("Modulus", "Modulus operator.")
    30         {
    31             this.Prefix = "%";
    32             this.Suffix = "";
    33         }
     22    }
    3423
    35         public override IDeepCloneable Clone(Cloner cloner)
    36         {
    37             return new Modulus(this, cloner);
    38         }
     24    public Modulus()
     25      : base("Modulus", "Modulus operator.") {
     26      this.Prefix = "%";
     27      this.Suffix = "";
     28    }
    3929
    40         public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children)
    41         {
    42             return this.Prefix + this.Suffix;
    43         }
     30    public override IDeepCloneable Clone(Cloner cloner) {
     31      return new Modulus(this, cloner);
    4432    }
     33
     34    public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
     35      return this.Prefix + this.Suffix;
     36    }
     37  }
    4538}
  • branches/Robocode/HeuristicLab.Problems.Robocode/Symbols/Numerical Expressions/Numerical Operators/Multiplication.cs

    r9565 r9630  
    33using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    44
    5 namespace HeuristicLab.Problems.Robocode
    6 {
    7     [StorableClass]
    8     public class Multiplication : CodeNode
    9     {
    10         public override int MinimumArity { get { return 0; } }
    11         public override int MaximumArity { get { return 0; } }
     5namespace HeuristicLab.Problems.Robocode {
     6  [StorableClass]
     7  public class Multiplication : CodeNode {
     8    public override int MinimumArity { get { return 0; } }
     9    public override int MaximumArity { get { return 0; } }
    1210
    13         [Storable]
    14         public override string Prefix { get; set; }
     11    [Storable]
     12    public override string Prefix { get; set; }
    1513
    16         [Storable]
    17         public override string Suffix { get; set; }
     14    [Storable]
     15    public override string Suffix { get; set; }
    1816
    19         [StorableConstructor]
    20         private Multiplication(bool deserializing) : base(deserializing) { }
    21         private Multiplication(Multiplication original, Cloner cloner)
    22             : base(original, cloner)
    23         {
    24             this.Prefix = "*";
    25             this.Suffix = "";
    26         }
     17    [StorableConstructor]
     18    private Multiplication(bool deserializing) : base(deserializing) { }
     19    private Multiplication(Multiplication original, Cloner cloner)
     20      : base(original, cloner) {
    2721
    28         public Multiplication()
    29             : base("Multiplication", "Multiplication operator.")
    30         {
    31             this.Prefix = "*";
    32             this.Suffix = "";
    33         }
     22    }
    3423
    35         public override IDeepCloneable Clone(Cloner cloner)
    36         {
    37             return new Multiplication(this, cloner);
    38         }
     24    public Multiplication()
     25      : base("Multiplication", "Multiplication operator.") {
     26      this.Prefix = "*";
     27      this.Suffix = "";
     28    }
    3929
    40         public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children)
    41         {
    42             return this.Prefix + this.Suffix;
    43         }
     30    public override IDeepCloneable Clone(Cloner cloner) {
     31      return new Multiplication(this, cloner);
    4432    }
     33
     34    public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
     35      return this.Prefix + this.Suffix;
     36    }
     37  }
    4538}
  • branches/Robocode/HeuristicLab.Problems.Robocode/Symbols/Numerical Expressions/Numerical Operators/Subtraction.cs

    r9565 r9630  
    33using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    44
    5 namespace HeuristicLab.Problems.Robocode
    6 {
    7     [StorableClass]
    8     public class Subtraction : CodeNode
    9     {
    10         public override int MinimumArity { get { return 0; } }
    11         public override int MaximumArity { get { return 0; } }
     5namespace HeuristicLab.Problems.Robocode {
     6  [StorableClass]
     7  public class Subtraction : CodeNode {
     8    public override int MinimumArity { get { return 0; } }
     9    public override int MaximumArity { get { return 0; } }
    1210
    13         [Storable]
    14         public override string Prefix { get; set; }
     11    [Storable]
     12    public override string Prefix { get; set; }
    1513
    16         [Storable]
    17         public override string Suffix { get; set; }
     14    [Storable]
     15    public override string Suffix { get; set; }
    1816
    19         [StorableConstructor]
    20         private Subtraction(bool deserializing) : base(deserializing) { }
    21         private Subtraction(Subtraction original, Cloner cloner)
    22             : base(original, cloner)
    23         {
    24             this.Prefix = "-";
    25             this.Suffix = "";
    26         }
     17    [StorableConstructor]
     18    private Subtraction(bool deserializing) : base(deserializing) { }
     19    private Subtraction(Subtraction original, Cloner cloner)
     20      : base(original, cloner) {
    2721
    28         public Subtraction()
    29             : base("Subtraction", "Subtraction operator.")
    30         {
    31             this.Prefix = "-";
    32             this.Suffix = "";
    33         }
     22    }
    3423
    35         public override IDeepCloneable Clone(Cloner cloner)
    36         {
    37             return new Subtraction(this, cloner);
    38         }
     24    public Subtraction()
     25      : base("Subtraction", "Subtraction operator.") {
     26      this.Prefix = "-";
     27      this.Suffix = "";
     28    }
    3929
    40         public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children)
    41         {
    42             return this.Prefix + this.Suffix;
    43         }
     30    public override IDeepCloneable Clone(Cloner cloner) {
     31      return new Subtraction(this, cloner);
    4432    }
     33
     34    public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
     35      return this.Prefix + this.Suffix;
     36    }
     37  }
    4538}
  • branches/Robocode/HeuristicLab.Problems.Robocode/Symbols/Numerical Expressions/NumericalExpression.cs

    r9565 r9630  
    33using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    44
    5 namespace HeuristicLab.Problems.Robocode
    6 {
    7     [StorableClass]
    8     public class NumericalExpression : CodeNode
    9     {
    10         public override int MinimumArity { get { return 1; } }
    11         public override int MaximumArity { get { return 1; } }
     5namespace HeuristicLab.Problems.Robocode {
     6  [StorableClass]
     7  public class NumericalExpression : CodeNode {
     8    public override int MinimumArity { get { return 1; } }
     9    public override int MaximumArity { get { return 1; } }
    1210
    13         [Storable]
    14         public override string Prefix { get; set; }
     11    [Storable]
     12    public override string Prefix { get; set; }
    1513
    16         [Storable]
    17         public override string Suffix { get; set; }
     14    [Storable]
     15    public override string Suffix { get; set; }
    1816
    19         [StorableConstructor]
    20         private NumericalExpression(bool deserializing) : base(deserializing) { }
    21         private NumericalExpression(NumericalExpression original, Cloner cloner)
    22             : base(original, cloner)
    23         {
    24             this.Prefix = "";
    25             this.Suffix = "";
    26         }
     17    [StorableConstructor]
     18    private NumericalExpression(bool deserializing) : base(deserializing) { }
     19    private NumericalExpression(NumericalExpression original, Cloner cloner)
     20      : base(original, cloner) {
     21    }
    2722
    28         public NumericalExpression()
    29             : base("NumericalExpression", "A NumericalExpression.")
    30         {
    31             this.Prefix = "";
    32             this.Suffix = "";
    33         }
     23    public NumericalExpression()
     24      : base("NumericalExpression", "A NumericalExpression.") {
     25      this.Prefix = "";
     26      this.Suffix = "";
     27    }
    3428
    35         public override IDeepCloneable Clone(Cloner cloner)
    36         {
    37             return new NumericalExpression(this, cloner);
    38         }
     29    public override IDeepCloneable Clone(Cloner cloner) {
     30      return new NumericalExpression(this, cloner);
     31    }
    3932
    40         public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children)
    41         {
    42             var enumerator = children.GetEnumerator();
     33    public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
     34      var enumerator = children.GetEnumerator();
    4335
    44             if (!enumerator.MoveNext()) throw new System.Exception("NumericalExpression was not given a child.");
    45             var symbol = enumerator.Current.Symbol;
     36      if (!enumerator.MoveNext()) throw new System.Exception("NumericalExpression was not given a child.");
     37      var symbol = enumerator.Current.Symbol;
    4638
    47             if (!(symbol is Number || symbol is NumericalOperation || symbol.GetType().GetInterface(typeof(INumericalMethod).FullName) != null))
    48                 throw new System.Exception("NumericalExpression was given a child of type " + symbol.GetType().ToString() +
    49                     ". The expected child must be of type " + typeof(Number).ToString() + " or " +
    50                     typeof(NumericalOperation).ToString() + " or " +
    51                     typeof(INumericalMethod).ToString() + ".");
     39      if (!(symbol is Number || symbol is NumericalOperation || symbol.GetType().GetInterface(typeof(INumericalMethod).FullName) != null))
     40        throw new System.Exception("NumericalExpression was given a child of type " + symbol.GetType().ToString() +
     41            ". The expected child must be of type " + typeof(Number).ToString() + " or " +
     42            typeof(NumericalOperation).ToString() + " or " +
     43            typeof(INumericalMethod).ToString() + ".");
    5244
    53             string result = ((CodeNode)symbol).Interpret(enumerator.Current, enumerator.Current.Subtrees);
    54             if (enumerator.MoveNext()) throw new System.Exception("NumericalExpression was given more than one child.");
     45      string result = ((CodeNode)symbol).Interpret(enumerator.Current, enumerator.Current.Subtrees);
     46      if (enumerator.MoveNext()) throw new System.Exception("NumericalExpression was given more than one child.");
    5547
    56             return this.Prefix + result + this.Suffix;
    57         }
     48      return this.Prefix + result + this.Suffix;
    5849    }
     50  }
    5951}
  • branches/Robocode/HeuristicLab.Problems.Robocode/Symbols/Numerical Expressions/NumericalOperation.cs

    r9565 r9630  
    33using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    44
    5 namespace HeuristicLab.Problems.Robocode
    6 {
    7     [StorableClass]
    8     public class NumericalOperation : CodeNode
    9     {
    10         public override int MinimumArity { get { return 3; } }
    11         public override int MaximumArity { get { return 3; } }
     5namespace HeuristicLab.Problems.Robocode {
     6  [StorableClass]
     7  public class NumericalOperation : CodeNode {
     8    public override int MinimumArity { get { return 3; } }
     9    public override int MaximumArity { get { return 3; } }
    1210
    13         [Storable]
    14         public override string Prefix { get; set; }
     11    [Storable]
     12    public override string Prefix { get; set; }
    1513
    16         [Storable]
    17         public override string Suffix { get; set; }
     14    [Storable]
     15    public override string Suffix { get; set; }
    1816
    19         [StorableConstructor]
    20         private NumericalOperation(bool deserializing) : base(deserializing) { }
    21         private NumericalOperation(NumericalOperation original, Cloner cloner)
    22             : base(original, cloner)
    23         {
    24             this.Prefix = "(";
    25             this.Suffix = ")";
     17    [StorableConstructor]
     18    private NumericalOperation(bool deserializing) : base(deserializing) { }
     19    private NumericalOperation(NumericalOperation original, Cloner cloner)
     20      : base(original, cloner) {
     21    }
     22
     23    public NumericalOperation()
     24      : base("NumericalOperation", "An expression consisting of two numbers and an operator.") {
     25      this.Prefix = "(";
     26      this.Suffix = ")";
     27    }
     28
     29    public override IDeepCloneable Clone(Cloner cloner) {
     30      return new NumericalOperation(this, cloner);
     31    }
     32
     33    public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
     34      ISymbolicExpressionTreeNode condition = null, lhs = null, rhs = null;
     35      var enumerator = children.GetEnumerator();
     36      int childCount = 0;
     37      while (enumerator.MoveNext()) {
     38        childCount++;
     39        switch (childCount) {
     40          case 1: condition = enumerator.Current; break;
     41          case 2: lhs = enumerator.Current; break;
     42          case 3: rhs = enumerator.Current; break;
     43          default: throw new System.Exception("Unexpected number of children. Expected 3 children.");
    2644        }
     45      }
     46      if (childCount < 3) throw new System.Exception("Unexpected number of children. Expected 3 children.");
    2747
    28         public NumericalOperation()
    29             : base("NumericalOperation", "An expression consisting of two numbers and an operator.")
    30         {
    31             this.Prefix = "(";
    32             this.Suffix = ")";
    33         }
     48      if (!(condition.Symbol is Addition || condition.Symbol is Division ||
     49          condition.Symbol is Modulus || condition.Symbol is Multiplication || condition.Symbol is Subtraction))
     50        throw new System.Exception("Unexpected first child for NumericalOperation of type: " +
     51            condition.GetType().ToString() + ". Expected " + typeof(Addition).ToString() +
     52            " or " + typeof(Division).ToString() +
     53            " or " + typeof(Modulus).ToString() +
     54            " or " + typeof(Multiplication).ToString() +
     55            " or " + typeof(Subtraction).ToString() + ".");
    3456
    35         public override IDeepCloneable Clone(Cloner cloner)
    36         {
    37             return new NumericalOperation(this, cloner);
    38         }
     57      // TODO Check children 2 & 3 for correct types
    3958
    40         public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children)
    41         {
    42             ISymbolicExpressionTreeNode condition = null, lhs = null, rhs = null;
    43             var enumerator = children.GetEnumerator();
    44             int childCount = 0;
    45             while (enumerator.MoveNext())
    46             {
    47                 childCount++;
    48                 switch (childCount)
    49                 {
    50                     case 1: condition = enumerator.Current; break;
    51                     case 2: lhs = enumerator.Current; break;
    52                     case 3: rhs = enumerator.Current; break;
    53                     default: throw new System.Exception("Unexpected number of children. Expected 3 children.");
    54                 }
    55             }
    56             if (childCount < 3) throw new System.Exception("Unexpected number of children. Expected 3 children.");
    57 
    58             if (!(condition.Symbol is Addition || condition.Symbol is Division ||
    59                 condition.Symbol is Modulus || condition.Symbol is Multiplication || condition.Symbol is Subtraction))
    60                 throw new System.Exception("Unexpected first child for NumericalOperation of type: " +
    61                     condition.GetType().ToString() + ". Expected " + typeof(Addition).ToString() +
    62                     " or " + typeof(Division).ToString() +
    63                     " or " + typeof(Modulus).ToString() +
    64                     " or " + typeof(Multiplication).ToString() +
    65                     " or " + typeof(Subtraction).ToString() + ".");
    66 
    67             // TODO Check children 2 & 3 for correct types
    68 
    69             string[] result = new string[]
     59      string[] result = new string[]
    7060            {
    7161                ((CodeNode)condition.Symbol).Interpret(condition, condition.Subtrees),
     
    7464            };
    7565
    76             return this.Prefix + " " + result[1] + " " + result[0] + " " + result[2] + " " + this.Suffix;
    77         }
     66      return this.Prefix + " " + result[1] + " " + result[0] + " " + result[2] + " " + this.Suffix;
    7867    }
     68  }
    7969}
  • branches/Robocode/HeuristicLab.Problems.Robocode/Symbols/Numerical Methods/GetEnergy.cs

    r9565 r9630  
    33using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    44
    5 namespace HeuristicLab.Problems.Robocode
    6 {
    7     [StorableClass]
    8     public class GetEnergy : CodeNode, INumericalMethod
    9     {
    10         public override int MinimumArity { get { return 0; } }
    11         public override int MaximumArity { get { return 0; } }
     5namespace HeuristicLab.Problems.Robocode {
     6  [StorableClass]
     7  public class GetEnergy : CodeNode, INumericalMethod {
     8    public override int MinimumArity { get { return 0; } }
     9    public override int MaximumArity { get { return 0; } }
    1210
    13         [Storable]
    14         public override string Prefix { get; set; }
     11    [Storable]
     12    public override string Prefix { get; set; }
    1513
    16         [Storable]
    17         public override string Suffix { get; set; }
     14    [Storable]
     15    public override string Suffix { get; set; }
    1816
    19         [StorableConstructor]
    20         private GetEnergy(bool deserializing) : base(deserializing) { }
    21         private GetEnergy(GetEnergy original, Cloner cloner)
    22             : base(original, cloner)
    23         {
    24             this.Prefix = "getEnergy(";
    25             this.Suffix = ")";
    26         }
     17    [StorableConstructor]
     18    private GetEnergy(bool deserializing) : base(deserializing) { }
     19    private GetEnergy(GetEnergy original, Cloner cloner)
     20      : base(original, cloner) {
    2721
    28         public GetEnergy()
    29             : base("GetEnergy", "Returns the robot's current energy.")
    30         {
    31             this.Prefix = "getEnergy(";
    32             this.Suffix = ")";
    33         }
     22    }
    3423
    35         public override IDeepCloneable Clone(Cloner cloner)
    36         {
    37             return new GetEnergy(this, cloner);
    38         }
     24    public GetEnergy()
     25      : base("GetEnergy", "Returns the robot's current energy.") {
     26      this.Prefix = "getEnergy(";
     27      this.Suffix = ")";
     28    }
    3929
    40         public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children)
    41         {
    42             return this.Prefix + this.Suffix;
    43         }
     30    public override IDeepCloneable Clone(Cloner cloner) {
     31      return new GetEnergy(this, cloner);
    4432    }
     33
     34    public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
     35      return this.Prefix + this.Suffix;
     36    }
     37  }
    4538}
  • branches/Robocode/HeuristicLab.Problems.Robocode/Symbols/Numerical Methods/GetGunHeading.cs

    r9565 r9630  
    33using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    44
    5 namespace HeuristicLab.Problems.Robocode
    6 {
    7     [StorableClass]
    8     public class GetGunHeading : CodeNode, INumericalMethod
    9     {
    10         public override int MinimumArity { get { return 0; } }
    11         public override int MaximumArity { get { return 0; } }
     5namespace HeuristicLab.Problems.Robocode {
     6  [StorableClass]
     7  public class GetGunHeading : CodeNode, INumericalMethod {
     8    public override int MinimumArity { get { return 0; } }
     9    public override int MaximumArity { get { return 0; } }
    1210
    13         [Storable]
    14         public override string Prefix { get; set; }
     11    [Storable]
     12    public override string Prefix { get; set; }
    1513
    16         [Storable]
    17         public override string Suffix { get; set; }
     14    [Storable]
     15    public override string Suffix { get; set; }
    1816
    19         [StorableConstructor]
    20         private GetGunHeading(bool deserializing) : base(deserializing) { }
    21         private GetGunHeading(GetGunHeading original, Cloner cloner)
    22             : base(original, cloner)
    23         {
    24             this.Prefix = "getGunHeading(";
    25             this.Suffix = ")";
    26         }
     17    [StorableConstructor]
     18    private GetGunHeading(bool deserializing) : base(deserializing) { }
     19    private GetGunHeading(GetGunHeading original, Cloner cloner)
     20      : base(original, cloner) {
    2721
    28         public GetGunHeading()
    29             : base("GetGunHeading", "Returns the direction that the robot's gun is facing, in degrees.")
    30         {
    31             this.Prefix = "getGunHeading(";
    32             this.Suffix = ")";
    33         }
     22    }
    3423
    35         public override IDeepCloneable Clone(Cloner cloner)
    36         {
    37             return new GetGunHeading(this, cloner);
    38         }
     24    public GetGunHeading()
     25      : base("GetGunHeading", "Returns the direction that the robot's gun is facing, in degrees.") {
     26      this.Prefix = "getGunHeading(";
     27      this.Suffix = ")";
     28    }
    3929
    40         public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children)
    41         {
    42             return this.Prefix + this.Suffix;
    43         }
     30    public override IDeepCloneable Clone(Cloner cloner) {
     31      return new GetGunHeading(this, cloner);
    4432    }
     33
     34    public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
     35      return this.Prefix + this.Suffix;
     36    }
     37  }
    4538}
  • branches/Robocode/HeuristicLab.Problems.Robocode/Symbols/Numerical Methods/GetHeading.cs

    r9565 r9630  
    33using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    44
    5 namespace HeuristicLab.Problems.Robocode
    6 {
    7     [StorableClass]
    8     public class GetHeading : CodeNode, INumericalMethod
    9     {
    10         public override int MinimumArity { get { return 0; } }
    11         public override int MaximumArity { get { return 0; } }
     5namespace HeuristicLab.Problems.Robocode {
     6  [StorableClass]
     7  public class GetHeading : CodeNode, INumericalMethod {
     8    public override int MinimumArity { get { return 0; } }
     9    public override int MaximumArity { get { return 0; } }
    1210
    13         [Storable]
    14         public override string Prefix { get; set; }
     11    [Storable]
     12    public override string Prefix { get; set; }
    1513
    16         [Storable]
    17         public override string Suffix { get; set; }
     14    [Storable]
     15    public override string Suffix { get; set; }
    1816
    19         [StorableConstructor]
    20         private GetHeading(bool deserializing) : base(deserializing) { }
    21         private GetHeading(GetHeading original, Cloner cloner)
    22             : base(original, cloner)
    23         {
    24             this.Prefix = "getHeading(";
    25             this.Suffix = ")";
    26         }
     17    [StorableConstructor]
     18    private GetHeading(bool deserializing) : base(deserializing) { }
     19    private GetHeading(GetHeading original, Cloner cloner)
     20      : base(original, cloner) {
    2721
    28         public GetHeading()
    29             : base("GetHeading", "Returns the direction that the robot's body is facing, in degrees.")
    30         {
    31             this.Prefix = "getHeading(";
    32             this.Suffix = ")";
    33         }
     22    }
    3423
    35         public override IDeepCloneable Clone(Cloner cloner)
    36         {
    37             return new GetHeading(this, cloner);
    38         }
     24    public GetHeading()
     25      : base("GetHeading", "Returns the direction that the robot's body is facing, in degrees.") {
     26      this.Prefix = "getHeading(";
     27      this.Suffix = ")";
     28    }
    3929
    40         public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children)
    41         {
    42             return this.Prefix + this.Suffix;
    43         }
     30    public override IDeepCloneable Clone(Cloner cloner) {
     31      return new GetHeading(this, cloner);
    4432    }
     33
     34    public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
     35      return this.Prefix + this.Suffix;
     36    }
     37  }
    4538}
  • branches/Robocode/HeuristicLab.Problems.Robocode/Symbols/Numerical Methods/GetRadarHeading.cs

    r9565 r9630  
    33using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    44
    5 namespace HeuristicLab.Problems.Robocode
    6 {
    7     [StorableClass]
    8     public class GetRadarHeading : CodeNode, INumericalMethod
    9     {
    10         public override int MinimumArity { get { return 0; } }
    11         public override int MaximumArity { get { return 0; } }
     5namespace HeuristicLab.Problems.Robocode {
     6  [StorableClass]
     7  public class GetRadarHeading : CodeNode, INumericalMethod {
     8    public override int MinimumArity { get { return 0; } }
     9    public override int MaximumArity { get { return 0; } }
    1210
    13         [Storable]
    14         public override string Prefix { get; set; }
     11    [Storable]
     12    public override string Prefix { get; set; }
    1513
    16         [Storable]
    17         public override string Suffix { get; set; }
     14    [Storable]
     15    public override string Suffix { get; set; }
    1816
    19         [StorableConstructor]
    20         private GetRadarHeading(bool deserializing) : base(deserializing) { }
    21         private GetRadarHeading(GetRadarHeading original, Cloner cloner)
    22             : base(original, cloner)
    23         {
    24             this.Prefix = "getRadarHeading(";
    25             this.Suffix = ")";
    26         }
     17    [StorableConstructor]
     18    private GetRadarHeading(bool deserializing) : base(deserializing) { }
     19    private GetRadarHeading(GetRadarHeading original, Cloner cloner)
     20      : base(original, cloner) {
     21    }
    2722
    28         public GetRadarHeading()
    29             : base("GetRadarHeading", "Returns the direction that the robot's radar is facing, in degrees.")
    30         {
    31             this.Prefix = "getRadarHeading(";
    32             this.Suffix = ")";
    33         }
     23    public GetRadarHeading()
     24      : base("GetRadarHeading", "Returns the direction that the robot's radar is facing, in degrees.") {
     25      this.Prefix = "getRadarHeading(";
     26      this.Suffix = ")";
     27    }
    3428
    35         public override IDeepCloneable Clone(Cloner cloner)
    36         {
    37             return new GetRadarHeading(this, cloner);
    38         }
     29    public override IDeepCloneable Clone(Cloner cloner) {
     30      return new GetRadarHeading(this, cloner);
     31    }
    3932
    40         public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children)
    41         {
    42             return this.Prefix + this.Suffix;
    43         }
     33    public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
     34      return this.Prefix + this.Suffix;
    4435    }
     36  }
    4537}
  • branches/Robocode/HeuristicLab.Problems.Robocode/Symbols/Numerical Methods/GetX.cs

    r9565 r9630  
    33using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    44
    5 namespace HeuristicLab.Problems.Robocode
    6 {
    7     [StorableClass]
    8     public class GetX : CodeNode, INumericalMethod
    9     {
    10         public override int MinimumArity { get { return 0; } }
    11         public override int MaximumArity { get { return 0; } }
     5namespace HeuristicLab.Problems.Robocode {
     6  [StorableClass]
     7  public class GetX : CodeNode, INumericalMethod {
     8    public override int MinimumArity { get { return 0; } }
     9    public override int MaximumArity { get { return 0; } }
    1210
    13         [Storable]
    14         public override string Prefix { get; set; }
     11    [Storable]
     12    public override string Prefix { get; set; }
    1513
    16         [Storable]
    17         public override string Suffix { get; set; }
     14    [Storable]
     15    public override string Suffix { get; set; }
    1816
    19         [StorableConstructor]
    20         private GetX(bool deserializing) : base(deserializing) { }
    21         private GetX(GetX original, Cloner cloner)
    22             : base(original, cloner)
    23         {
    24             this.Prefix = "getX(";
    25             this.Suffix = ")";
    26         }
     17    [StorableConstructor]
     18    private GetX(bool deserializing) : base(deserializing) { }
     19    private GetX(GetX original, Cloner cloner)
     20      : base(original, cloner) {
    2721
    28         public GetX()
    29             : base("GetX", "Returns the X position of the robot. (0,0) is at the bottom left of the battlefield.")
    30         {
    31             this.Prefix = "getX(";
    32             this.Suffix = ")";
    33         }
     22    }
    3423
    35         public override IDeepCloneable Clone(Cloner cloner)
    36         {
    37             return new GetX(this, cloner);
    38         }
     24    public GetX()
     25      : base("GetX", "Returns the X position of the robot. (0,0) is at the bottom left of the battlefield.") {
     26      this.Prefix = "getX(";
     27      this.Suffix = ")";
     28    }
    3929
    40         public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children)
    41         {
    42             return this.Prefix + this.Suffix;
    43         }
     30    public override IDeepCloneable Clone(Cloner cloner) {
     31      return new GetX(this, cloner);
    4432    }
     33
     34    public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
     35      return this.Prefix + this.Suffix;
     36    }
     37  }
    4538}
  • branches/Robocode/HeuristicLab.Problems.Robocode/Symbols/Numerical Methods/GetY.cs

    r9565 r9630  
    33using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    44
    5 namespace HeuristicLab.Problems.Robocode
    6 {
    7     [StorableClass]
    8     public class GetY : CodeNode, INumericalMethod
    9     {
    10         public override int MinimumArity { get { return 0; } }
    11         public override int MaximumArity { get { return 0; } }
     5namespace HeuristicLab.Problems.Robocode {
     6  [StorableClass]
     7  public class GetY : CodeNode, INumericalMethod {
     8    public override int MinimumArity { get { return 0; } }
     9    public override int MaximumArity { get { return 0; } }
    1210
    13         [Storable]
    14         public override string Prefix { get; set; }
     11    [Storable]
     12    public override string Prefix { get; set; }
    1513
    16         [Storable]
    17         public override string Suffix { get; set; }
     14    [Storable]
     15    public override string Suffix { get; set; }
    1816
    19         [StorableConstructor]
    20         private GetY(bool deserializing) : base(deserializing) { }
    21         private GetY(GetY original, Cloner cloner)
    22             : base(original, cloner)
    23         {
    24             this.Prefix = "getY(";
    25             this.Suffix = ")";
    26         }
     17    [StorableConstructor]
     18    private GetY(bool deserializing) : base(deserializing) { }
     19    private GetY(GetY original, Cloner cloner)
     20      : base(original, cloner) {
    2721
    28         public GetY()
    29             : base("GetY", "Returns the Y position of the robot. (0,0) is at the bottom left of the battlefield.")
    30         {
    31             this.Prefix = "getY(";
    32             this.Suffix = ")";
    33         }
     22    }
    3423
    35         public override IDeepCloneable Clone(Cloner cloner)
    36         {
    37             return new GetY(this, cloner);
    38         }
     24    public GetY()
     25      : base("GetY", "Returns the Y position of the robot. (0,0) is at the bottom left of the battlefield.") {
     26      this.Prefix = "getY(";
     27      this.Suffix = ")";
     28    }
    3929
    40         public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children)
    41         {
    42             return this.Prefix + this.Suffix;
    43         }
     30    public override IDeepCloneable Clone(Cloner cloner) {
     31      return new GetY(this, cloner);
    4432    }
     33
     34    public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
     35      return this.Prefix + this.Suffix;
     36    }
     37  }
    4538}
  • branches/Robocode/HeuristicLab.Problems.Robocode/Symbols/Tank.cs

    r9565 r9630  
    33using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    44
    5 namespace HeuristicLab.Problems.Robocode
    6 {
    7     [StorableClass]
    8     public class Tank : CodeNode
    9     {
    10         public override int MinimumArity { get { return 7; } }
    11         public override int MaximumArity { get { return 7; } }
     5namespace HeuristicLab.Problems.Robocode {
     6  [StorableClass]
     7  public class Tank : CodeNode {
     8    public override int MinimumArity { get { return 7; } }
     9    public override int MaximumArity { get { return 7; } }
    1210
    13         [Storable]
    14         public override string Prefix { get; set; }
     11    [Storable]
     12    public override string Prefix { get; set; }
    1513
    16         [Storable]
    17         public override string Suffix { get; set; }
     14    [Storable]
     15    public override string Suffix { get; set; }
    1816
    19         [StorableConstructor]
    20         private Tank(bool deserializing) : base(deserializing) { }
    21         private Tank(Tank original, Cloner cloner)
    22             : base(original, cloner)
    23         {
    24             this.Prefix = "package Evaluation;" +
    25                           "\r\nimport robocode.*;" +
    26                           "\r\nimport robocode.Robot;" +
    27                           "\r\nimport robocode.util.*;" +
    28                           "\r\nimport static robocode.util.Utils.normalRelativeAngleDegrees;" +
    29                           "\r\nimport java.awt.*;" +
    30                           "\r\n\r\n" +
    31                           "\r\npublic class output extends AdvancedRobot {\r\n";
    32             this.Suffix = "\r\n}";
    33         }
     17    [StorableConstructor]
     18    private Tank(bool deserializing) : base(deserializing) { }
     19    private Tank(Tank original, Cloner cloner)
     20      : base(original, cloner) {
     21    }
    3422
    35         public Tank()
    36             : base("Tank", "The root of a Robocode Tank program.")
    37         {
    38             this.Prefix = "package Evaluation;" +
    39                           "\r\nimport robocode.*;" +
    40                           "\r\nimport robocode.Robot;" +
    41                           "\r\nimport robocode.util.*;" +
    42                           "\r\nimport static robocode.util.Utils.normalRelativeAngleDegrees;" +
    43                           "\r\nimport java.awt.*;" +
    44                           "\r\n\r\n" +
    45                           "\r\npublic class output extends AdvancedRobot {\r\n";
    46             this.Suffix = "\r\n}";
    47         }
     23    public Tank()
     24      : base("Tank", "The root of a Robocode Tank program.") {
     25      this.Prefix = "package Evaluation;" +
     26                    "\r\nimport robocode.*;" +
     27                    "\r\nimport robocode.Robot;" +
     28                    "\r\nimport robocode.util.*;" +
     29                    "\r\nimport static robocode.util.Utils.normalRelativeAngleDegrees;" +
     30                    "\r\nimport java.awt.*;" +
     31                    "\r\n\r\n" +
     32                    "\r\npublic class output extends AdvancedRobot {\r\n";
     33      this.Suffix = "\r\n}";
     34    }
    4835
    49         public override IDeepCloneable Clone(Cloner cloner)
    50         {
    51             return new Tank(this, cloner);
    52         }
     36    public override IDeepCloneable Clone(Cloner cloner) {
     37      return new Tank(this, cloner);
     38    }
    5339
    54         public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children)
    55         {
    56             string result = "";
    57             foreach (ISymbolicExpressionTreeNode c in children)
    58                 result += "\r\n" + ((CodeNode)c.Symbol).Interpret(c, c.Subtrees);
    59             return this.Prefix + "\r\n" + result + "\r\n" + this.Suffix;
    60         }
     40    public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
     41      string result = "";
     42      foreach (ISymbolicExpressionTreeNode c in children)
     43        result += "\r\n" + ((CodeNode)c.Symbol).Interpret(c, c.Subtrees);
     44      return this.Prefix + "\r\n" + result + "\r\n" + this.Suffix;
    6145    }
     46  }
    6247}
  • branches/Robocode/HeuristicLab.Problems.Robocode/Symbols/Void Methods/Ahead.cs

    r9565 r9630  
    33using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    44
    5 namespace HeuristicLab.Problems.Robocode
    6 {
    7     [StorableClass]
    8     public class Ahead : CodeNode
    9     {
    10         public override int MinimumArity { get { return 1; } }
    11         public override int MaximumArity { get { return 1; } }
     5namespace HeuristicLab.Problems.Robocode {
     6  [StorableClass]
     7  public class Ahead : CodeNode {
     8    public override int MinimumArity { get { return 1; } }
     9    public override int MaximumArity { get { return 1; } }
    1210
    13         [Storable]
    14         public override string Prefix { get; set; }
     11    [Storable]
     12    public override string Prefix { get; set; }
    1513
    16         [Storable]
    17         public override string Suffix { get; set; }
     14    [Storable]
     15    public override string Suffix { get; set; }
    1816
    19         [StorableConstructor]
    20         private Ahead(bool deserializing) : base(deserializing) { }
    21         private Ahead(Ahead original, Cloner cloner)
    22             : base(original, cloner)
    23         {
    24             this.Prefix = "setAhead(";
    25             this.Suffix = ");";
    26         }
     17    [StorableConstructor]
     18    private Ahead(bool deserializing) : base(deserializing) { }
     19    private Ahead(Ahead original, Cloner cloner)
     20      : base(original, cloner) {
     21    }
    2722
    28         public Ahead()
    29             : base("Ahead", "Immediately moves your robot ahead (forward) by distance measured in pixels.")
    30         {
    31             this.Prefix = "setAhead(";
    32             this.Suffix = ");";
    33         }
     23    public Ahead()
     24      : base("Ahead", "Immediately moves your robot ahead (forward) by distance measured in pixels.") {
     25      this.Prefix = "setAhead(";
     26      this.Suffix = ");";
     27    }
    3428
    35         public override IDeepCloneable Clone(Cloner cloner)
    36         {
    37             return new Ahead(this, cloner);
    38         }
     29    public override IDeepCloneable Clone(Cloner cloner) {
     30      return new Ahead(this, cloner);
     31    }
    3932
    40         public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children)
    41         {
    42             var enumerator = children.GetEnumerator();
     33    public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
     34      var enumerator = children.GetEnumerator();
    4335
    44             if (!enumerator.MoveNext()) throw new System.Exception("Ahead was not given a child.");
    45             var symbol = enumerator.Current.Symbol;
     36      if (!enumerator.MoveNext()) throw new System.Exception("Ahead was not given a child.");
     37      var symbol = enumerator.Current.Symbol;
    4638
    47             if (!(symbol is Number || symbol is NumericalOperation || symbol is NumericalExpression))
    48                 throw new System.Exception("Ahead was given a child of type " + symbol.GetType().ToString() +
    49                     ". The expected child must be of type " + typeof(Number).ToString() + " or " +
    50                     typeof(NumericalOperation).ToString() + " or " +
    51                     typeof(NumericalExpression).ToString() + ".");
     39      if (!(symbol is Number || symbol is NumericalOperation || symbol is NumericalExpression))
     40        throw new System.Exception("Ahead was given a child of type " + symbol.GetType().ToString() +
     41            ". The expected child must be of type " + typeof(Number).ToString() + " or " +
     42            typeof(NumericalOperation).ToString() + " or " +
     43            typeof(NumericalExpression).ToString() + ".");
    5244
    53             string result = ((CodeNode)symbol).Interpret(enumerator.Current, enumerator.Current.Subtrees);
    54             if (enumerator.MoveNext()) throw new System.Exception("Ahead was given more than one child.");
     45      string result = ((CodeNode)symbol).Interpret(enumerator.Current, enumerator.Current.Subtrees);
     46      if (enumerator.MoveNext()) throw new System.Exception("Ahead was given more than one child.");
    5547
    56             return this.Prefix + result + this.Suffix;
    57         }
     48      return this.Prefix + result + this.Suffix;
    5849    }
     50  }
    5951}
  • branches/Robocode/HeuristicLab.Problems.Robocode/Symbols/Void Methods/Back.cs

    r9565 r9630  
    33using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    44
    5 namespace HeuristicLab.Problems.Robocode
    6 {
    7     [StorableClass]
    8     public class Back : CodeNode
    9     {
    10         public override int MinimumArity { get { return 1; } }
    11         public override int MaximumArity { get { return 1; } }
     5namespace HeuristicLab.Problems.Robocode {
     6  [StorableClass]
     7  public class Back : CodeNode {
     8    public override int MinimumArity { get { return 1; } }
     9    public override int MaximumArity { get { return 1; } }
    1210
    13         [Storable]
    14         public override string Prefix { get; set; }
     11    [Storable]
     12    public override string Prefix { get; set; }
    1513
    16         [Storable]
    17         public override string Suffix { get; set; }
     14    [Storable]
     15    public override string Suffix { get; set; }
    1816
    19         [StorableConstructor]
    20         private Back(bool deserializing) : base(deserializing) { }
    21         private Back(Back original, Cloner cloner)
    22             : base(original, cloner)
    23         {
    24             this.Prefix = "setBack(";
    25             this.Suffix = ");";
    26         }
     17    [StorableConstructor]
     18    private Back(bool deserializing) : base(deserializing) { }
     19    private Back(Back original, Cloner cloner)
     20      : base(original, cloner) { }
    2721
    28         public Back()
    29             : base("Back", "Immediately moves your robot backward by distance measured in pixels.")
    30         {
    31             this.Prefix = "setBack(";
    32             this.Suffix = ");";
    33         }
     22    public Back()
     23      : base("Back", "Immediately moves your robot backward by distance measured in pixels.") {
     24      this.Prefix = "setBack(";
     25      this.Suffix = ");";
     26    }
    3427
    35         public override IDeepCloneable Clone(Cloner cloner)
    36         {
    37             return new Back(this, cloner);
    38         }
     28    public override IDeepCloneable Clone(Cloner cloner) {
     29      return new Back(this, cloner);
     30    }
    3931
    40         public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children)
    41         {
    42             var enumerator = children.GetEnumerator();
     32    public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
     33      var enumerator = children.GetEnumerator();
    4334
    44             if (!enumerator.MoveNext()) throw new System.Exception("Back was not given a child.");
    45             var symbol = enumerator.Current.Symbol;
     35      if (!enumerator.MoveNext()) throw new System.Exception("Back was not given a child.");
     36      var symbol = enumerator.Current.Symbol;
    4637
    47             if (!(symbol is Number || symbol is NumericalOperation || symbol is NumericalExpression))
    48                 throw new System.Exception("Back was given a child of type " + symbol.GetType().ToString() +
    49                     ". The expected child must be of type " + typeof(Number).ToString() + " or " +
    50                     typeof(NumericalOperation).ToString() + " or " +
    51                     typeof(NumericalExpression).ToString() + ".");
     38      if (!(symbol is Number || symbol is NumericalOperation || symbol is NumericalExpression))
     39        throw new System.Exception("Back was given a child of type " + symbol.GetType().ToString() +
     40            ". The expected child must be of type " + typeof(Number).ToString() + " or " +
     41            typeof(NumericalOperation).ToString() + " or " +
     42            typeof(NumericalExpression).ToString() + ".");
    5243
    53             string result = ((CodeNode)symbol).Interpret(enumerator.Current, enumerator.Current.Subtrees);
    54             if (enumerator.MoveNext()) throw new System.Exception("Back was given more than one child.");
     44      string result = ((CodeNode)symbol).Interpret(enumerator.Current, enumerator.Current.Subtrees);
     45      if (enumerator.MoveNext()) throw new System.Exception("Back was given more than one child.");
    5546
    56             return this.Prefix + result + this.Suffix;
    57         }
     47      return this.Prefix + result + this.Suffix;
    5848    }
     49  }
    5950}
  • branches/Robocode/HeuristicLab.Problems.Robocode/Symbols/Void Methods/Fire.cs

    r9565 r9630  
    33using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    44
    5 namespace HeuristicLab.Problems.Robocode
    6 {
    7     [StorableClass]
    8     public class Fire : CodeNode
    9     {
    10         public override int MinimumArity { get { return 1; } }
    11         public override int MaximumArity { get { return 1; } }
     5namespace HeuristicLab.Problems.Robocode {
     6  [StorableClass]
     7  public class Fire : CodeNode {
     8    public override int MinimumArity { get { return 1; } }
     9    public override int MaximumArity { get { return 1; } }
    1210
    13         [Storable]
    14         public override string Prefix { get; set; }
     11    [Storable]
     12    public override string Prefix { get; set; }
    1513
    16         [Storable]
    17         public override string Suffix { get; set; }
     14    [Storable]
     15    public override string Suffix { get; set; }
    1816
    19         [StorableConstructor]
    20         private Fire(bool deserializing) : base(deserializing) { }
    21         private Fire(Fire original, Cloner cloner)
    22             : base(original, cloner)
    23         {
    24             this.Prefix = "setFire(";
    25             this.Suffix = ");";
    26         }
     17    [StorableConstructor]
     18    private Fire(bool deserializing) : base(deserializing) { }
     19    private Fire(Fire original, Cloner cloner)
     20      : base(original, cloner) { }
    2721
    28         public Fire()
    29             : base("Fire", "Immediately fires a bullet.")
    30         {
    31             this.Prefix = "setFire(";
    32             this.Suffix = ")";
    33         }
     22    public Fire()
     23      : base("Fire", "Immediately fires a bullet.") {
     24      this.Prefix = "setFire(";
     25      this.Suffix = ");";
     26    }
    3427
    35         public override IDeepCloneable Clone(Cloner cloner)
    36         {
    37             return new Fire(this, cloner);
    38         }
     28    public override IDeepCloneable Clone(Cloner cloner) {
     29      return new Fire(this, cloner);
     30    }
    3931
    40         public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children)
    41         {
    42             var enumerator = children.GetEnumerator();
     32    public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
     33      var enumerator = children.GetEnumerator();
    4334
    44             if (!enumerator.MoveNext()) throw new System.Exception("Fire was not given a child.");
    45             var symbol = enumerator.Current.Symbol;
     35      if (!enumerator.MoveNext()) throw new System.Exception("Fire was not given a child.");
     36      var symbol = enumerator.Current.Symbol;
    4637
    47             if (!(symbol is ShotPower))
    48                 throw new System.Exception("Fire was given a child of type " + symbol.GetType().ToString() +
    49                     ". The expected child must be of type " + typeof(ShotPower).ToString() + ".");
     38      if (!(symbol is ShotPower))
     39        throw new System.Exception("Fire was given a child of type " + symbol.GetType().ToString() +
     40            ". The expected child must be of type " + typeof(ShotPower).ToString() + ".");
    5041
    51             string result = ((CodeNode)symbol).Interpret(enumerator.Current, enumerator.Current.Subtrees);
    52             if (enumerator.MoveNext()) throw new System.Exception("Fire was given more than one child.");
     42      string result = ((CodeNode)symbol).Interpret(enumerator.Current, enumerator.Current.Subtrees);
     43      if (enumerator.MoveNext()) throw new System.Exception("Fire was given more than one child.");
    5344
    54             return this.Prefix + result + this.Suffix;
    55         }
     45      return this.Prefix + result + this.Suffix;
    5646    }
     47  }
    5748}
  • branches/Robocode/HeuristicLab.Problems.Robocode/Symbols/Void Methods/TurnGunLeft.cs

    r9565 r9630  
    33using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    44
    5 namespace HeuristicLab.Problems.Robocode
    6 {
    7     [StorableClass]
    8     public class TurnGunLeft : CodeNode
    9     {
    10         public override int MinimumArity { get { return 1; } }
    11         public override int MaximumArity { get { return 1; } }
     5namespace HeuristicLab.Problems.Robocode {
     6  [StorableClass]
     7  public class TurnGunLeft : CodeNode {
     8    public override int MinimumArity { get { return 1; } }
     9    public override int MaximumArity { get { return 1; } }
    1210
    13         [Storable]
    14         public override string Prefix { get; set; }
     11    [Storable]
     12    public override string Prefix { get; set; }
    1513
    16         [Storable]
    17         public override string Suffix { get; set; }
     14    [Storable]
     15    public override string Suffix { get; set; }
    1816
    19         [StorableConstructor]
    20         private TurnGunLeft(bool deserializing) : base(deserializing) { }
    21         private TurnGunLeft(TurnGunLeft original, Cloner cloner)
    22             : base(original, cloner)
    23         {
    24             this.Prefix = "setTurnGunLeft(";
    25             this.Suffix = ");";
    26         }
     17    [StorableConstructor]
     18    private TurnGunLeft(bool deserializing) : base(deserializing) { }
     19    private TurnGunLeft(TurnGunLeft original, Cloner cloner)
     20      : base(original, cloner) {
     21    }
    2722
    28         public TurnGunLeft()
    29             : base("TurnGunLeft", "Immediately turns the robot's gun to the left by degrees.")
    30         {
    31             this.Prefix = "setTurnGunLeft(";
    32             this.Suffix = ");";
    33         }
     23    public TurnGunLeft()
     24      : base("TurnGunLeft", "Immediately turns the robot's gun to the left by degrees.") {
     25      this.Prefix = "setTurnGunLeft(";
     26      this.Suffix = ");";
     27    }
    3428
    35         public override IDeepCloneable Clone(Cloner cloner)
    36         {
    37             return new TurnGunLeft(this, cloner);
    38         }
     29    public override IDeepCloneable Clone(Cloner cloner) {
     30      return new TurnGunLeft(this, cloner);
     31    }
    3932
    40         public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children)
    41         {
    42             var enumerator = children.GetEnumerator();
     33    public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
     34      var enumerator = children.GetEnumerator();
    4335
    44             if (!enumerator.MoveNext()) throw new System.Exception("TurnGunLeft was not given a child.");
    45             var symbol = enumerator.Current.Symbol;
     36      if (!enumerator.MoveNext()) throw new System.Exception("TurnGunLeft was not given a child.");
     37      var symbol = enumerator.Current.Symbol;
    4638
    47             if (!(symbol is Number || symbol is NumericalOperation || symbol is NumericalExpression))
    48                 throw new System.Exception("TurnGunLeft was given a child of type " + symbol.GetType().ToString() +
    49                     ". The expected child must be of type " + typeof(Number).ToString() + " or " +
    50                     typeof(NumericalOperation).ToString() + " or " +
    51                     typeof(NumericalExpression).ToString() + ".");
     39      if (!(symbol is Number || symbol is NumericalOperation || symbol is NumericalExpression))
     40        throw new System.Exception("TurnGunLeft was given a child of type " + symbol.GetType().ToString() +
     41            ". The expected child must be of type " + typeof(Number).ToString() + " or " +
     42            typeof(NumericalOperation).ToString() + " or " +
     43            typeof(NumericalExpression).ToString() + ".");
    5244
    53             string result = ((CodeNode)symbol).Interpret(enumerator.Current, enumerator.Current.Subtrees);
    54             if (enumerator.MoveNext()) throw new System.Exception("TurnGunLeft was given more than one child.");
     45      string result = ((CodeNode)symbol).Interpret(enumerator.Current, enumerator.Current.Subtrees);
     46      if (enumerator.MoveNext()) throw new System.Exception("TurnGunLeft was given more than one child.");
    5547
    56             return this.Prefix + result + this.Suffix;
    57         }
     48      return this.Prefix + result + this.Suffix;
    5849    }
     50  }
    5951}
  • branches/Robocode/HeuristicLab.Problems.Robocode/Symbols/Void Methods/TurnGunRight.cs

    r9565 r9630  
    33using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    44
    5 namespace HeuristicLab.Problems.Robocode
    6 {
    7     [StorableClass]
    8     public class TurnGunRight : CodeNode
    9     {
    10         public override int MinimumArity { get { return 1; } }
    11         public override int MaximumArity { get { return 1; } }
     5namespace HeuristicLab.Problems.Robocode {
     6  [StorableClass]
     7  public class TurnGunRight : CodeNode {
     8    public override int MinimumArity { get { return 1; } }
     9    public override int MaximumArity { get { return 1; } }
    1210
    13         [Storable]
    14         public override string Prefix { get; set; }
     11    [Storable]
     12    public override string Prefix { get; set; }
    1513
    16         [Storable]
    17         public override string Suffix { get; set; }
     14    [Storable]
     15    public override string Suffix { get; set; }
    1816
    19         [StorableConstructor]
    20         private TurnGunRight(bool deserializing) : base(deserializing) { }
    21         private TurnGunRight(TurnGunRight original, Cloner cloner)
    22             : base(original, cloner)
    23         {
    24             this.Prefix = "setTurnGunRight(";
    25             this.Suffix = ");";
    26         }
     17    [StorableConstructor]
     18    private TurnGunRight(bool deserializing) : base(deserializing) { }
     19    private TurnGunRight(TurnGunRight original, Cloner cloner)
     20      : base(original, cloner) {
    2721
    28         public TurnGunRight()
    29             : base("TurnGunRight", "Immediately turns the robot's gun to the right by degrees.")
    30         {
    31             this.Prefix = "setTurnGunRight(";
    32             this.Suffix = ");";
    33         }
     22    }
    3423
    35         public override IDeepCloneable Clone(Cloner cloner)
    36         {
    37             return new TurnGunRight(this, cloner);
    38         }
     24    public TurnGunRight()
     25      : base("TurnGunRight", "Immediately turns the robot's gun to the right by degrees.") {
     26      this.Prefix = "setTurnGunRight(";
     27      this.Suffix = ");";
     28    }
    3929
    40         public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children)
    41         {
    42             var enumerator = children.GetEnumerator();
     30    public override IDeepCloneable Clone(Cloner cloner) {
     31      return new TurnGunRight(this, cloner);
     32    }
    4333
    44             if (!enumerator.MoveNext()) throw new System.Exception("TurnGunRight was not given a child.");
    45             var symbol = enumerator.Current.Symbol;
     34    public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
     35      var enumerator = children.GetEnumerator();
    4636
    47             if (!(symbol is Number || symbol is NumericalOperation || symbol is NumericalExpression))
    48                 throw new System.Exception("TurnGunRight was given a child of type " + symbol.GetType().ToString() +
    49                     ". The expected child must be of type " + typeof(Number).ToString() + " or " +
    50                     typeof(NumericalOperation).ToString() + " or " +
    51                     typeof(NumericalExpression).ToString() + ".");
     37      if (!enumerator.MoveNext()) throw new System.Exception("TurnGunRight was not given a child.");
     38      var symbol = enumerator.Current.Symbol;
    5239
    53             string result = ((CodeNode)symbol).Interpret(enumerator.Current, enumerator.Current.Subtrees);
    54             if (enumerator.MoveNext()) throw new System.Exception("TurnGunRight was given more than one child.");
     40      if (!(symbol is Number || symbol is NumericalOperation || symbol is NumericalExpression))
     41        throw new System.Exception("TurnGunRight was given a child of type " + symbol.GetType().ToString() +
     42            ". The expected child must be of type " + typeof(Number).ToString() + " or " +
     43            typeof(NumericalOperation).ToString() + " or " +
     44            typeof(NumericalExpression).ToString() + ".");
    5545
    56             return this.Prefix + result + this.Suffix;
    57         }
     46      string result = ((CodeNode)symbol).Interpret(enumerator.Current, enumerator.Current.Subtrees);
     47      if (enumerator.MoveNext()) throw new System.Exception("TurnGunRight was given more than one child.");
     48
     49      return this.Prefix + result + this.Suffix;
    5850    }
     51  }
    5952}
  • branches/Robocode/HeuristicLab.Problems.Robocode/Symbols/Void Methods/TurnLeft.cs

    r9565 r9630  
    33using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    44
    5 namespace HeuristicLab.Problems.Robocode
    6 {
    7     [StorableClass]
    8     public class TurnLeft : CodeNode
    9     {
    10         public override int MinimumArity { get { return 1; } }
    11         public override int MaximumArity { get { return 1; } }
     5namespace HeuristicLab.Problems.Robocode {
     6  [StorableClass]
     7  public class TurnLeft : CodeNode {
     8    public override int MinimumArity { get { return 1; } }
     9    public override int MaximumArity { get { return 1; } }
    1210
    13         [Storable]
    14         public override string Prefix { get; set; }
     11    [Storable]
     12    public override string Prefix { get; set; }
    1513
    16         [Storable]
    17         public override string Suffix { get; set; }
     14    [Storable]
     15    public override string Suffix { get; set; }
    1816
    19         [StorableConstructor]
    20         private TurnLeft(bool deserializing) : base(deserializing) { }
    21         private TurnLeft(TurnLeft original, Cloner cloner)
    22             : base(original, cloner)
    23         {
    24             this.Prefix = "setTurnLeft(";
    25             this.Suffix = ");";
    26         }
     17    [StorableConstructor]
     18    private TurnLeft(bool deserializing) : base(deserializing) { }
     19    private TurnLeft(TurnLeft original, Cloner cloner)
     20      : base(original, cloner) {
     21    }
    2722
    28         public TurnLeft()
    29             : base("TurnLeft", "Immediately turns the robot's body to the left by degrees.")
    30         {
    31             this.Prefix = "setTurnLeft(";
    32             this.Suffix = ");";
    33         }
     23    public TurnLeft()
     24      : base("TurnLeft", "Immediately turns the robot's body to the left by degrees.") {
     25      this.Prefix = "setTurnLeft(";
     26      this.Suffix = ");";
     27    }
    3428
    35         public override IDeepCloneable Clone(Cloner cloner)
    36         {
    37             return new TurnLeft(this, cloner);
    38         }
     29    public override IDeepCloneable Clone(Cloner cloner) {
     30      return new TurnLeft(this, cloner);
     31    }
    3932
    40         public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children)
    41         {
    42             var enumerator = children.GetEnumerator();
     33    public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
     34      var enumerator = children.GetEnumerator();
    4335
    44             if (!enumerator.MoveNext()) throw new System.Exception("TurnLeft was not given a child.");
    45             var symbol = enumerator.Current.Symbol;
     36      if (!enumerator.MoveNext()) throw new System.Exception("TurnLeft was not given a child.");
     37      var symbol = enumerator.Current.Symbol;
    4638
    47             if (!(symbol is Number || symbol is NumericalOperation || symbol is NumericalExpression))
    48                 throw new System.Exception("TurnLeft was given a child of type " + symbol.GetType().ToString() +
    49                     ". The expected child must be of type " + typeof(Number).ToString() + " or " +
    50                     typeof(NumericalOperation).ToString() + " or " +
    51                     typeof(NumericalExpression).ToString() + ".");
     39      if (!(symbol is Number || symbol is NumericalOperation || symbol is NumericalExpression))
     40        throw new System.Exception("TurnLeft was given a child of type " + symbol.GetType().ToString() +
     41            ". The expected child must be of type " + typeof(Number).ToString() + " or " +
     42            typeof(NumericalOperation).ToString() + " or " +
     43            typeof(NumericalExpression).ToString() + ".");
    5244
    53             string result = ((CodeNode)symbol).Interpret(enumerator.Current, enumerator.Current.Subtrees);
    54             if (enumerator.MoveNext()) throw new System.Exception("TurnLeft was given more than one child.");
     45      string result = ((CodeNode)symbol).Interpret(enumerator.Current, enumerator.Current.Subtrees);
     46      if (enumerator.MoveNext()) throw new System.Exception("TurnLeft was given more than one child.");
    5547
    56             return this.Prefix + result + this.Suffix;
    57         }
     48      return this.Prefix + result + this.Suffix;
    5849    }
     50  }
    5951}
  • branches/Robocode/HeuristicLab.Problems.Robocode/Symbols/Void Methods/TurnRadarLeft.cs

    r9565 r9630  
    33using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    44
    5 namespace HeuristicLab.Problems.Robocode
    6 {
    7     [StorableClass]
    8     public class TurnRadarLeft : CodeNode
    9     {
    10         public override int MinimumArity { get { return 1; } }
    11         public override int MaximumArity { get { return 1; } }
     5namespace HeuristicLab.Problems.Robocode {
     6  [StorableClass]
     7  public class TurnRadarLeft : CodeNode {
     8    public override int MinimumArity { get { return 1; } }
     9    public override int MaximumArity { get { return 1; } }
    1210
    13         [Storable]
    14         public override string Prefix { get; set; }
     11    [Storable]
     12    public override string Prefix { get; set; }
    1513
    16         [Storable]
    17         public override string Suffix { get; set; }
     14    [Storable]
     15    public override string Suffix { get; set; }
    1816
    19         [StorableConstructor]
    20         private TurnRadarLeft(bool deserializing) : base(deserializing) { }
    21         private TurnRadarLeft(TurnRadarLeft original, Cloner cloner)
    22             : base(original, cloner)
    23         {
    24             this.Prefix = "setTurnRadarLeft(";
    25             this.Suffix = ");";
    26         }
     17    [StorableConstructor]
     18    private TurnRadarLeft(bool deserializing) : base(deserializing) { }
     19    private TurnRadarLeft(TurnRadarLeft original, Cloner cloner)
     20      : base(original, cloner) {
     21    }
    2722
    28         public TurnRadarLeft()
    29             : base("TurnRadarLeft", "Immediately turns the robot's radar to the left by degrees.")
    30         {
    31             this.Prefix = "setTurnRadarLeft(";
    32             this.Suffix = ");";
    33         }
     23    public TurnRadarLeft()
     24      : base("TurnRadarLeft", "Immediately turns the robot's radar to the left by degrees.") {
     25      this.Prefix = "setTurnRadarLeft(";
     26      this.Suffix = ");";
     27    }
    3428
    35         public override IDeepCloneable Clone(Cloner cloner)
    36         {
    37             return new TurnRadarLeft(this, cloner);
    38         }
     29    public override IDeepCloneable Clone(Cloner cloner) {
     30      return new TurnRadarLeft(this, cloner);
     31    }
    3932
    40         public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children)
    41         {
    42             var enumerator = children.GetEnumerator();
     33    public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
     34      var enumerator = children.GetEnumerator();
    4335
    44             if (!enumerator.MoveNext()) throw new System.Exception("TurnRadarLeft was not given a child.");
    45             var symbol = enumerator.Current.Symbol;
     36      if (!enumerator.MoveNext()) throw new System.Exception("TurnRadarLeft was not given a child.");
     37      var symbol = enumerator.Current.Symbol;
    4638
    47             if (!(symbol is Number || symbol is NumericalOperation || symbol is NumericalExpression))
    48                 throw new System.Exception("TurnRadarLeft was given a child of type " + symbol.GetType().ToString() +
    49                     ". The expected child must be of type " + typeof(Number).ToString() + " or " +
    50                     typeof(NumericalOperation).ToString() + " or " +
    51                     typeof(NumericalExpression).ToString() + ".");
     39      if (!(symbol is Number || symbol is NumericalOperation || symbol is NumericalExpression))
     40        throw new System.Exception("TurnRadarLeft was given a child of type " + symbol.GetType().ToString() +
     41            ". The expected child must be of type " + typeof(Number).ToString() + " or " +
     42            typeof(NumericalOperation).ToString() + " or " +
     43            typeof(NumericalExpression).ToString() + ".");
    5244
    53             string result = ((CodeNode)symbol).Interpret(enumerator.Current, enumerator.Current.Subtrees);
    54             if (enumerator.MoveNext()) throw new System.Exception("TurnRadarLeft was given more than one child.");
     45      string result = ((CodeNode)symbol).Interpret(enumerator.Current, enumerator.Current.Subtrees);
     46      if (enumerator.MoveNext()) throw new System.Exception("TurnRadarLeft was given more than one child.");
    5547
    56             return this.Prefix + result + this.Suffix;
    57         }
     48      return this.Prefix + result + this.Suffix;
    5849    }
     50  }
    5951}
  • branches/Robocode/HeuristicLab.Problems.Robocode/Symbols/Void Methods/TurnRadarRight.cs

    r9565 r9630  
    33using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    44
    5 namespace HeuristicLab.Problems.Robocode
    6 {
    7     [StorableClass]
    8     public class TurnRadarRight : CodeNode
    9     {
    10         public override int MinimumArity { get { return 1; } }
    11         public override int MaximumArity { get { return 1; } }
     5namespace HeuristicLab.Problems.Robocode {
     6  [StorableClass]
     7  public class TurnRadarRight : CodeNode {
     8    public override int MinimumArity { get { return 1; } }
     9    public override int MaximumArity { get { return 1; } }
    1210
    13         [Storable]
    14         public override string Prefix { get; set; }
     11    [Storable]
     12    public override string Prefix { get; set; }
    1513
    16         [Storable]
    17         public override string Suffix { get; set; }
     14    [Storable]
     15    public override string Suffix { get; set; }
    1816
    19         [StorableConstructor]
    20         private TurnRadarRight(bool deserializing) : base(deserializing) { }
    21         private TurnRadarRight(TurnRadarRight original, Cloner cloner)
    22             : base(original, cloner)
    23         {
    24             this.Prefix = "setTurnRadarRight(";
    25             this.Suffix = ");";
    26         }
     17    [StorableConstructor]
     18    private TurnRadarRight(bool deserializing) : base(deserializing) { }
     19    private TurnRadarRight(TurnRadarRight original, Cloner cloner)
     20      : base(original, cloner) {
    2721
    28         public TurnRadarRight()
    29             : base("TurnRadarRight", "Immediately turns the robot's radar to the right by degrees.")
    30         {
    31             this.Prefix = "setTurnRadarRight(";
    32             this.Suffix = ");";
    33         }
     22    }
    3423
    35         public override IDeepCloneable Clone(Cloner cloner)
    36         {
    37             return new TurnRadarRight(this, cloner);
    38         }
     24    public TurnRadarRight()
     25      : base("TurnRadarRight", "Immediately turns the robot's radar to the right by degrees.") {
     26      this.Prefix = "setTurnRadarRight(";
     27      this.Suffix = ");";
     28    }
    3929
    40         public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children)
    41         {
    42             var enumerator = children.GetEnumerator();
     30    public override IDeepCloneable Clone(Cloner cloner) {
     31      return new TurnRadarRight(this, cloner);
     32    }
    4333
    44             if (!enumerator.MoveNext()) throw new System.Exception("TurnRadarRight was not given a child.");
    45             var symbol = enumerator.Current.Symbol;
     34    public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
     35      var enumerator = children.GetEnumerator();
    4636
    47             if (!(symbol is Number || symbol is NumericalOperation || symbol is NumericalExpression))
    48                 throw new System.Exception("TurnRadarRight was given a child of type " + symbol.GetType().ToString() +
    49                     ". The expected child must be of type " + typeof(Number).ToString() + " or " +
    50                     typeof(NumericalOperation).ToString() + " or " +
    51                     typeof(NumericalExpression).ToString() + ".");
     37      if (!enumerator.MoveNext()) throw new System.Exception("TurnRadarRight was not given a child.");
     38      var symbol = enumerator.Current.Symbol;
    5239
    53             string result = ((CodeNode)symbol).Interpret(enumerator.Current, enumerator.Current.Subtrees);
    54             if (enumerator.MoveNext()) throw new System.Exception("TurnRadarRight was given more than one child.");
     40      if (!(symbol is Number || symbol is NumericalOperation || symbol is NumericalExpression))
     41        throw new System.Exception("TurnRadarRight was given a child of type " + symbol.GetType().ToString() +
     42            ". The expected child must be of type " + typeof(Number).ToString() + " or " +
     43            typeof(NumericalOperation).ToString() + " or " +
     44            typeof(NumericalExpression).ToString() + ".");
    5545
    56             return this.Prefix + result + this.Suffix;
    57         }
     46      string result = ((CodeNode)symbol).Interpret(enumerator.Current, enumerator.Current.Subtrees);
     47      if (enumerator.MoveNext()) throw new System.Exception("TurnRadarRight was given more than one child.");
     48
     49      return this.Prefix + result + this.Suffix;
    5850    }
     51  }
    5952}
  • branches/Robocode/HeuristicLab.Problems.Robocode/Symbols/Void Methods/TurnRight.cs

    r9565 r9630  
    33using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    44
    5 namespace HeuristicLab.Problems.Robocode
    6 {
    7     [StorableClass]
    8     public class TurnRight : CodeNode
    9     {
    10         public override int MinimumArity { get { return 1; } }
    11         public override int MaximumArity { get { return 1; } }
     5namespace HeuristicLab.Problems.Robocode {
     6  [StorableClass]
     7  public class TurnRight : CodeNode {
     8    public override int MinimumArity { get { return 1; } }
     9    public override int MaximumArity { get { return 1; } }
    1210
    13         [Storable]
    14         public override string Prefix { get; set; }
     11    [Storable]
     12    public override string Prefix { get; set; }
    1513
    16         [Storable]
    17         public override string Suffix { get; set; }
     14    [Storable]
     15    public override string Suffix { get; set; }
    1816
    19         [StorableConstructor]
    20         private TurnRight(bool deserializing) : base(deserializing) { }
    21         private TurnRight(TurnRight original, Cloner cloner)
    22             : base(original, cloner)
    23         {
    24             this.Prefix = "setTurnRight(";
    25             this.Suffix = ");";
    26         }
     17    [StorableConstructor]
     18    private TurnRight(bool deserializing) : base(deserializing) { }
     19    private TurnRight(TurnRight original, Cloner cloner)
     20      : base(original, cloner) {
    2721
    28         public TurnRight()
    29             : base("TurnRight", "Immediately turns the robot's body to the right by degrees.")
    30         {
    31             this.Prefix = "setTurnRight(";
    32             this.Suffix = ");";
    33         }
     22    }
    3423
    35         public override IDeepCloneable Clone(Cloner cloner)
    36         {
    37             return new TurnRight(this, cloner);
    38         }
     24    public TurnRight()
     25      : base("TurnRight", "Immediately turns the robot's body to the right by degrees.") {
     26      this.Prefix = "setTurnRight(";
     27      this.Suffix = ");";
     28    }
    3929
    40         public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children)
    41         {
    42             var enumerator = children.GetEnumerator();
     30    public override IDeepCloneable Clone(Cloner cloner) {
     31      return new TurnRight(this, cloner);
     32    }
    4333
    44             if (!enumerator.MoveNext()) throw new System.Exception("TurnRight was not given a child.");
    45             var symbol = enumerator.Current.Symbol;
     34    public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
     35      var enumerator = children.GetEnumerator();
    4636
    47             if (!(symbol is Number || symbol is NumericalOperation || symbol is NumericalExpression))
    48                 throw new System.Exception("TurnRight was given a child of type " + symbol.GetType().ToString() +
    49                     ". The expected child must be of type " + typeof(Number).ToString() + " or " +
    50                     typeof(NumericalOperation).ToString() + " or " +
    51                     typeof(NumericalExpression).ToString() + ".");
     37      if (!enumerator.MoveNext()) throw new System.Exception("TurnRight was not given a child.");
     38      var symbol = enumerator.Current.Symbol;
    5239
    53             string result = ((CodeNode)symbol).Interpret(enumerator.Current, enumerator.Current.Subtrees);
    54             if (enumerator.MoveNext()) throw new System.Exception("TurnRight was given more than one child.");
     40      if (!(symbol is Number || symbol is NumericalOperation || symbol is NumericalExpression))
     41        throw new System.Exception("TurnRight was given a child of type " + symbol.GetType().ToString() +
     42            ". The expected child must be of type " + typeof(Number).ToString() + " or " +
     43            typeof(NumericalOperation).ToString() + " or " +
     44            typeof(NumericalExpression).ToString() + ".");
    5545
    56             return this.Prefix + result + this.Suffix;
    57         }
     46      string result = ((CodeNode)symbol).Interpret(enumerator.Current, enumerator.Current.Subtrees);
     47      if (enumerator.MoveNext()) throw new System.Exception("TurnRight was given more than one child.");
     48
     49      return this.Prefix + result + this.Suffix;
    5850    }
     51  }
    5952}
Note: See TracChangeset for help on using the changeset viewer.