Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 9598 was 9565, checked in by melkaref, 12 years ago

Robocode Plugin code without Mutation Operators

File size: 2.5 KB
RevLine 
[9565]1using HeuristicLab.Common;
2using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
3using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
4
5namespace 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; } }
12
13        [Storable]
14        public override string Prefix { get; set; }
15
16        [Storable]
17        public override string Suffix { get; set; }
18
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        }
34
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        }
48
49        public override IDeepCloneable Clone(Cloner cloner)
50        {
51            return new Tank(this, cloner);
52        }
53
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        }
61    }
62}
Note: See TracBrowser for help on using the repository browser.