Changeset 13013
- Timestamp:
- 10/15/15 16:39:12 (9 years ago)
- Location:
- branches/Robocode.TrunkInt
- Files:
-
- 75 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode.Views/3.3/BattleRunnerDialog.Designer.cs
r13011 r13013 19 19 */ 20 20 #endregion 21 namespace HeuristicLab.Problems.GeneticProgramming.Views.Robo Code {21 namespace HeuristicLab.Problems.GeneticProgramming.Views.Robocode { 22 22 partial class BattleRunnerDialog { 23 23 /// <summary> -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode.Views/3.3/BattleRunnerDialog.cs
r13011 r13013 23 23 using System.Windows.Forms; 24 24 using HeuristicLab.Common; 25 using HeuristicLab.Problems.GeneticProgramming.Robo Code;25 using HeuristicLab.Problems.GeneticProgramming.Robocode; 26 26 27 namespace HeuristicLab.Problems.GeneticProgramming.Views.Robo Code {27 namespace HeuristicLab.Problems.GeneticProgramming.Views.Robocode { 28 28 public partial class BattleRunnerDialog : Form { 29 29 public int NrOfRounds { -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode.Views/3.3/CodeNodeView.Designer.cs
r13011 r13013 19 19 */ 20 20 #endregion 21 namespace HeuristicLab.Problems.GeneticProgramming.Views.Robo Code {21 namespace HeuristicLab.Problems.GeneticProgramming.Views.Robocode { 22 22 partial class CodeNodeView { 23 23 /// <summary> -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode.Views/3.3/CodeNodeView.cs
r13011 r13013 23 23 using HeuristicLab.Core.Views; 24 24 using HeuristicLab.MainForm; 25 using HeuristicLab.Problems.GeneticProgramming.Robo Code;25 using HeuristicLab.Problems.GeneticProgramming.Robocode; 26 26 27 namespace HeuristicLab.Problems.GeneticProgramming.Views.Robo Code {27 namespace HeuristicLab.Problems.GeneticProgramming.Views.Robocode { 28 28 [View("CodeNode View")] 29 29 [Content(typeof(CodeNode), IsDefaultView = true)] -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode.Views/3.3/EnemyCollectionView.Designer.cs
r13011 r13013 21 21 22 22 23 namespace HeuristicLab.Problems.GeneticProgramming.Views.Robo Code {23 namespace HeuristicLab.Problems.GeneticProgramming.Views.Robocode { 24 24 partial class EnemyCollectionView { 25 25 /// <summary> -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode.Views/3.3/EnemyCollectionView.cs
r13011 r13013 20 20 #endregion 21 21 22 using System.Windows.Forms; 22 using HeuristicLab.Core.Views; 23 using HeuristicLab.Data; 23 24 using HeuristicLab.MainForm; 24 using HeuristicLab.Problems.GeneticProgramming.Robo Code;25 using HeuristicLab.Problems.GeneticProgramming.Robocode; 25 26 26 namespace HeuristicLab.Problems.GeneticProgramming.Views.Robo Code {27 namespace HeuristicLab.Problems.GeneticProgramming.Views.Robocode { 27 28 [View("EnemyCollection View")] 28 29 [Content(typeof(EnemyCollection), true)] 29 public partial class EnemyCollectionView : C ore.Views.CheckedItemListView<HeuristicLab.Data.StringValue> {30 public partial class EnemyCollectionView : CheckedItemListView<StringValue> { 30 31 public new EnemyCollection Content { 31 32 get { return (EnemyCollection)base.Content; } -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode.Views/3.3/Plugin.cs.frame
r13011 r13013 27 27 using HeuristicLab.PluginInfrastructure; 28 28 29 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code.Views29 namespace HeuristicLab.Problems.GeneticProgramming.Robocode.Views 30 30 { 31 31 [Plugin("HeuristicLab.Problems.Robocode.Views", "The Robocode problem for genetic programming.", "3.3.9.$WCREV$")] -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode.Views/3.3/SolutionCodeView.Designer.cs
r13011 r13013 19 19 */ 20 20 #endregion 21 namespace HeuristicLab.Problems.GeneticProgramming.Views.Robo Code {21 namespace HeuristicLab.Problems.GeneticProgramming.Views.Robocode { 22 22 partial class SolutionCodeView { 23 23 /// <summary> -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode.Views/3.3/SolutionCodeView.cs
r13011 r13013 25 25 using HeuristicLab.Core.Views; 26 26 using HeuristicLab.MainForm; 27 using HeuristicLab.Problems.GeneticProgramming.Robo Code;27 using HeuristicLab.Problems.GeneticProgramming.Robocode; 28 28 29 namespace HeuristicLab.Problems.GeneticProgramming.Views.Robo Code {29 namespace HeuristicLab.Problems.GeneticProgramming.Views.Robocode { 30 30 [View("Robocode Tank Code View")] 31 31 [Content(typeof(Solution), IsDefaultView = true)] … … 45 45 protected override void OnContentChanged() { 46 46 base.OnContentChanged(); 47 if (Content == null) { 48 programCode.Text = string.Empty; 49 } else { 50 programCode.Text = Interpreter.InterpretProgramTree(Content.Tree.Root, programName); 51 } 47 programCode.Text = Content == null ? string.Empty : Interpreter.InterpretProgramTree(Content.Tree.Root, programName); 52 48 } 53 49 -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode.Views/3.3/SolutionProgramView.Designer.cs
r13011 r13013 22 22 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views; 23 23 24 namespace HeuristicLab.Problems.GeneticProgramming.Views.Robo Code {24 namespace HeuristicLab.Problems.GeneticProgramming.Views.Robocode { 25 25 partial class SolutionProgramView { 26 26 private void InitializeComponent() { -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode.Views/3.3/SolutionProgramView.cs
r13011 r13013 22 22 using HeuristicLab.Core.Views; 23 23 using HeuristicLab.MainForm; 24 using HeuristicLab.Problems.GeneticProgramming.Robo Code;24 using HeuristicLab.Problems.GeneticProgramming.Robocode; 25 25 26 namespace HeuristicLab.Problems.GeneticProgramming.Views.Robo Code {26 namespace HeuristicLab.Problems.GeneticProgramming.Views.Robocode { 27 27 [View("Robocode Tank Program Tree View")] 28 28 [Content(typeof(Solution), IsDefaultView = false)] … … 39 39 protected override void OnContentChanged() { 40 40 base.OnContentChanged(); 41 if (Content == null) { 42 graphTreeView.Content = null; 43 } else { 44 graphTreeView.Content = Content.Tree; 45 } 41 graphTreeView.Content = Content == null ? null : Content.Tree; 46 42 } 47 43 } -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/BattleRunner.java
r13010 r13013 27 27 // 28 28 public class BattleRunner { 29 30 29 public static String player = "Evaluation.output*"; 30 public static List<Double> score = new ArrayList<Double>(); 31 31 32 32 // This program requires 5 arguments: 33 33 // The first argument is the name of the robot. 34 35 36 34 // The second argument is the path to the robocode installation. If not give, c:\robocode is assumed. 35 // The third argument: true if Robocode should be shown, otherwise it is hidden. 36 // The fourth argument is the number of rounds. 37 37 // The remaining arguments are the names of the opponents. At least 1 must be provided. 38 39 40 38 public static void main(String[] args) { 39 if (args.length < 5) 40 System.exit(-1); 41 41 42 43 Boolean visible = false; 44 45 46 String[] robots = new String[1 + args.length - 4];42 String roboCodePath = "C:\\robocode"; 43 Boolean visible = false; 44 String bots = ""; 45 int numberOfRounds = 3; 46 String[] robots = new String[1 + args.length - 4]; 47 47 48 player = robots[0] = args[0]; 49 roboCodePath = args[1]; 50 visible = Boolean.valueOf(args[2]); 51 numberOfRounds = Integer.valueOf(args[3]); 52 for (int i = 4; i < args.length; i++) 53 robots[i - 3] = args[i]; 48 player = robots[0] = args[0]; 49 roboCodePath = args[1]; 50 visible = Boolean.valueOf(args[2]); 51 numberOfRounds = Integer.valueOf(args[3]); 52 for (int i = 4; i < args.length; i++) { 53 robots[i - 3] = args[i]; 54 } 54 55 55 56 57 engine.setVisible(visible); 58 engine.addBattleListener(new BattleObserver());56 RobocodeEngine.setLogMessagesEnabled(false); 57 RobocodeEngine engine = new RobocodeEngine(new java.io.File(roboCodePath)); 58 engine.setVisible(visible); 59 engine.addBattleListener(new BattleObserver()); 59 60 60 BattlefieldSpecification battlefield = new BattlefieldSpecification(800, 600); 61 RobotSpecification[] all = engine.getLocalRepository(); 62 List<RobotSpecification> selectedRobots = new ArrayList<RobotSpecification>(); 63 64 for(RobotSpecification rs : all) { 65 for(String r : robots) { 66 if(r.equals(rs.getClassName())) { 67 selectedRobots.add(rs); 68 } 69 } 70 } 71 72 for (int i = 1; i < selectedRobots.size(); i++) { 73 BattleSpecification battleSpec = new BattleSpecification(numberOfRounds, battlefield, 74 new RobotSpecification[] { selectedRobots.get(0), selectedRobots.get(i) }); 61 BattlefieldSpecification battlefield = new BattlefieldSpecification(800, 600); 62 RobotSpecification[] all = engine.getLocalRepository(); 63 List<RobotSpecification> selectedRobots = new ArrayList<RobotSpecification>(); 64 65 for(RobotSpecification rs : all) { 66 for(String r : robots) { 67 if(r.equals(rs.getClassName())) { 68 selectedRobots.add(rs); 69 } 70 } 71 } 75 72 76 // run our specified battle and wait till the battle finishes 77 engine.runBattle(battleSpec, true); 78 } 79 engine.close(); 73 for (int i = 1; i < selectedRobots.size(); i++) { 74 BattleSpecification battleSpec = new BattleSpecification(numberOfRounds, battlefield, new RobotSpecification[] { selectedRobots.get(0), selectedRobots.get(i) }); 80 75 81 // print out result which is then parsed by HeuristicLab 82 System.out.println(avg(score)); 83 System.exit(0); 76 // run our specified battle and wait till the battle finishes 77 engine.runBattle(battleSpec, true); 84 78 } 85 86 private static double avg(List <Double> lst) { 87 double sum = 0; 88 for (double val : lst) { 89 sum += val; 90 } 91 return sum / lst.size(); 92 } 79 engine.close(); 80 81 // print out result which is then parsed by HeuristicLab 82 System.out.println(avg(score)); 83 System.exit(0); 84 } 85 86 private static double avg(List <Double> lst) { 87 double sum = 0; 88 for (double val : lst) { 89 sum += val; 90 } 91 return sum / lst.size(); 92 } 93 93 } 94 94 … … 97 97 // 98 98 class BattleObserver extends BattleAdaptor { 99 public void onBattleCompleted(BattleCompletedEvent e) { 100 101 102 103 for (robocode.BattleResults result : e.getSortedResults()) { 99 public void onBattleCompleted(BattleCompletedEvent e) { 100 double robotScore = -1.0; 101 double opponentScore = -1.0; 102 103 for (robocode.BattleResults result : e.getSortedResults()) { 104 104 if (result.getTeamLeaderName().contains(BattleRunner.player)) 105 105 robotScore = result.getScore(); … … 107 107 opponentScore = result.getScore(); 108 108 } 109 110 //prevent div / 0 which can happen if both robots do not score 111 if((robotScore + opponentScore) == 0) { 112 BattleRunner.score.add(0.0); 113 } else { 114 BattleRunner.score.add(robotScore / (robotScore + opponentScore)); 115 } 109 110 //prevent div / 0 which can happen if both robots do not score 111 if((robotScore + opponentScore) == 0) { 112 BattleRunner.score.add(0.0); 113 } else { 114 BattleRunner.score.add(robotScore / (robotScore + opponentScore)); 116 115 } 116 } 117 117 } -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/BestSolutionAnalyzer.cs
r13011 r13013 29 29 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 30 30 31 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code {31 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { 32 32 [StorableClass] 33 33 [Item("Best Tank Program Analyzer", -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/EnemyCollection.cs
r13011 r13013 29 29 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 30 30 31 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code {32 [Item("EnemyCollection", "A collection of enemy robots .")]31 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { 32 [Item("EnemyCollection", "A collection of enemy robots for the Robocode genetic programming problem.")] 33 33 [StorableClass] 34 34 public class EnemyCollection : CheckedItemList<StringValue> { -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Grammar.cs
r13011 r13013 25 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 26 27 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code {27 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { 28 28 [StorableClass] 29 29 [Item("Robocode Grammar", "The grammar for the Robocode GP problem.")] -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Interpreter.cs
r13011 r13013 26 26 using System.Linq; 27 27 using System.Reflection; 28 using HeuristicLab.Core;29 using HeuristicLab.Data;30 28 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 31 29 32 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code {30 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { 33 31 public static class Interpreter { 34 32 public static double EvaluateTankProgram(ISymbolicExpressionTree tree, string path, EnemyCollection enemies, string robotName = null, bool showUI = false, int nrOfRounds = 3) { … … 47 45 File.WriteAllText(srcRobotPath, interpretedProgram, System.Text.Encoding.Default); 48 46 47 // compile java source to class file 49 48 ProcessStartInfo javaCompileInfo = new ProcessStartInfo(); 50 49 javaCompileInfo.FileName = "cmd.exe"; … … 55 54 javaCompileInfo.CreateNoWindow = true; 56 55 57 Process javaCompile = new Process();58 javaCompile.StartInfo = javaCompileInfo;59 javaCompile.Start();56 using (Process javaCompile = new Process()) { 57 javaCompile.StartInfo = javaCompileInfo; 58 javaCompile.Start(); 60 59 61 string cmdOutput = javaCompile.StandardOutput.ReadToEnd();62 cmdOutput += javaCompile.StandardError.ReadToEnd();60 string cmdOutput = javaCompile.StandardOutput.ReadToEnd(); 61 cmdOutput += javaCompile.StandardError.ReadToEnd(); 63 62 64 javaCompile.WaitForExit(); 65 if (javaCompile.ExitCode != 0) { 66 DeleteRobotFiles(path, robotName); 67 throw new Exception("Compile Error: " + cmdOutput); 63 javaCompile.WaitForExit(); 64 if (javaCompile.ExitCode != 0) { 65 DeleteRobotFiles(path, robotName); 66 throw new Exception("Compile Error: " + cmdOutput); 67 } 68 68 } 69 69 70 70 //parallel execution of multiple robocode instances can sometimes lead to a damaged robot.database 71 try { File.Delete(path + @"\robots\robot.database"); } 72 catch { } 71 var robotsDbFileName = Path.Combine(path, "robots", "robot.database"); 72 if (File.Exists(robotsDbFileName)) 73 File.Delete(robotsDbFileName); 73 74 74 75 ProcessStartInfo evaluateCodeInfo = new ProcessStartInfo(); 75 76 77 // execute a battle with numberOfRounds against a number of enemies 78 // TODO: seems there is a bug when selecting multiple enemies 76 79 evaluateCodeInfo.FileName = "cmd.exe"; 77 evaluateCodeInfo.Arguments = "/C java -cp " + battleRunnerPath + ";" + robocodeCoreJar + ";" + robocodeJar + 78 ";" + picocontainerJar + ";" + " BattleRunner Evaluation." + robotName + " " + path; 79 80 if (showUI) { 81 evaluateCodeInfo.Arguments += " true " + nrOfRounds + " "; 82 } else { 83 evaluateCodeInfo.Arguments += " false " + nrOfRounds + " "; 84 } 85 86 foreach (var enemy in enemies.CheckedItems) 87 evaluateCodeInfo.Arguments += enemy.Value + " "; 80 var classpath = string.Join(";", new[] { battleRunnerPath, robocodeCoreJar, robocodeJar, picocontainerJar }); 81 var enemyRobotNames = string.Join(" ", enemies.CheckedItems.Select(i => i.Value)); 82 evaluateCodeInfo.Arguments = string.Format("/C java -cp {0} BattleRunner Evaluation.{1} {2} {3} {4} {5}", classpath, robotName, path, showUI, nrOfRounds, enemyRobotNames); 88 83 89 84 evaluateCodeInfo.RedirectStandardOutput = true; … … 92 87 evaluateCodeInfo.CreateNoWindow = true; 93 88 94 Process evaluateCode = new Process(); 95 evaluateCode.StartInfo = evaluateCodeInfo; 96 evaluateCode.Start(); 97 evaluateCode.WaitForExit(); 89 double evaluation; 90 using (Process evaluateCode = new Process()) { 91 evaluateCode.StartInfo = evaluateCodeInfo; 92 evaluateCode.Start(); 93 evaluateCode.WaitForExit(); 98 94 99 if (evaluateCode.ExitCode != 0) { 100 DeleteRobotFiles(path, robotName); 101 throw new Exception("Error running Robocode: " + evaluateCode.StandardError.ReadToEnd()); 102 } 95 if (evaluateCode.ExitCode != 0) { 96 DeleteRobotFiles(path, robotName); 97 throw new Exception("Error running Robocode: " + evaluateCode.StandardError.ReadToEnd() + Environment.NewLine + 98 evaluateCode.StandardOutput.ReadToEnd()); 99 } 103 100 104 string scoreString = ""; 105 double evaluation = -1.0; 106 try { 107 scoreString = evaluateCode.StandardOutput.ReadToEnd().Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).Last(); 108 evaluation = Double.Parse(scoreString, CultureInfo.InvariantCulture); 109 } 110 catch (Exception ex) { 111 throw new Exception("Error parsing score string: " + ex.ToString()); 112 } 113 finally { 114 DeleteRobotFiles(path, robotName); 101 try { 102 string scoreString = 103 evaluateCode.StandardOutput.ReadToEnd() 104 .Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries) 105 .Last(); 106 evaluation = Double.Parse(scoreString, CultureInfo.InvariantCulture); 107 } 108 catch (Exception ex) { 109 throw new Exception("Error parsing score string: " + ex); 110 } 111 finally { 112 DeleteRobotFiles(path, robotName); 113 } 115 114 } 116 115 … … 119 118 120 119 private static void DeleteRobotFiles(string path, string outputname) { 121 try { 122 File.Delete(path + @"\robots\Evaluation\" + outputname + ".java"); 123 File.Delete(path + @"\robots\Evaluation\" + outputname + ".class"); 124 } 125 catch { } 120 File.Delete(path + @"\robots\Evaluation\" + outputname + ".java"); 121 File.Delete(path + @"\robots\Evaluation\" + outputname + ".class"); 126 122 } 127 123 … … 132 128 } 133 129 catch { 134 throw new Exception("Error finding required Robo Code files.");130 throw new Exception("Error finding required Robocode files."); 135 131 } 136 132 return fileName; -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Plugin.cs.frame
r13011 r13013 27 27 using HeuristicLab.PluginInfrastructure; 28 28 29 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code29 namespace HeuristicLab.Problems.GeneticProgramming.Robocode 30 30 { 31 31 [Plugin("HeuristicLab.Problems.Robocode", "The Robocode problem for genetic programming.", "3.3.9.$WCREV$")] -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/RobocodeEvaluator.cs
r13011 r13013 29 29 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 30 30 31 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code {31 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { 32 32 [StorableClass] 33 33 [Item("Robocode Evaluator", "Evaluator for the Robocode GP problem.")] -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/RobocodeProblem.cs
r13011 r13013 30 30 using HeuristicLab.PluginInfrastructure; 31 31 32 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code {32 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { 33 33 [StorableClass] 34 34 [Creatable("Problems")] -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Solution.cs
r13011 r13013 25 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 26 27 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code {27 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { 28 28 [StorableClass] 29 29 [Item("Solution", "Robocode program and configuration.")] -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Block.cs
r13011 r13013 26 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 27 28 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code {28 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { 29 29 [StorableClass] 30 30 public class Block : CodeNode { -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/CodeNode.cs
r13011 r13013 25 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 26 27 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code {27 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { 28 28 [StorableClass] 29 29 public abstract class CodeNode : Symbol { -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Event Methods/Events/EmptyEvent.cs
r13011 r13013 25 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 26 27 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code {27 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { 28 28 [StorableClass] 29 29 public class EmptyEvent : CodeNode { -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Event Methods/Events/OnBulletHit.cs
r13011 r13013 27 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 28 29 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code {29 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { 30 30 [StorableClass] 31 31 public class OnBulletHit : CodeNode { -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Event Methods/Events/OnBulletMissed.cs
r13011 r13013 27 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 28 29 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code {29 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { 30 30 [StorableClass] 31 31 public class OnBulletMissed : CodeNode { -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Event Methods/Events/OnHitByBullet.cs
r13011 r13013 27 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 28 29 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code {29 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { 30 30 [StorableClass] 31 31 public class OnHitByBullet : CodeNode { -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Event Methods/Events/OnHitRobot.cs
r13011 r13013 27 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 28 29 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code {29 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { 30 30 [StorableClass] 31 31 public class OnHitRobot : CodeNode { -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Event Methods/Events/OnHitWall.cs
r13011 r13013 27 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 28 29 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code {29 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { 30 30 [StorableClass] 31 31 public class OnHitWall : CodeNode { -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Event Methods/Events/OnScannedRobot.cs
r13011 r13013 27 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 28 29 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code {29 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { 30 30 [StorableClass] 31 31 public class OnScannedRobot : CodeNode { -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Event Methods/Run.cs
r13011 r13013 27 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 28 29 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code {29 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { 30 30 [StorableClass] 31 31 public class Run : CodeNode { -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Logical Expressions/BooleanTreeNode.cs
r13011 r13013 25 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 26 27 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code {27 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { 28 28 [StorableClass] 29 29 public class BooleanTreeNode : SymbolicExpressionTreeTerminalNode { … … 53 53 54 54 public override void ResetLocalParameters(IRandom random) { 55 value = random.Next(0, 2) == 1; 55 // initialization 56 value = random.NextDouble() > 0.5; 57 } 58 59 public override void ShakeLocalParameters(IRandom random, double shakingFactor) { 60 // mutation: flip value with 5% probability 61 if (random.NextDouble() < 0.05) value = !value; 56 62 } 57 63 } -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Logical Expressions/Conjunction.cs
r13011 r13013 27 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 28 29 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code {29 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { 30 30 [StorableClass] 31 31 public class Conjunction : CodeNode { … … 55 55 public override string Interpret(ISymbolicExpressionTreeNode node, IEnumerable<ISymbolicExpressionTreeNode> children) { 56 56 if (children.Count() < 2) 57 throw new ArgumentException("Expected at leas et 2children.", "children");57 throw new ArgumentException("Expected at least two children.", "children"); 58 58 59 59 string result = string.Join(" && ", children.Select(c => ((CodeNode)c.Symbol).Interpret(c, c.Subtrees))); -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Logical Expressions/Disjunction.cs
r13011 r13013 27 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 28 29 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code {29 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { 30 30 [StorableClass] 31 31 public class Disjunction : CodeNode { … … 55 55 public override string Interpret(ISymbolicExpressionTreeNode node, IEnumerable<ISymbolicExpressionTreeNode> children) { 56 56 if (children.Count() < 2) 57 throw new ArgumentException("Expected at leas et 2children.", "children");57 throw new ArgumentException("Expected at least two children.", "children"); 58 58 59 59 string result = string.Join(" || ", children.Select(c => ((CodeNode)c.Symbol).Interpret(c, c.Subtrees))); -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Logical Expressions/Logical Comparators/Equal.cs
r13011 r13013 27 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 28 29 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code {29 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { 30 30 [StorableClass] 31 31 public class Equal : CodeNode, ILogicalComparator { … … 52 52 ISymbolicExpressionTreeNode lhs = null, rhs = null; 53 53 if (children.Count() != 2) 54 throw new Exception("Unexpected number of children. Expected 2children.");54 throw new Exception("Unexpected number of children. Expected two children."); 55 55 56 56 lhs = children.First(); -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Logical Expressions/Logical Comparators/GreaterThan.cs
r13011 r13013 27 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 28 29 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code {29 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { 30 30 [StorableClass] 31 31 public class GreaterThan : CodeNode, ILogicalComparator { … … 52 52 ISymbolicExpressionTreeNode lhs = null, rhs = null; 53 53 if (children.Count() != 2) 54 throw new Exception("Unexpected number of children. Expected 2children.");54 throw new Exception("Unexpected number of children. Expected two children."); 55 55 56 56 lhs = children.First(); -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Logical Expressions/Logical Comparators/GreaterThanOrEqual.cs
r13011 r13013 27 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 28 29 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code {29 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { 30 30 [StorableClass] 31 31 public class GreaterThanOrEqual : CodeNode, ILogicalComparator { … … 52 52 ISymbolicExpressionTreeNode lhs = null, rhs = null; 53 53 if (children.Count() != 2) 54 throw new Exception("Unexpected number of children. Expected 2children.");54 throw new Exception("Unexpected number of children. Expected two children."); 55 55 56 56 lhs = children.First(); -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Logical Expressions/Logical Comparators/ILogicalComparator.cs
r13011 r13013 20 20 #endregion 21 21 22 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code {22 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { 23 23 public interface ILogicalComparator { } 24 24 } -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Logical Expressions/Logical Comparators/LessThan.cs
r13011 r13013 27 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 28 29 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code {29 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { 30 30 [StorableClass] 31 31 public class LessThan : CodeNode, ILogicalComparator { … … 52 52 ISymbolicExpressionTreeNode lhs = null, rhs = null; 53 53 if (children.Count() != 2) 54 throw new Exception("Unexpected number of children. Expected 2children.");54 throw new Exception("Unexpected number of children. Expected two children."); 55 55 56 56 lhs = children.First(); -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Logical Expressions/Logical Comparators/LessThanOrEqual.cs
r13011 r13013 27 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 28 29 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code {29 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { 30 30 [StorableClass] 31 31 public class LessThanOrEqual : CodeNode, ILogicalComparator { … … 52 52 ISymbolicExpressionTreeNode lhs = null, rhs = null; 53 53 if (children.Count() != 2) 54 throw new Exception("Unexpected number of children. Expected 2children.");54 throw new Exception("Unexpected number of children. Expected two children."); 55 55 56 56 lhs = children.First(); -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Logical Expressions/LogicalExpression.cs
r13011 r13013 27 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 28 29 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code {29 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { 30 30 [StorableClass] 31 31 public class LogicalExpression : CodeNode { … … 56 56 var symbol = exprTree.Symbol; 57 57 if (!(symbol is LogicalValue || symbol is Conjunction || symbol is Disjunction || symbol is Negation)) 58 throw new System.Exception("LogicalExpression was given a child of type " + symbol.GetType() + 59 ". The expected child must be of type " + typeof(LogicalValue) 60 + " or " + typeof(Conjunction) 61 + " or " + typeof(Disjunction) 62 + " or " + typeof(Negation) + "."); 58 throw new InvalidProgramException("Negation was given a child of type " + symbol.GetType() + 59 ". The expected child must be of type LogicalValue or Conjunction or Disjunction or Negation."); 63 60 64 61 return Prefix + ((CodeNode)symbol).Interpret(exprTree, exprTree.Subtrees) + Suffix; -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Logical Expressions/LogicalValue.cs
r13011 r13013 25 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 26 27 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code {27 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { 28 28 [StorableClass] 29 29 public class LogicalValue : CodeNode { -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Logical Expressions/Negation.cs
r13011 r13013 27 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 28 29 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code {29 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { 30 30 [StorableClass] 31 31 public class Negation : CodeNode { … … 60 60 var symbol = exprTree.Symbol; 61 61 if (!(symbol is LogicalValue || symbol is Conjunction || symbol is Disjunction || symbol is Negation || symbol is ILogicalComparator)) 62 throw new System.Exception("Negation was given a child of type " + symbol.GetType() + 63 ". The expected child must be of type " + typeof(LogicalValue) 64 + " or " + typeof(Conjunction) 65 + " or " + typeof(Disjunction) 66 + " or " + typeof(Negation) 67 + " or " + typeof(ILogicalComparator) + "."); 62 throw new InvalidProgramException("Negation was given a child of type " + symbol.GetType() + 63 ". The expected child must be of type LogicalValue or Conjunction or Disjunction or Negation or ILogicalComparator."); 68 64 69 65 return Prefix + ((CodeNode)symbol).Interpret(exprTree, exprTree.Subtrees) + Suffix; -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Numerical Expressions/Number.cs
r13011 r13013 26 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 27 28 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code {28 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { 29 29 [StorableClass] 30 30 public class Number : CodeNode { -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Numerical Expressions/NumberTreeNode.cs
r13011 r13013 25 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 26 27 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code {27 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { 28 28 [StorableClass] 29 29 public class NumberTreeNode : SymbolicExpressionTreeTerminalNode { … … 53 53 54 54 public override void ResetLocalParameters(IRandom random) { 55 // random initialization 55 56 value = random.Next(-360, 360); 57 } 58 59 public override void ShakeLocalParameters(IRandom random, double shakingFactor) { 60 // random mutation (cyclic) 61 value = value + random.Next(-20, 20); 62 if (value < -360) value += 2 * 360; 63 else if (value > 359) value -= 2 * 360; 56 64 } 57 65 } -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Numerical Expressions/Numerical Operators/Addition.cs
r13011 r13013 27 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 28 29 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code {29 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { 30 30 [StorableClass] 31 31 public class Addition : CodeNode, INumericalOperator { … … 55 55 public override string Interpret(ISymbolicExpressionTreeNode node, IEnumerable<ISymbolicExpressionTreeNode> children) { 56 56 if (children.Count() < 2) 57 throw new ArgumentException("Expected at leas et 2children.", "children");57 throw new ArgumentException("Expected at least two children.", "children"); 58 58 59 59 string result = string.Join(" + ", children.Select(c => ((CodeNode)c.Symbol).Interpret(c, c.Subtrees))); -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Numerical Expressions/Numerical Operators/Division.cs
r13011 r13013 27 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 28 29 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code {29 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { 30 30 [StorableClass] 31 31 public class Division : CodeNode, INumericalOperator { … … 55 55 public override string Interpret(ISymbolicExpressionTreeNode node, IEnumerable<ISymbolicExpressionTreeNode> children) { 56 56 if (children.Count() < 2) 57 throw new ArgumentException("Expected at leas et 2children.", "children");57 throw new ArgumentException("Expected at least two children.", "children"); 58 58 59 59 string result = string.Join(" / ", children.Select(c => ((CodeNode)c.Symbol).Interpret(c, c.Subtrees))); -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Numerical Expressions/Numerical Operators/INumericalOperator.cs
r13011 r13013 20 20 #endregion 21 21 22 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code {22 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { 23 23 public interface INumericalOperator { } 24 24 } -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Numerical Expressions/Numerical Operators/Modulus.cs
r13011 r13013 27 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 28 29 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code {29 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { 30 30 [StorableClass] 31 31 public class Modulus : CodeNode, INumericalOperator { … … 55 55 public override string Interpret(ISymbolicExpressionTreeNode node, IEnumerable<ISymbolicExpressionTreeNode> children) { 56 56 if (children.Count() < 2) 57 throw new ArgumentException("Expected at leas et 2children.", "children");57 throw new ArgumentException("Expected at least two children.", "children"); 58 58 59 59 string result = string.Join(" % ", children.Select(c => ((CodeNode)c.Symbol).Interpret(c, c.Subtrees))); -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Numerical Expressions/Numerical Operators/Multiplication.cs
r13011 r13013 27 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 28 29 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code {29 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { 30 30 [StorableClass] 31 31 public class Multiplication : CodeNode, INumericalOperator { … … 55 55 public override string Interpret(ISymbolicExpressionTreeNode node, IEnumerable<ISymbolicExpressionTreeNode> children) { 56 56 if (children.Count() < 2) 57 throw new ArgumentException("Expected at leas et 2children.", "children");57 throw new ArgumentException("Expected at least two children.", "children"); 58 58 59 59 string result = string.Join(" * ", children.Select(c => ((CodeNode)c.Symbol).Interpret(c, c.Subtrees))); -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Numerical Expressions/Numerical Operators/Subtraction.cs
r13011 r13013 27 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 28 29 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code {29 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { 30 30 [StorableClass] 31 31 public class Subtraction : CodeNode, INumericalOperator { … … 55 55 public override string Interpret(ISymbolicExpressionTreeNode node, IEnumerable<ISymbolicExpressionTreeNode> children) { 56 56 if (children.Count() < 2) 57 throw new ArgumentException("Expected at leas et 2children.", "children");57 throw new ArgumentException("Expected at least two children.", "children"); 58 58 59 59 string result = string.Join(" - ", children.Select(c => ((CodeNode)c.Symbol).Interpret(c, c.Subtrees))); -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Numerical Expressions/NumericalExpression.cs
r13011 r13013 27 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 28 29 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code {29 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { 30 30 [StorableClass] 31 31 public class NumericalExpression : CodeNode { … … 56 56 var symbol = exprTree.Symbol; 57 57 if (!(symbol is Number || symbol is INumericalMethod || symbol is INumericalOperator)) 58 throw new System.Exception("NumericalExpression was given a child of type " + symbol.GetType() + 59 ". The expected child must be of type " + typeof(Number) 60 + " or " + typeof(INumericalMethod) 61 + " or " + typeof(INumericalOperator) + "."); 58 throw new InvalidProgramException("NumericalExpression was given a child of type " + symbol.GetType() + 59 ". The expected child must be of type Number or INumericalMethod or INumericalOperator ."); 62 60 63 61 return Prefix + ((CodeNode)symbol).Interpret(exprTree, exprTree.Subtrees) + Suffix; -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Numerical Expressions/ShotPower.cs
r13011 r13013 26 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 27 28 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code {28 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { 29 29 [StorableClass] 30 30 public class ShotPower : CodeNode { -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Numerical Expressions/ShotPowerTreeNode.cs
r13011 r13013 26 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 27 28 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code {28 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { 29 29 [StorableClass] 30 30 public class ShotPowerTreeNode : SymbolicExpressionTreeTerminalNode { … … 54 54 55 55 public override void ResetLocalParameters(IRandom random) { 56 // random initialization 56 57 value = Math.Max(0.1, random.NextDouble() * 3); 58 } 59 60 public override void ShakeLocalParameters(IRandom random, double shakingFactor) { 61 // mutation 62 var d = random.NextDouble() * 2.0 - 1.0; 63 value = Math.Max(0.1, value + shakingFactor * d); 57 64 } 58 65 } -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Numerical Methods/GetEnergy.cs
r13011 r13013 25 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 26 27 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code {27 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { 28 28 [StorableClass] 29 29 public class GetEnergy : CodeNode, INumericalMethod { -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Numerical Methods/GetGunHeading.cs
r13011 r13013 25 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 26 27 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code {27 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { 28 28 [StorableClass] 29 29 public class GetGunHeading : CodeNode, INumericalMethod { -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Numerical Methods/GetHeading.cs
r13011 r13013 25 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 26 27 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code {27 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { 28 28 [StorableClass] 29 29 public class GetHeading : CodeNode, INumericalMethod { -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Numerical Methods/GetRadarHeading.cs
r13011 r13013 25 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 26 27 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code {27 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { 28 28 [StorableClass] 29 29 public class GetRadarHeading : CodeNode, INumericalMethod { -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Numerical Methods/GetX.cs
r13011 r13013 25 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 26 27 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code {27 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { 28 28 [StorableClass] 29 29 public class GetX : CodeNode, INumericalMethod { -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Numerical Methods/GetY.cs
r13011 r13013 25 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 26 27 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code {27 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { 28 28 [StorableClass] 29 29 public class GetY : CodeNode, INumericalMethod { -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Numerical Methods/INumericalMethod.cs
r13011 r13013 20 20 #endregion 21 21 22 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code {22 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { 23 23 public interface INumericalMethod { } 24 24 } -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Program.cs
r13011 r13013 25 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 26 27 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code {27 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { 28 28 [StorableClass] 29 29 public class Program : Symbol { -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Stat.cs
r13011 r13013 27 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 28 29 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code {29 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { 30 30 [StorableClass] 31 31 public class Stat : CodeNode { -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Statements/IfThenElseStat.cs
r13011 r13013 27 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 28 29 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code {29 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { 30 30 [StorableClass] 31 31 public class IfThenElseStat : CodeNode { -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Statements/WhileStat.cs
r13011 r13013 26 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 27 28 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code {28 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { 29 29 [StorableClass] 30 30 public class WhileStat : CodeNode { -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Tank.cs
r13011 r13013 27 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 28 29 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code {29 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { 30 30 [StorableClass] 31 31 public class Tank : CodeNode { -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Void Methods/Ahead.cs
r13011 r13013 27 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 28 29 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code {29 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { 30 30 [StorableClass] 31 31 public class Ahead : CodeNode { … … 60 60 var symbol = exprTree.Symbol; 61 61 if (!(symbol is NumericalExpression)) 62 throw new Exception("Ahead was given a child of type " + symbol.GetType() +63 ". The expected child must be of type " + typeof(NumericalExpression) + ".");62 throw new InvalidProgramException("Ahead was given a child of type " + symbol.GetType() + 63 ". The expected child must be of type NumericalExpression."); 64 64 65 65 string result = ((CodeNode)symbol).Interpret(exprTree, exprTree.Subtrees); -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Void Methods/Back.cs
r13011 r13013 27 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 28 29 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code {29 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { 30 30 [StorableClass] 31 31 public class Back : CodeNode { … … 60 60 var symbol = exprTree.Symbol; 61 61 if (!(symbol is NumericalExpression)) 62 throw new Exception("Back was given a child of type " + symbol.GetType() +63 ". The expected child must be of type " + typeof(NumericalExpression) + ".");62 throw new InvalidProgramException("Back was given a child of type " + symbol.GetType() + 63 ". The expected child must be of type NumericalExpression."); 64 64 65 65 string result = ((CodeNode)symbol).Interpret(exprTree, exprTree.Subtrees); -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Void Methods/DoNothing.cs
r13011 r13013 25 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 26 27 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code {27 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { 28 28 [StorableClass] 29 29 public class DoNothing : CodeNode { … … 41 41 protected DoNothing(DoNothing original, Cloner cloner) : base(original, cloner) { } 42 42 43 public DoNothing() : base("DoNothing", "Do nothing this turn, meaning that the robot will skip it 's turn.") { }43 public DoNothing() : base("DoNothing", "Do nothing this turn, meaning that the robot will skip its turn.") { } 44 44 45 45 public override IDeepCloneable Clone(Cloner cloner) { -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Void Methods/Fire.cs
r13011 r13013 27 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 28 29 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code {29 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { 30 30 [StorableClass] 31 31 public class Fire : CodeNode { … … 60 60 var symbol = exprTree.Symbol; 61 61 if (!(symbol is ShotPower)) 62 throw new Exception("Fire was given a child of type " + symbol.GetType() +63 ". The expected child must be of type " + typeof(ShotPower) + ".");62 throw new InvalidProgramException("Fire was given a child of type " + symbol.GetType() + 63 ". The expected child must be of type ShotPower."); 64 64 65 65 string result = ((CodeNode)symbol).Interpret(exprTree, exprTree.Subtrees); -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Void Methods/TurnGunLeft.cs
r13011 r13013 27 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 28 29 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code {29 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { 30 30 [StorableClass] 31 31 public class TurnGunLeft : CodeNode { … … 60 60 var symbol = exprTree.Symbol; 61 61 if (!(symbol is NumericalExpression)) 62 throw new Exception("TurnGunLeft was given a child of type " + symbol.GetType() +63 ". The expected child must be of type " + typeof(NumericalExpression) + ".");62 throw new InvalidProgramException("TurGunLeft was given a child of type " + symbol.GetType() + 63 ". The expected child must be of type NumericalExpression."); 64 64 65 65 string result = ((CodeNode)symbol).Interpret(exprTree, exprTree.Subtrees); -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Void Methods/TurnGunRight.cs
r13011 r13013 27 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 28 29 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code {29 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { 30 30 [StorableClass] 31 31 public class TurnGunRight : CodeNode { … … 60 60 var symbol = exprTree.Symbol; 61 61 if (!(symbol is NumericalExpression)) 62 throw new Exception("TurnGunRight was given a child of type " + symbol.GetType() +63 ". The expected child must be of type " + typeof(NumericalExpression) + ".");62 throw new InvalidProgramException("TurnGunRight was given a child of type " + symbol.GetType() + 63 ". The expected child must be of type NumericalExpression."); 64 64 65 65 string result = ((CodeNode)symbol).Interpret(exprTree, exprTree.Subtrees); -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Void Methods/TurnLeft.cs
r13011 r13013 27 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 28 29 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code {29 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { 30 30 [StorableClass] 31 31 public class TurnLeft : CodeNode { … … 60 60 var symbol = exprTree.Symbol; 61 61 if (!(symbol is NumericalExpression)) 62 throw new System.Exception("TurnLeft was given a child of type " + symbol.GetType() +63 ". The expected child must be of type " + typeof(NumericalExpression) + ".");62 throw new InvalidProgramException("TurnLeft was given a child of type " + symbol.GetType() + 63 ". The expected child must be of type NumericalExpression."); 64 64 65 65 string result = ((CodeNode)symbol).Interpret(exprTree, exprTree.Subtrees); -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Void Methods/TurnRadarLeft.cs
r13011 r13013 27 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 28 29 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code {29 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { 30 30 [StorableClass] 31 31 public class TurnRadarLeft : CodeNode { … … 60 60 var symbol = exprTree.Symbol; 61 61 if (!(symbol is NumericalExpression)) 62 throw new Exception("TurnRadarLeft was given a child of type " + symbol.GetType() +63 ". The expected child must be of type " + typeof(NumericalExpression) + ".");62 throw new InvalidProgramException("TurnRadarLeft was given a child of type " + symbol.GetType() + 63 ". The expected child must be of type NumericalExpression."); 64 64 65 65 string result = ((CodeNode)symbol).Interpret(exprTree, exprTree.Subtrees); -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Void Methods/TurnRadarRight.cs
r13011 r13013 27 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 28 29 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code {29 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { 30 30 [StorableClass] 31 31 public class TurnRadarRight : CodeNode { … … 60 60 var symbol = exprTree.Symbol; 61 61 if (!(symbol is NumericalExpression)) 62 throw new Exception("TurnRadarRight was given a child of type " + symbol.GetType() +63 ". The expected child must be of type " + typeof(NumericalExpression) + ".");62 throw new InvalidProgramException("TurnRadarRight was given a child of type " + symbol.GetType() + 63 ". The expected child must be of type NumericalExpression."); 64 64 65 65 string result = ((CodeNode)symbol).Interpret(exprTree, exprTree.Subtrees); -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Void Methods/TurnRight.cs
r13011 r13013 27 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 28 29 namespace HeuristicLab.Problems.GeneticProgramming.Robo Code {29 namespace HeuristicLab.Problems.GeneticProgramming.Robocode { 30 30 [StorableClass] 31 31 public class TurnRight : CodeNode { … … 60 60 var symbol = exprTree.Symbol; 61 61 if (!(symbol is NumericalExpression)) 62 throw new System.Exception("TurnRight was given a child of type " + symbol.GetType() +63 ". The expected child must be of type " + typeof(NumericalExpression) + ".");62 throw new InvalidProgramException("TurnRight was given a child of type " + symbol.GetType() + 63 ". The expected child must be of type NumericalExpression."); 64 64 65 65 string result = ((CodeNode)symbol).Interpret(exprTree, exprTree.Subtrees);
Note: See TracChangeset
for help on using the changeset viewer.