Changeset 9898 for branches/Robocode.TrunkInt
- Timestamp:
- 08/22/13 15:16:13 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Interpreter.cs
r9892 r9898 36 36 string interpretedProgram = InterpretProgramTree(tree.Root, robotName); 37 37 string battleRunnerPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); 38 string roboCodeLibPath = Path.Combine(path, "libs"); 39 string robocodeJar = Path.Combine(roboCodeLibPath, "robocode.jar"); 40 string robocodeCoreJar = GetFileName(roboCodeLibPath, "robocode.core*"); 41 string picocontainerJar = GetFileName(roboCodeLibPath, "picocontainer*"); 42 string robotsPath = Path.Combine(path, "robots", "Evaluation"); 43 string srcRobotPath = Path.Combine(robotsPath, robotName + ".java"); 38 44 39 45 try { 40 File.WriteAllText( path + "/robots/Evaluation/" + robotName + ".java", interpretedProgram, System.Text.Encoding.Default);46 File.WriteAllText(srcRobotPath, interpretedProgram, System.Text.Encoding.Default); 41 47 } 42 48 catch (Exception ex) { … … 46 52 ProcessStartInfo javaCompileInfo = new ProcessStartInfo(); 47 53 javaCompileInfo.FileName = "cmd.exe"; 48 javaCompileInfo.Arguments = "/C javac -cp " + path + "\\libs\\robocode.jar " + 49 path + "\\robots\\Evaluation\\" + robotName + ".java"; 54 javaCompileInfo.Arguments = "/C javac -cp " + robocodeJar + "; " + srcRobotPath; 50 55 javaCompileInfo.RedirectStandardOutput = true; 51 56 javaCompileInfo.RedirectStandardError = true; … … 67 72 68 73 //parallel execution of multiple robocode instances can sometimes lead to a damaged robot.database 69 try { File.Delete(path + "/robots/robot.database"); }74 try { File.Delete(path + @"\robots\robot.database"); } 70 75 catch { } 71 76 … … 73 78 74 79 evaluateCodeInfo.FileName = "cmd.exe"; 75 evaluateCodeInfo.Arguments = "/C java -c lasspath " + battleRunnerPath + ";" + path + "\\libs\\robocode.core-1.8.1.0.jar;" + path + "\\libs\\robocode.jar;"+76 path + "\\libs\\picocontainer-2.14.2.jar BattleRunner Evaluation." +77 robotName + "* " + path; 80 evaluateCodeInfo.Arguments = "/C java -cp " + battleRunnerPath + ";" + robocodeCoreJar + ";" + robocodeJar + 81 ";" + picocontainerJar + ";" + " BattleRunner Evaluation." + robotName + "* " + path; 82 78 83 if (showUI) 79 84 evaluateCodeInfo.Arguments += " true"; … … 97 102 double evaluation = -1.0; 98 103 try { 99 scoreString = evaluateCode.StandardOutput.ReadToEnd().Split(new string[] { "\r\n"}, StringSplitOptions.RemoveEmptyEntries).Last();104 scoreString = evaluateCode.StandardOutput.ReadToEnd().Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).Last(); 100 105 evaluation = Double.Parse(scoreString, CultureInfo.InvariantCulture); 101 106 } … … 112 117 private static void DeleteRobotFiles(string path, string outputname) { 113 118 try { 114 File.Delete(path + "/robots/Evaluation/" + outputname + ".java");115 File.Delete(path + "/robots/Evaluation/" + outputname + ".class");119 File.Delete(path + @"\robots\Evaluation\" + outputname + ".java"); 120 File.Delete(path + @"\robots\Evaluation\" + outputname + ".class"); 116 121 } 117 122 catch { } 123 } 124 125 private static string GetFileName(string path, string pattern) { 126 string fileName = string.Empty; 127 try { 128 fileName = Directory.GetFiles(path, pattern).First(); 129 } 130 catch { 131 throw new Exception("Error finding required RoboCode files."); 132 } 133 return fileName; 118 134 } 119 135
Note: See TracChangeset
for help on using the changeset viewer.