Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 12961 was 9630, checked in by ascheibe, 11 years ago

#2069 fixed cloning constructors and formatting

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