Index: /branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Interpreter.cs
===================================================================
--- /branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Interpreter.cs	(revision 9880)
+++ /branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Interpreter.cs	(revision 9881)
@@ -24,35 +24,23 @@
 using System.IO;
 using System.Linq;
-using System.Text;
 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
 
 namespace HeuristicLab.Problems.Robocode {
   public class Interpreter {
-
-    static string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
-
     public static double EvaluateTankProgram(ISymbolicExpressionTree tree, string path) {
-      //TankStats tankStats = EvaluateTankProgram(tree.Root, solutionCandidateRoot, null);
-      //Evaluator.tankStatLog += "\r\n" + tankStats.shots + " / " + tankStats.moves;
       string interpretedProgram = InterpretProgramTree(tree.Root);
-      Random random = new Random();
       string formattedPath = path.Replace("/", "\\");
       string outputname = "";
-      string output = "";
-      bool noError = true;
-      do {
-        try {
-          outputname = new string(Enumerable.Repeat(chars, 8).Select(s => s[random.Next(s.Length)]).ToArray());
-          output = /*solutionCandidateRoot.InnerText*/interpretedProgram.Replace("class output", "class " + outputname);
-          File.WriteAllText(path + "/robots/Evaluation/" + outputname + ".java", output, System.Text.Encoding.Default);
-          noError = true;
-        }
-        catch (Exception e) { noError = false; }
-      } while (!noError);
 
-      //string path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
-      //path.Replace("\\", "\\\\");
-      //path.Replace(" ", "\\ ");
-      #region Compile code file
+      try {
+        outputname = Guid.NewGuid().ToString();
+        outputname = outputname.Replace('-', '_');
+        outputname = "Robocode" + outputname;
+        string output = interpretedProgram.Replace("class output", "class " + outputname);
+        File.WriteAllText(path + "/robots/Evaluation/" + outputname + ".java", output, System.Text.Encoding.Default);
+      }
+      catch (Exception ex) {
+        throw;
+      }
 
       ProcessStartInfo javaCompileInfo = new ProcessStartInfo();
@@ -68,36 +56,20 @@
       javaCompile.Start();
 
-      /*Evaluator.tankStatLog = "=====================================================\r\n";
-      Evaluator.tankStatLog += "Tree Compilation Output: \r\n";
-      Evaluator.tankStatLog += "=====================================================\r\n";*/
-
       string cmdOutput = javaCompile.StandardOutput.ReadToEnd();
       cmdOutput += javaCompile.StandardError.ReadToEnd();
 
-      //Evaluator.tankStatLog += cmdOutput;
-      //Console.WriteLine(cmdOutput);
-      //Console.ReadLine();
-
-      /*Evaluator.tankStatLog = "=====================================================\r\n";
-      Evaluator.tankStatLog += "End of Tree Compilation Output: \r\n";
-      Evaluator.tankStatLog += "=====================================================\r\n";*/
-
       javaCompile.WaitForExit();
       if (javaCompile.ExitCode != 0) {
-        return -1000.0;
+        DeleteRobotFiles(path, outputname);
+        throw new Exception("Compile Error: " + cmdOutput);
       }
-      #endregion
 
-
+      //parallel execution of multiple robocode instances can sometimes lead to a damaged robot.database
       try { File.Delete(path + "/robots/robot.database"); }
-      catch (Exception e) { }
-
-      #region evaluate code
+      catch { }
 
       ProcessStartInfo evaluateCodeInfo = new ProcessStartInfo();
       evaluateCodeInfo.FileName = "cmd.exe";
-      //javaCompileInfo.Arguments = "/C javac -cp C:\\robocode\\libs\\robocode.jar \"" + path + "\\Spaced Up\\output.java\"";
       evaluateCodeInfo.Arguments = "/C java -classpath " + formattedPath + "\\libs;" + formattedPath + "\\libs\\robocode.core-1.8.1.0.jar;" + formattedPath + "\\libs\\robocode.jar;" + formattedPath + "\\libs\\picocontainer-2.14.2.jar BattleRunner Evaluation." + outputname + "* false";
-      //Console.WriteLine(javaCompileInfo.Arguments);
       evaluateCodeInfo.RedirectStandardOutput = true;
       evaluateCodeInfo.RedirectStandardError = true;
@@ -108,33 +80,32 @@
       evaluateCode.StartInfo = evaluateCodeInfo;
       evaluateCode.Start();
-
-      StringBuilder q = new StringBuilder();
-      string scoreString = "";
       evaluateCode.WaitForExit();
-
-      try {
-        scoreString = evaluateCode.StandardOutput.ReadToEnd().Split(
-        new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries).Last();
-        q.Append("Output: " + scoreString + "\r\n");
-        q.Append("Error: " + evaluateCode.StandardError.ReadToEnd() + "\r\n");
-        cmdOutput += q.ToString();
-      }
-      catch {
-        return -1000.0;
+      if (evaluateCode.ExitCode != 0) {
+        DeleteRobotFiles(path, outputname);
+        throw new Exception("Error running Robocode: " + evaluateCode.StandardError.ReadToEnd());
       }
 
-      #endregion
+      string scoreString = "";
+      double evaluation = -900;
+      try {
+        scoreString = evaluateCode.StandardOutput.ReadToEnd().Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries).Last();
+        evaluation = Double.Parse(scoreString);
+      }
+      catch (Exception ex) {
+        throw new Exception("Error parsing score string: " + ex.ToString());
+      }
+      finally {
+        DeleteRobotFiles(path, outputname);
+      }
 
-      double evaluation = -900;
+      return evaluation;
+    }
+
+    private static void DeleteRobotFiles(string path, string outputname) {
       try {
         File.Delete(path + "/robots/Evaluation/" + outputname + ".java");
         File.Delete(path + "/robots/Evaluation/" + outputname + ".class");
-        evaluation = Double.Parse(scoreString);
       }
-      catch (Exception e) { evaluation = -900; }
-      Random rand = new Random();
-      evaluation += rand.NextDouble() / 100;
-
-      return evaluation;
+      catch { }
     }
 
Index: /branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/RobocodeEvaluator.cs
===================================================================
--- /branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/RobocodeEvaluator.cs	(revision 9880)
+++ /branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/RobocodeEvaluator.cs	(revision 9881)
@@ -20,5 +20,4 @@
 #endregion
 
-using System.Threading;
 using HeuristicLab.Common;
 using HeuristicLab.Core;
@@ -37,7 +36,4 @@
     private const string TankProgramParameterName = "TankProgram";
     private const string RobocodePathParamaterName = "Path";
-
-    //TODO: this should be removed
-    public static SemaphoreSlim semaphore = new SemaphoreSlim(10);
 
     #region Parameters
@@ -65,11 +61,7 @@
 
     public override IOperation Apply() {
-      semaphore.Wait();
-
       ISymbolicExpressionTree tree = TankProgramParameter.ActualValue;
       string path = RobocodePathParameter.ActualValue.Value;
       QualityParameter.ActualValue = new DoubleValue(Interpreter.EvaluateTankProgram(tree, path));
-
-      semaphore.Release();
 
       return base.Apply();
