1 | using HeuristicLab.Common;
|
---|
2 | using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
|
---|
3 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
4 |
|
---|
5 | namespace 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 | } |
---|