Free cookie consent management tool by TermsFeed Policy Generator

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

#2069 fixed cloning constructors and formatting

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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}
Note: See TracChangeset for help on using the changeset viewer.