Last change
on this file since 9609 was
9565,
checked in by melkaref, 11 years ago
|
Robocode Plugin code without Mutation Operators
|
File size:
1.8 KB
|
Rev | Line | |
---|
[9565] | 1 | using HeuristicLab.Common;
|
---|
| 2 | using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
|
---|
| 3 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
| 4 |
|
---|
| 5 | namespace HeuristicLab.Problems.Robocode
|
---|
| 6 | {
|
---|
| 7 | [StorableClass]
|
---|
| 8 | public class Run : CodeNode
|
---|
| 9 | {
|
---|
| 10 | public override int MinimumArity { get { return 2; } }
|
---|
| 11 | public override int MaximumArity { get { return 10; } }
|
---|
| 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 Run(bool deserializing) : base(deserializing) { }
|
---|
| 21 | private Run(Run original, Cloner cloner)
|
---|
| 22 | : base(original, cloner)
|
---|
| 23 | {
|
---|
| 24 | this.Prefix = "\r\npublic void run() {\r\n\tsetAdjustGunForRobotTurn(true);\r\n\tturnRadarRightRadians(Double.POSITIVE_INFINITY);";
|
---|
| 25 | this.Suffix = "\r\nexecute();\r\n}\r\n";
|
---|
| 26 | }
|
---|
| 27 |
|
---|
| 28 | public Run()
|
---|
| 29 | : base("Run", "The main method in every robot.")
|
---|
| 30 | {
|
---|
| 31 | this.Prefix = "\r\npublic void run() {\r\n\tsetAdjustGunForRobotTurn(true);\r\n\tturnRadarRightRadians(Double.POSITIVE_INFINITY);";
|
---|
| 32 | this.Suffix = "\r\nexecute();\r\n}\r\n";
|
---|
| 33 | }
|
---|
| 34 |
|
---|
| 35 | public override IDeepCloneable Clone(Cloner cloner)
|
---|
| 36 | {
|
---|
| 37 | return new Run(this, cloner);
|
---|
| 38 | }
|
---|
| 39 |
|
---|
| 40 | public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children)
|
---|
| 41 | {
|
---|
| 42 | string result = "";
|
---|
| 43 | foreach (ISymbolicExpressionTreeNode c in children)
|
---|
| 44 | result += "\r\n" + ((CodeNode)c.Symbol).Interpret(c, c.Subtrees);
|
---|
| 45 | return this.Prefix + "\r\n" + result + "\r\n" + this.Suffix;
|
---|
| 46 | }
|
---|
| 47 | }
|
---|
| 48 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.