Free cookie consent management tool by TermsFeed Policy Generator

source: branches/Robocode/HeuristicLab.Problems.Robocode/Symbols/Tank.cs @ 12394

Last change on this file since 12394 was 9630, checked in by ascheibe, 12 years ago

#2069 fixed cloning constructors and formatting

File size: 1.7 KB
RevLine 
[9565]1using HeuristicLab.Common;
2using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
3using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
4
[9630]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; } }
[9565]10
[9630]11    [Storable]
12    public override string Prefix { get; set; }
[9565]13
[9630]14    [Storable]
15    public override string Suffix { get; set; }
[9565]16
[9630]17    [StorableConstructor]
18    private Tank(bool deserializing) : base(deserializing) { }
19    private Tank(Tank original, Cloner cloner)
20      : base(original, cloner) {
21    }
[9565]22
[9630]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    }
[9565]35
[9630]36    public override IDeepCloneable Clone(Cloner cloner) {
37      return new Tank(this, cloner);
38    }
[9565]39
[9630]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;
[9565]45    }
[9630]46  }
[9565]47}
Note: See TracBrowser for help on using the repository browser.