Index: branches/Robocode/HeuristicLab.Problems.Robocode/Interpreter.cs
===================================================================
--- branches/Robocode/HeuristicLab.Problems.Robocode/Interpreter.cs	(revision 9570)
+++ branches/Robocode/HeuristicLab.Problems.Robocode/Interpreter.cs	(revision 9601)
@@ -1,474 +1,401 @@
 ﻿using System;
-using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
 using System.Linq;
 using System.Text;
-using System.Threading.Tasks;
-using System.IO;
+using System.Xml;
+using HeuristicLab.Core;
 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
-using System.Xml;
-using System.Diagnostics;
-using HeuristicLab.PluginInfrastructure;
-using HeuristicLab.Core;
-using System.Threading;
-
-namespace HeuristicLab.Problems.Robocode
-{
-    public class Interpreter
-    {
-
-        private struct TankStats
-        {
-            public int moves , shots;
-            public TankStats(int moves, int shots)
-            {
-                this.moves = moves;
-                this.shots = shots;
-            }
+
+namespace HeuristicLab.Problems.Robocode {
+  public class Interpreter {
+
+    private struct TankStats {
+      public int moves, shots;
+      public TankStats(int moves, int shots) {
+        this.moves = moves;
+        this.shots = shots;
+      }
+    }
+    static string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+
+    public static string BuildTankProgram(ISymbolicExpressionTree tree) {
+      XmlDocument solutionCandidateRoot = new XmlDocument();
+      solutionCandidateRoot.Load("../tank.xml");
+
+      TankStats tankStats = EvaluateTankProgram(tree.Root, solutionCandidateRoot.FirstChild, null);
+      return solutionCandidateRoot.InnerText;
+    }
+
+    public static double EvaluateTankProgram(ISymbolicExpressionTree tree, XmlNode solutionCandidateRoot, 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;
         }
-        static string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
-
-        public static string BuildTankProgram(ISymbolicExpressionTree tree)
-        {
-            XmlDocument solutionCandidateRoot = new XmlDocument();
-            solutionCandidateRoot.Load("../tank.xml");
-
-            TankStats tankStats = EvaluateTankProgram(tree.Root, solutionCandidateRoot.FirstChild, null);
-            return solutionCandidateRoot.InnerText;
+        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
+
+      ProcessStartInfo javaCompileInfo = new ProcessStartInfo();
+      javaCompileInfo.FileName = "cmd.exe";
+      javaCompileInfo.Arguments = "/C javac -cp " + formattedPath + "\\libs\\robocode.jar " + formattedPath + "\\robots\\Evaluation\\" + outputname + ".java";
+      javaCompileInfo.RedirectStandardOutput = true;
+      javaCompileInfo.RedirectStandardError = true;
+      javaCompileInfo.UseShellExecute = false;
+      javaCompileInfo.CreateNoWindow = true;
+
+      Process javaCompile = new Process();
+      javaCompile.StartInfo = javaCompileInfo;
+      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();
+      #endregion
+
+
+      try { File.Delete(path + "/robots/robot.database"); }
+      catch (Exception e) { }
+
+      #region evaluate code
+
+      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;
+      evaluateCodeInfo.UseShellExecute = false;
+      evaluateCodeInfo.CreateNoWindow = true;
+
+      Process evaluateCode = new Process();
+      evaluateCode.StartInfo = evaluateCodeInfo;
+      evaluateCode.Start();
+
+      // instead of p.WaitForExit(), do
+      StringBuilder q = new StringBuilder();
+      string scoreString = "";
+      while (!evaluateCode.HasExited) {
+        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();
+
+      #endregion
+
+      double evaluation = -900;
+      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;
+
+      /*Evaluator.tankStatLog = "=====================================================\r\n";
+      Evaluator.tankStatLog += "START OF TREE - Score: " + evaluation + " (" + tankStats.shots + "/" + tankStats.moves + ")" + "\r\n" + " Compilation Output: " + cmdOutput + "\r\n";
+      Evaluator.tankStatLog += "=====================================================\r\n";
+
+      Evaluator.tankStatLog += solutionCandidateRoot.InnerText + "\r\n";
+
+      Evaluator.tankStatLog += "=====================================================\r\n";
+      Evaluator.tankStatLog += "END OF TREE\r\n";
+      Evaluator.tankStatLog += "=====================================================\r\n";
+
+      File.AppendAllText("../TankLog.txt", Evaluator.tankStatLog);*/
+      return evaluation;
+    }
+
+    public static double EvaluateTankProgram(ISymbolicExpressionTree tree, ScopeList coevolutionIndividuals, XmlNode solutionCandidateRoot, string path) {
+      Random random = new Random();
+      string formattedPath = path.Replace("/", "\\");
+
+      // Interpret and compile main tree
+      //XmlNode mainTreeNode = solutionCandidateRoot.Clone();
+      //EvaluateTankProgram(tree.Root, mainTreeNode, null);
+      string interpretedMainTree = InterpretProgramTree(tree.Root);
+      string mainTreeName = writeTreeToFile(interpretedMainTree, path, random);
+      compileCodefile(/*mainTreeName,*/ mainTreeName, formattedPath);
+
+      // Interpret and compile coevolutionIndividuals
+      String[] coevolutionIndividualsNames = new String[coevolutionIndividuals.Count];
+      for (int i = 0; i < coevolutionIndividuals.Count; i++) {
+        //XmlNode individualTreeNode = solutionCandidateRoot.Clone();
+        //EvaluateTankProgram(((ISymbolicExpressionTree)coevolutionIndividuals[i].Variables.ToArray()[0].Value).Root, individualTreeNode, null);
+        string interpretedIndividual = InterpretProgramTree(((ISymbolicExpressionTree)coevolutionIndividuals[i].Variables.ToArray()[0].Value).Root);
+        coevolutionIndividualsNames[i] = writeTreeToFile(/*individualTreeNode,*/ interpretedIndividual, path, random);
+        compileCodefile(coevolutionIndividualsNames[i], formattedPath);
+      }
+
+      // Force Robocode to update its robot database by deleting the existing one
+      try { File.Delete(path + "/robots/robot.database"); }
+      catch (Exception e) { }
+
+      // Run evaluator
+      double evaluation = runEvaluator(mainTreeName, coevolutionIndividualsNames, formattedPath);
+      try {
+        File.Delete(path + "/robots/Evaluation/" + mainTreeName + ".java");
+        File.Delete(path + "/robots/Evaluation/" + mainTreeName + ".class");
+        foreach (string s in coevolutionIndividualsNames) {
+          File.Delete(path + "/robots/Evaluation/" + s + ".java");
+          File.Delete(path + "/robots/Evaluation/" + s + ".class");
         }
-
-        public static double EvaluateTankProgram(ISymbolicExpressionTree tree, XmlNode solutionCandidateRoot, 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
-
-            ProcessStartInfo javaCompileInfo = new ProcessStartInfo();
-            javaCompileInfo.FileName = "cmd.exe";
-            javaCompileInfo.Arguments = "/C javac -cp " + formattedPath + "\\libs\\robocode.jar " + formattedPath + "\\robots\\Evaluation\\" + outputname + ".java";
-            javaCompileInfo.RedirectStandardOutput = true;
-            javaCompileInfo.RedirectStandardError = true;
-            javaCompileInfo.UseShellExecute = false;
-            javaCompileInfo.CreateNoWindow = true;
-
-            Process javaCompile = new Process();
-            javaCompile.StartInfo = javaCompileInfo;
-            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();
-            #endregion
-
-
-            try
-            { File.Delete(path + "/robots/robot.database"); }
-            catch (Exception e) { }
-
-            #region evaluate code
-
-            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;
-            evaluateCodeInfo.UseShellExecute = false;
-            evaluateCodeInfo.CreateNoWindow = true;
-
-            Process evaluateCode = new Process();
-            evaluateCode.StartInfo = evaluateCodeInfo;
-            evaluateCode.Start();
-
-            // instead of p.WaitForExit(), do
-            StringBuilder q = new StringBuilder();
-            string scoreString = "";
-            while (!evaluateCode.HasExited)
-            {
-                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();
-
-            #endregion
-
-            double evaluation = -900;
-            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;
-
-            /*Evaluator.tankStatLog = "=====================================================\r\n";
-            Evaluator.tankStatLog += "START OF TREE - Score: " + evaluation + " (" + tankStats.shots + "/" + tankStats.moves + ")" + "\r\n" + " Compilation Output: " + cmdOutput + "\r\n";
-            Evaluator.tankStatLog += "=====================================================\r\n";
-
-            Evaluator.tankStatLog += solutionCandidateRoot.InnerText + "\r\n";
-
-            Evaluator.tankStatLog += "=====================================================\r\n";
-            Evaluator.tankStatLog += "END OF TREE\r\n";
-            Evaluator.tankStatLog += "=====================================================\r\n";
-
-            File.AppendAllText("../TankLog.txt", Evaluator.tankStatLog);*/
-            return evaluation;
+      }
+      catch (Exception e) { }
+      Random rand = new Random();
+      evaluation += rand.NextDouble() / 100;
+
+      return evaluation;
+    }
+
+    private static string writeTreeToFile(/*XmlNode node,*/ string interpretedTree, string path, Random random) {
+      string outputName = "";
+      string outputString = "";
+      bool noError = true;
+      do {
+        try {
+          outputName = new string(Enumerable.Repeat(chars, 8).Select(s => s[random.Next(s.Length)]).ToArray());
+          outputString = /*node.InnerText*/interpretedTree.Replace("class output", "class " + outputName);
+          File.WriteAllText(path + "/robots/Evaluation/" + outputName + ".java", outputString, System.Text.Encoding.Default);
+          noError = true;
         }
-
-        public static double EvaluateTankProgram(ISymbolicExpressionTree tree, ScopeList coevolutionIndividuals, XmlNode solutionCandidateRoot, string path)
-        {
-            Random random = new Random();
-            string formattedPath = path.Replace("/", "\\");
-
-            // Interpret and compile main tree
-            //XmlNode mainTreeNode = solutionCandidateRoot.Clone();
-            //EvaluateTankProgram(tree.Root, mainTreeNode, null);
-            string interpretedMainTree = InterpretProgramTree(tree.Root);
-            string mainTreeName = writeTreeToFile(interpretedMainTree, path, random);
-            compileCodefile(/*mainTreeName,*/ mainTreeName, formattedPath);
-
-            // Interpret and compile coevolutionIndividuals
-            String[] coevolutionIndividualsNames = new String[coevolutionIndividuals.Count];
-            for (int i = 0; i < coevolutionIndividuals.Count; i++)
-            {
-                //XmlNode individualTreeNode = solutionCandidateRoot.Clone();
-                //EvaluateTankProgram(((ISymbolicExpressionTree)coevolutionIndividuals[i].Variables.ToArray()[0].Value).Root, individualTreeNode, null);
-                string interpretedIndividual = InterpretProgramTree(((ISymbolicExpressionTree)coevolutionIndividuals[i].Variables.ToArray()[0].Value).Root);
-                coevolutionIndividualsNames[i] = writeTreeToFile(/*individualTreeNode,*/ interpretedIndividual, path, random);
-                compileCodefile(coevolutionIndividualsNames[i], formattedPath);
-            }
-            
-            // Force Robocode to update its robot database by deleting the existing one
-            try
-            { File.Delete(path + "/robots/robot.database"); }
-            catch (Exception e) { }
-
-            // Run evaluator
-            double evaluation = runEvaluator(mainTreeName, coevolutionIndividualsNames, formattedPath);
-            try
-            {
-                File.Delete(path + "/robots/Evaluation/" + mainTreeName + ".java");
-                File.Delete(path + "/robots/Evaluation/" + mainTreeName + ".class");
-                foreach (string s in coevolutionIndividualsNames)
-                {
-                    File.Delete(path + "/robots/Evaluation/" + s + ".java");
-                    File.Delete(path + "/robots/Evaluation/" + s + ".class");
-                }
-            }
-            catch (Exception e) { }
-            Random rand = new Random();
-            evaluation += rand.NextDouble() / 100;
-
-            return evaluation;
+        catch (Exception e) { noError = false; }
+      } while (!noError);
+
+      return outputName;
+    }
+
+    private static bool compileCodefile(string filename, string formattedPath) {
+      ProcessStartInfo javaCompileInfo = new ProcessStartInfo();
+      javaCompileInfo.FileName = "cmd.exe";
+      javaCompileInfo.Arguments = "/C javac -cp " + formattedPath + "\\libs\\robocode.jar " + formattedPath + "\\robots\\Evaluation\\" + filename + ".java";
+      javaCompileInfo.RedirectStandardOutput = true;
+      javaCompileInfo.RedirectStandardError = true;
+      javaCompileInfo.UseShellExecute = false;
+      javaCompileInfo.CreateNoWindow = true;
+
+      Process javaCompile = new Process();
+      javaCompile.StartInfo = javaCompileInfo;
+      javaCompile.Start();
+
+      string cmdOutput = javaCompile.StandardOutput.ReadToEnd();
+      cmdOutput += javaCompile.StandardError.ReadToEnd();
+
+      javaCompile.WaitForExit();
+
+      if (cmdOutput.Equals(""))
+        return true;
+      return false;
+    }
+
+    private static double runEvaluator(string mainTreeFilename, string[] coevolutionIndividualsNames, string formattedPath) {
+      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." + mainTreeFilename + "* ";
+      if (coevolutionIndividualsNames != null) {
+        foreach (string s in coevolutionIndividualsNames)
+          evaluateCodeInfo.Arguments += "Evaluation." + s + "* ";
+      } else
+        evaluateCodeInfo.Arguments += "false";
+      //Console.WriteLine(javaCompileInfo.Arguments);
+      evaluateCodeInfo.RedirectStandardOutput = true;
+      evaluateCodeInfo.RedirectStandardError = true;
+      evaluateCodeInfo.UseShellExecute = false;
+      evaluateCodeInfo.CreateNoWindow = true;
+
+      Process evaluateCode = new Process();
+      evaluateCode.StartInfo = evaluateCodeInfo;
+      evaluateCode.Start();
+
+      StringBuilder q = new StringBuilder();
+      string scoreString = "";
+      while (!evaluateCode.HasExited) {
+        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");
+      }
+      string cmdOutput = q.ToString();
+      try {
+        double evaluation = Double.Parse(scoreString);
+        return evaluation;
+      }
+      catch (Exception e) { }
+
+      return -900;
+    }
+
+    private static TankStats EvaluateTankProgram(ISymbolicExpressionTreeNode node, XmlNode docNode, string method) {
+      TankStats tankStats = new TankStats(0, 0);
+
+      //string log = "Doing node: \r\n";
+      /*if (node.Symbol is ProgramRootSymbol ||
+          node.Symbol is StartSymbol)
+          tankStats = EvaluateTankProgram(node.GetSubtree(0), ref docNode, null);
+      else*/
+      if (node.Symbol is Constant)
+        docNode[method]["code"].InnerText += " " + ((ConstantTreeNode)node).Value + " ";
+      else if (node.Symbol is ShotPower)
+        docNode[method]["code"].InnerText += " " + ((ShotPowerTreeNode)node).Value + " ";
+      else if (node.Symbol is LogicalValue)
+        docNode[method]["code"].InnerText += " " + ((BooleanTreeNode)node).Value.ToString().ToLower() + " ";
+      else if (node.Symbol is Block) {
+        docNode[method]["code"].InnerText += "{\r\n";
+        foreach (ISymbolicExpressionTreeNode n in node.Subtrees)
+          EvaluateTankProgram(n, docNode, method);
+        docNode[method]["code"].InnerText += "}\r\n";
+      } else if (node.Symbol is IfStatement) {
+        docNode[method]["code"].InnerText += "if(";
+        EvaluateTankProgram(node.GetSubtree(0), docNode, method);
+        docNode[method]["code"].InnerText += ")\r\n";
+        EvaluateTankProgram(node.GetSubtree(1), docNode, method);
+        if (node.SubtreeCount == 3)
+          EvaluateTankProgram(node.GetSubtree(2), docNode, method);
+      } else if (node.Symbol is ElseStatement) {
+        docNode[method]["code"].InnerText += "else\r\n";
+        if (node.SubtreeCount == 1)
+          EvaluateTankProgram(node.GetSubtree(0), docNode, method);
+      } else if (node.Symbol is WhileLoop) {
+        docNode[method]["code"].InnerText += "While(";
+        EvaluateTankProgram(node.GetSubtree(0), docNode, method);
+        docNode[method]["code"].InnerText += ")\r\n";
+        EvaluateTankProgram(node.GetSubtree(1), docNode, method);
+      } else if (node.Symbol is Ahead) {
+        docNode[method]["code"].InnerText += "setAhead(";
+        EvaluateTankProgram(node.GetSubtree(0), docNode, method);
+        docNode[method]["code"].InnerText += ");\r\n";
+        tankStats.moves = 1;
+      } else if (node.Symbol is Back) {
+        docNode[method]["code"].InnerText += "setBack(";
+        EvaluateTankProgram(node.GetSubtree(0), docNode, method);
+        docNode[method]["code"].InnerText += ");\r\n";
+        tankStats.moves = 1;
+      } else if (node.Symbol is SetAdjustGunForRobotTurn) {
+        docNode[method]["code"].InnerText += "setAdjustGunForRobotTurn(";
+        EvaluateTankProgram(node.GetSubtree(0), docNode, method);
+        docNode[method]["code"].InnerText += ");\r\n";
+        tankStats.moves = 1;
+      } else if (node.Symbol is SetAdjustRadarForGunTurn) {
+        docNode[method]["code"].InnerText += "setAdjustRadarForGunTurn(";
+        EvaluateTankProgram(node.GetSubtree(0), docNode, method);
+        docNode[method]["code"].InnerText += ");\r\n";
+        tankStats.moves = 1;
+      } else if (node.Symbol is SetAdjustRadarForRobotTurn) {
+        docNode[method]["code"].InnerText += "setAdjustRadarForRobotTurn(";
+        EvaluateTankProgram(node.GetSubtree(0), docNode, method);
+        docNode[method]["code"].InnerText += ");\r\n";
+        tankStats.moves = 1;
+      } else if (node.Symbol is TurnGunLeft) {
+        docNode[method]["code"].InnerText += "setTurnGunLeft(";
+        EvaluateTankProgram(node.GetSubtree(0), docNode, method);
+        docNode[method]["code"].InnerText += ");\r\n";
+        tankStats.moves = 1;
+      } else if (node.Symbol is TurnGunRight) {
+        docNode[method]["code"].InnerText += "setTurnGunRight(";
+        EvaluateTankProgram(node.GetSubtree(0), docNode, method);
+        docNode[method]["code"].InnerText += ");\r\n";
+        tankStats.moves = 1;
+      } else if (node.Symbol is TurnLeft) {
+        docNode[method]["code"].InnerText += "setTurnLeft(";
+        EvaluateTankProgram(node.GetSubtree(0), docNode, method);
+        docNode[method]["code"].InnerText += ");\r\n";
+        tankStats.moves = 1;
+      } else if (node.Symbol is TurnRadarLeft) {
+        docNode[method]["code"].InnerText += "setTurnRadarLeft(";
+        EvaluateTankProgram(node.GetSubtree(0), docNode, method);
+        docNode[method]["code"].InnerText += ");\r\n";
+        tankStats.moves = 1;
+      } else if (node.Symbol is TurnRadarRight) {
+        docNode[method]["code"].InnerText += "setTurnRadarRight(";
+        EvaluateTankProgram(node.GetSubtree(0), docNode, method);
+        docNode[method]["code"].InnerText += ");\r\n";
+        tankStats.moves = 1;
+      } else if (node.Symbol is TurnRight) {
+        docNode[method]["code"].InnerText += "setTurnRight(";
+        EvaluateTankProgram(node.GetSubtree(0), docNode, method);
+        docNode[method]["code"].InnerText += ");\r\n";
+        tankStats.moves = 1;
+      } else if (node.Symbol is Fire) {
+        docNode[method]["code"].InnerText += "setFire(";
+        EvaluateTankProgram(node.GetSubtree(0), docNode, method);
+        docNode[method]["code"].InnerText += ");\r\n";
+        tankStats.shots = 1;
+      } else if (node.Symbol is Run ||
+            node.Symbol is OnBulletHit ||
+            node.Symbol is OnBulletMissed ||
+            node.Symbol is OnHitByBullet ||
+            node.Symbol is OnHitRobot ||
+            node.Symbol is OnHitWall ||
+            node.Symbol is OnScannedRobot) {
+        tankStats = new TankStats();
+        foreach (SymbolicExpressionTreeNode n in node.Subtrees) {
+          string methodName = node.Symbol.GetType().ToString().Split('.').Last();
+          try {
+            var tempStats = EvaluateTankProgram(n, docNode, methodName);
+            tankStats.moves += tempStats.moves;
+            tankStats.shots += tempStats.shots;
+          }
+          catch (Exception e) {
+            //log += "NULL EXCEPTION ON:::::::: -" + methodName + "-\r\n";
+            //foreach (XmlNode f in docNode[methodName])
+            //    log += f.Name + "\r\n";
+          }
         }
-
-        private static string writeTreeToFile(/*XmlNode node,*/ string interpretedTree, string path, Random random)
-        {
-            string outputName = "";
-            string outputString = "";
-            bool noError = true;
-            do
-            {
-                try
-                {
-                    outputName = new string(Enumerable.Repeat(chars, 8).Select(s => s[random.Next(s.Length)]).ToArray());
-                    outputString = /*node.InnerText*/interpretedTree.Replace("class output", "class " + outputName);
-                    File.WriteAllText(path + "/robots/Evaluation/" + outputName + ".java", outputString, System.Text.Encoding.Default);
-                    noError = true;
-                }
-                catch (Exception e) { noError = false; }
-            } while (!noError);
-
-            return outputName;
+      } else if (node.Symbol is Tank) {
+        foreach (SymbolicExpressionTreeNode n in node.Subtrees) {
+          try {
+            var tempStats = EvaluateTankProgram(n, docNode, method);
+            tankStats.moves += tempStats.moves;
+            tankStats.shots += tempStats.shots;
+          }
+          catch (Exception e) { }
         }
-
-        private static bool compileCodefile(string filename, string formattedPath)
-        {
-            ProcessStartInfo javaCompileInfo = new ProcessStartInfo();
-            javaCompileInfo.FileName = "cmd.exe";
-            javaCompileInfo.Arguments = "/C javac -cp " + formattedPath + "\\libs\\robocode.jar " + formattedPath + "\\robots\\Evaluation\\" + filename + ".java";
-            javaCompileInfo.RedirectStandardOutput = true;
-            javaCompileInfo.RedirectStandardError = true;
-            javaCompileInfo.UseShellExecute = false;
-            javaCompileInfo.CreateNoWindow = true;
-
-            Process javaCompile = new Process();
-            javaCompile.StartInfo = javaCompileInfo;
-            javaCompile.Start();
-
-            string cmdOutput = javaCompile.StandardOutput.ReadToEnd();
-            cmdOutput += javaCompile.StandardError.ReadToEnd();
-
-            javaCompile.WaitForExit();
-
-            if (cmdOutput.Equals(""))
-                return true;
-            return false;
-        }
-
-        private static double runEvaluator(string mainTreeFilename, string[] coevolutionIndividualsNames, string formattedPath)
-        {
-            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." + mainTreeFilename + "* ";
-            if (coevolutionIndividualsNames != null)
-            {
-                foreach (string s in coevolutionIndividualsNames)
-                    evaluateCodeInfo.Arguments += "Evaluation." + s + "* ";
-            }
-            else
-                evaluateCodeInfo.Arguments += "false";
-            //Console.WriteLine(javaCompileInfo.Arguments);
-            evaluateCodeInfo.RedirectStandardOutput = true;
-            evaluateCodeInfo.RedirectStandardError = true;
-            evaluateCodeInfo.UseShellExecute = false;
-            evaluateCodeInfo.CreateNoWindow = true;
-
-            Process evaluateCode = new Process();
-            evaluateCode.StartInfo = evaluateCodeInfo;
-            evaluateCode.Start();
-
-            StringBuilder q = new StringBuilder();
-            string scoreString = "";
-            while (!evaluateCode.HasExited)
-            {
-                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");
-            }
-            string cmdOutput = q.ToString();
-            try
-            {
-                double evaluation = Double.Parse(scoreString);
-                return evaluation;
-            }
-            catch (Exception e) { }
-
-            return -900;
-        }
-        
-        private static TankStats EvaluateTankProgram(ISymbolicExpressionTreeNode node, XmlNode docNode, string method)
-        {
-            TankStats tankStats = new TankStats(0, 0);
-
-            //string log = "Doing node: \r\n";
-            /*if (node.Symbol is ProgramRootSymbol ||
-                node.Symbol is StartSymbol)
-                tankStats = EvaluateTankProgram(node.GetSubtree(0), ref docNode, null);
-            else*/
-            if (node.Symbol is Constant)
-                docNode[method]["code"].InnerText += " " + ((ConstantTreeNode)node).Value + " ";
-            else if (node.Symbol is ShotPower)
-                docNode[method]["code"].InnerText += " " + ((ShotPowerTreeNode)node).Value + " ";
-            else if (node.Symbol is LogicalValue)
-                docNode[method]["code"].InnerText += " " + ((BooleanTreeNode)node).Value.ToString().ToLower() + " ";
-            else if (node.Symbol is Block)
-            {
-                docNode[method]["code"].InnerText += "{\r\n";
-                foreach (ISymbolicExpressionTreeNode n in node.Subtrees)
-                    EvaluateTankProgram(n, docNode, method);
-                docNode[method]["code"].InnerText += "}\r\n";
-            }
-            else if (node.Symbol is IfStatement)
-            {
-                docNode[method]["code"].InnerText += "if(";
-                EvaluateTankProgram(node.GetSubtree(0), docNode, method);
-                docNode[method]["code"].InnerText += ")\r\n";
-                EvaluateTankProgram(node.GetSubtree(1), docNode, method);
-                if (node.SubtreeCount == 3)
-                    EvaluateTankProgram(node.GetSubtree(2), docNode, method);
-            }
-            else if (node.Symbol is ElseStatement)
-            {
-                docNode[method]["code"].InnerText += "else\r\n";
-                if (node.SubtreeCount == 1)
-                    EvaluateTankProgram(node.GetSubtree(0), docNode, method);
-            }
-            else if (node.Symbol is WhileLoop)
-            {
-                docNode[method]["code"].InnerText += "While(";
-                EvaluateTankProgram(node.GetSubtree(0), docNode, method);
-                docNode[method]["code"].InnerText += ")\r\n";
-                EvaluateTankProgram(node.GetSubtree(1), docNode, method);
-            }
-            else if (node.Symbol is Ahead)
-            {
-                docNode[method]["code"].InnerText += "setAhead(";
-                EvaluateTankProgram(node.GetSubtree(0), docNode, method);
-                docNode[method]["code"].InnerText += ");\r\n";
-                tankStats.moves = 1;
-            }
-            else if (node.Symbol is Back)
-            {
-                docNode[method]["code"].InnerText += "setBack(";
-                EvaluateTankProgram(node.GetSubtree(0), docNode, method);
-                docNode[method]["code"].InnerText += ");\r\n";
-                tankStats.moves = 1;
-            }
-            else if (node.Symbol is SetAdjustGunForRobotTurn)
-            {
-                docNode[method]["code"].InnerText += "setAdjustGunForRobotTurn(";
-                EvaluateTankProgram(node.GetSubtree(0), docNode, method);
-                docNode[method]["code"].InnerText += ");\r\n";
-                tankStats.moves = 1;
-            }
-            else if (node.Symbol is SetAdjustRadarForGunTurn)
-            {
-                docNode[method]["code"].InnerText += "setAdjustRadarForGunTurn(";
-                EvaluateTankProgram(node.GetSubtree(0), docNode, method);
-                docNode[method]["code"].InnerText += ");\r\n";
-                tankStats.moves = 1;
-            }
-            else if (node.Symbol is SetAdjustRadarForRobotTurn)
-            {
-                docNode[method]["code"].InnerText += "setAdjustRadarForRobotTurn(";
-                EvaluateTankProgram(node.GetSubtree(0), docNode, method);
-                docNode[method]["code"].InnerText += ");\r\n";
-                tankStats.moves = 1;
-            }
-            else if (node.Symbol is TurnGunLeft)
-            {
-                docNode[method]["code"].InnerText += "setTurnGunLeft(";
-                EvaluateTankProgram(node.GetSubtree(0), docNode, method);
-                docNode[method]["code"].InnerText += ");\r\n";
-                tankStats.moves = 1;
-            }
-            else if (node.Symbol is TurnGunRight)
-            {
-                docNode[method]["code"].InnerText += "setTurnGunRight(";
-                EvaluateTankProgram(node.GetSubtree(0), docNode, method);
-                docNode[method]["code"].InnerText += ");\r\n";
-                tankStats.moves = 1;
-            }
-            else if (node.Symbol is TurnLeft)
-            {
-                docNode[method]["code"].InnerText += "setTurnLeft(";
-                EvaluateTankProgram(node.GetSubtree(0), docNode, method);
-                docNode[method]["code"].InnerText += ");\r\n";
-                tankStats.moves = 1;
-            }
-            else if (node.Symbol is TurnRadarLeft)
-            {
-                docNode[method]["code"].InnerText += "setTurnRadarLeft(";
-                EvaluateTankProgram(node.GetSubtree(0), docNode, method);
-                docNode[method]["code"].InnerText += ");\r\n";
-                tankStats.moves = 1;
-            }
-            else if (node.Symbol is TurnRadarRight)
-            {
-                docNode[method]["code"].InnerText += "setTurnRadarRight(";
-                EvaluateTankProgram(node.GetSubtree(0), docNode, method);
-                docNode[method]["code"].InnerText += ");\r\n";
-                tankStats.moves = 1;
-            }
-            else if (node.Symbol is TurnRight)
-            {
-                docNode[method]["code"].InnerText += "setTurnRight(";
-                EvaluateTankProgram(node.GetSubtree(0), docNode, method);
-                docNode[method]["code"].InnerText += ");\r\n";
-                tankStats.moves = 1;
-            }
-            else if (node.Symbol is Fire)
-            {
-                docNode[method]["code"].InnerText += "setFire(";
-                EvaluateTankProgram(node.GetSubtree(0), docNode, method);
-                docNode[method]["code"].InnerText += ");\r\n";
-                tankStats.shots = 1;
-            }
-            else if (node.Symbol is Run ||
-                node.Symbol is OnBulletHit ||
-                node.Symbol is OnBulletMissed ||
-                node.Symbol is OnHitByBullet ||
-                node.Symbol is OnHitRobot ||
-                node.Symbol is OnHitWall ||
-                node.Symbol is OnScannedRobot)
-            {
-                tankStats = new TankStats();
-                foreach (SymbolicExpressionTreeNode n in node.Subtrees)
-                {
-                    string methodName = node.Symbol.GetType().ToString().Split('.').Last();
-                    try
-                    {
-                        var tempStats = EvaluateTankProgram(n, docNode, methodName);
-                        tankStats.moves += tempStats.moves;
-                        tankStats.shots += tempStats.shots;
-                    }
-                    catch (Exception e)
-                    {
-                        //log += "NULL EXCEPTION ON:::::::: -" + methodName + "-\r\n";
-                        //foreach (XmlNode f in docNode[methodName])
-                        //    log += f.Name + "\r\n";
-                    }
-                }
-            }
-            else if (node.Symbol is Tank)
-            {
-                foreach (SymbolicExpressionTreeNode n in node.Subtrees)
-                {
-                    try
-                    {
-                        var tempStats = EvaluateTankProgram(n, docNode, method);
-                        tankStats.moves += tempStats.moves;
-                        tankStats.shots += tempStats.shots;
-                    }
-                    catch (Exception e) { }
-                }
-            }
-            else
-                tankStats = EvaluateTankProgram(node.GetSubtree(0), docNode, null);
-
-            //log += tankStats.shots + " / " + tankStats.moves + "\r\n";
-            //File.AppendAllText("../TankLog.txt", log);
-
-            return tankStats;
-        }
-
-        public static string InterpretProgramTree(ISymbolicExpressionTreeNode node)
-        {
-            var tankNode = node;
-            while (!(tankNode.Symbol is Tank))
-                tankNode = tankNode.GetSubtree(0);
-            return ((CodeNode)tankNode.Symbol).Interpret(tankNode, tankNode.Subtrees);
-        }
-    }
+      } else
+        tankStats = EvaluateTankProgram(node.GetSubtree(0), docNode, null);
+
+      //log += tankStats.shots + " / " + tankStats.moves + "\r\n";
+      //File.AppendAllText("../TankLog.txt", log);
+
+      return tankStats;
+    }
+
+    public static string InterpretProgramTree(ISymbolicExpressionTreeNode node) {
+      var tankNode = node;
+      while (!(tankNode.Symbol is Tank))
+        tankNode = tankNode.GetSubtree(0);
+      return ((CodeNode)tankNode.Symbol).Interpret(tankNode, tankNode.Subtrees);
+    }
+  }
 }
Index: branches/Robocode/HeuristicLab.Problems.Robocode/Solution.cs
===================================================================
--- branches/Robocode/HeuristicLab.Problems.Robocode/Solution.cs	(revision 9570)
+++ branches/Robocode/HeuristicLab.Problems.Robocode/Solution.cs	(revision 9601)
@@ -4,65 +4,47 @@
 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
 
-namespace HeuristicLab.Problems.Robocode
-{
-    [StorableClass]
-    public sealed class Solution : NamedItem
-    {
-        //private int moves;
-        //[Storable]
-        //public int Moves
-        //{
-        //    get { return moves; }
-        //    private set { this.moves = value; }
-        //}
-        //private int shots;
-        //[Storable]
-        //public int Shots
-        //{
-        //    get { return shots; }
-        //    private set { this.shots = value; }
-        //}
-        private ISymbolicExpressionTree tree;
-        [Storable]
-        public ISymbolicExpressionTree Tree
-        {
-            get { return tree; }
-            private set { this.tree = value; }
-        }
+namespace HeuristicLab.Problems.Robocode {
+  [StorableClass]
+  public sealed class Solution : NamedItem {
+    //private int moves;
+    //[Storable]
+    //public int Moves
+    //{
+    //    get { return moves; }
+    //    private set { this.moves = value; }
+    //}
+    //private int shots;
+    //[Storable]
+    //public int Shots
+    //{
+    //    get { return shots; }
+    //    private set { this.shots = value; }
+    //}
+    [Storable]
+    public ISymbolicExpressionTree Tree { get; set; }
 
-        private string path;
-        [Storable]
-        public string Path
-        {
-            get { return path; }
-            private set { this.path = value; }
-        }
+    [Storable]
+    public string Path { get; set; }
 
-        [StorableConstructor]
-        private Solution(bool deserializing) : base(deserializing) { }
-        private Solution(Solution original, Cloner cloner)
-            : base(original, cloner)
-        {
-            //this.moves = original.moves;
-            //this.shots = original.shots;
-            this.tree = cloner.Clone(tree);
-        }
+    [StorableConstructor]
+    private Solution(bool deserializing) : base(deserializing) { }
+    private Solution(Solution original, Cloner cloner)
+      : base(original, cloner) {
 
-        public Solution(ISymbolicExpressionTree tree, string path)// int moves, int shots)
-            : base("Solution", "A tank program.")
-        {
-            this.tree = tree;
-            this.path = path;
-            //this.moves = moves;
-            //this.shots = shots;
-        }
-        [StorableHook(HookType.AfterDeserialization)]
-        private void AfterDeserialization()
-        {
-        }
-        public override IDeepCloneable Clone(Cloner cloner)
-        {
-            return new Solution(this, cloner);
-        }
+      Tree = cloner.Clone(original.Tree);
+      Path = original.Path;
     }
+
+    public Solution(ISymbolicExpressionTree tree, string path)// int moves, int shots)
+      : base("Solution", "A tank program.") {
+      this.Tree = tree;
+      this.Path = path;
+      //this.moves = moves;
+      //this.shots = shots;
+    }
+
+    public override IDeepCloneable Clone(Cloner cloner) {
+      return new Solution(this, cloner);
+    }
+  }
 }
Index: branches/Robocode/HeuristicLab.Problems.Robocode/Symbols/CodeNodeView.cs
===================================================================
--- branches/Robocode/HeuristicLab.Problems.Robocode/Symbols/CodeNodeView.cs	(revision 9570)
+++ branches/Robocode/HeuristicLab.Problems.Robocode/Symbols/CodeNodeView.cs	(revision 9601)
@@ -1,64 +1,44 @@
 ﻿using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Drawing;
-using System.Data;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
 using System.Windows.Forms;
 using HeuristicLab.Core.Views;
-using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views;
 using HeuristicLab.MainForm;
-using System.Diagnostics;
-using System.IO;
-using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
 
 
-namespace HeuristicLab.Problems.Robocode
-{
-    [View("CodeNode View")]
-    [Content(typeof(CodeNode), IsDefaultView = true)]
-    public partial class CodeNodeView : NamedItemView
-    {
-        public CodeNode Content
-        {
-            get { return (CodeNode)base.Content; }
-            set { base.Content = value; }
-        }
+namespace HeuristicLab.Problems.Robocode {
+  [View("CodeNode View")]
+  [Content(typeof(CodeNode), IsDefaultView = true)]
+  public partial class CodeNodeView : NamedItemView {
+    public new CodeNode Content {
+      get { return (CodeNode)base.Content; }
+      set { base.Content = value; }
+    }
 
-        public CodeNodeView() : base()
-        {
-            InitializeComponent();
-            //this.prefixCode.Text = Content.Prefix;
-            //this.suffixCode.Text = Content.Suffix;
-        }
+    public CodeNodeView()
+      : base() {
+      InitializeComponent();
+      //this.prefixCode.Text = Content.Prefix;
+      //this.suffixCode.Text = Content.Suffix;
+    }
 
-        protected override void OnContentChanged()
-        {
-            base.OnContentChanged();
-            if (Content == null)
-            {
-                this.prefixCode.Text = "";
-                this.suffixCode.Text = "";
-            }
-            else
-            {
-                this.prefixCode.Text = Content.Prefix;
-                this.suffixCode.Text = Content.Suffix;
-                //Content.Prefix = this.prefixCode.Text;
-                //Content.Suffix = this.suffixCode.Text;
-            }
-        }
+    protected override void OnContentChanged() {
+      base.OnContentChanged();
+      if (Content == null) {
+        this.prefixCode.Text = "";
+        this.suffixCode.Text = "";
+      } else {
+        this.prefixCode.Text = Content.Prefix;
+        this.suffixCode.Text = Content.Suffix;
+        //Content.Prefix = this.prefixCode.Text;
+        //Content.Suffix = this.suffixCode.Text;
+      }
+    }
 
-        private void prefixCode_Leave(object sender, EventArgs e)
-        {
-            Content.Prefix = this.prefixCode.Text;
-        }
+    private void prefixCode_Leave(object sender, EventArgs e) {
+      Content.Prefix = this.prefixCode.Text;
+    }
 
-        private void suffixCode_Leave(object sender, EventArgs e)
-        {
-            Content.Suffix = this.suffixCode.Text;
-        }
+    private void suffixCode_Leave(object sender, EventArgs e) {
+      Content.Suffix = this.suffixCode.Text;
     }
+  }
 }
