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