Free cookie consent management tool by TermsFeed Policy Generator

Changeset 9889


Ignore:
Timestamp:
08/21/13 14:38:09 (11 years ago)
Author:
ascheibe
Message:

#2069 cleaned up views

Location:
branches/Robocode.TrunkInt
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode.Views/3.3/CodeNodeView.Designer.cs

    r9781 r9889  
    2929        private void InitializeComponent()
    3030        {
    31           this.prefixCode = new System.Windows.Forms.TextBox();
    32           this.prefixLabel = new System.Windows.Forms.Label();
    33           this.suffixLabel = new System.Windows.Forms.Label();
    34           this.suffixCode = new System.Windows.Forms.TextBox();
    35           ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    36           this.SuspendLayout();
    37           //
    38           // nameTextBox
    39           //
    40           this.errorProvider.SetIconAlignment(this.nameTextBox, System.Windows.Forms.ErrorIconAlignment.MiddleLeft);
    41           this.errorProvider.SetIconPadding(this.nameTextBox, 2);
    42           this.nameTextBox.Visible = false;
    43           //
    44           // nameLabel
    45           //
    46           this.nameLabel.Visible = false;
    47           //
    48           // infoLabel
    49           //
    50           this.infoLabel.Visible = false;
    51           //
    52           // prefixCode
    53           //
    54           this.prefixCode.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    55                       | System.Windows.Forms.AnchorStyles.Right)));
    56           this.prefixCode.Font = new System.Drawing.Font("Consolas", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
    57           this.prefixCode.Location = new System.Drawing.Point(6, 19);
    58           this.prefixCode.Multiline = true;
    59           this.prefixCode.Name = "prefixCode";
    60           this.prefixCode.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
    61           this.prefixCode.Size = new System.Drawing.Size(333, 93);
    62           this.prefixCode.TabIndex = 3;
    63           this.prefixCode.Validated += new System.EventHandler(this.prefixCode_Validated);
    64           //
    65           // prefixLabel
    66           //
    67           this.prefixLabel.AutoSize = true;
    68           this.prefixLabel.Location = new System.Drawing.Point(3, 3);
    69           this.prefixLabel.Name = "prefixLabel";
    70           this.prefixLabel.Size = new System.Drawing.Size(33, 13);
    71           this.prefixLabel.TabIndex = 4;
    72           this.prefixLabel.Text = "Prefix";
    73           //
    74           // suffixLabel
    75           //
    76           this.suffixLabel.AutoSize = true;
    77           this.suffixLabel.Location = new System.Drawing.Point(6, 115);
    78           this.suffixLabel.Name = "suffixLabel";
    79           this.suffixLabel.Size = new System.Drawing.Size(33, 13);
    80           this.suffixLabel.TabIndex = 5;
    81           this.suffixLabel.Text = "Suffix";
    82           //
    83           // suffixCode
    84           //
    85           this.suffixCode.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    86                       | System.Windows.Forms.AnchorStyles.Right)));
    87           this.suffixCode.Location = new System.Drawing.Point(6, 131);
    88           this.suffixCode.Multiline = true;
    89           this.suffixCode.Name = "suffixCode";
    90           this.suffixCode.ScrollBars = System.Windows.Forms.ScrollBars.Horizontal;
    91           this.suffixCode.Size = new System.Drawing.Size(333, 87);
    92           this.suffixCode.TabIndex = 6;
    93           this.suffixCode.Validated += new System.EventHandler(this.suffixCode_Validated);
    94           //
    95           // CodeNodeView
    96           //
    97           this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
    98           this.Controls.Add(this.suffixCode);
    99           this.Controls.Add(this.suffixLabel);
    100           this.Controls.Add(this.prefixLabel);
    101           this.Controls.Add(this.prefixCode);
    102           this.Name = "CodeNodeView";
    103           this.Size = new System.Drawing.Size(351, 238);
    104           this.Controls.SetChildIndex(this.nameLabel, 0);
    105           this.Controls.SetChildIndex(this.nameTextBox, 0);
    106           this.Controls.SetChildIndex(this.infoLabel, 0);
    107           this.Controls.SetChildIndex(this.prefixCode, 0);
    108           this.Controls.SetChildIndex(this.prefixLabel, 0);
    109           this.Controls.SetChildIndex(this.suffixLabel, 0);
    110           this.Controls.SetChildIndex(this.suffixCode, 0);
    111           ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
    112           this.ResumeLayout(false);
    113           this.PerformLayout();
     31      this.prefixCode = new System.Windows.Forms.TextBox();
     32      this.prefixLabel = new System.Windows.Forms.Label();
     33      this.suffixLabel = new System.Windows.Forms.Label();
     34      this.suffixCode = new System.Windows.Forms.TextBox();
     35      this.splitContainer = new System.Windows.Forms.SplitContainer();
     36      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
     37      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
     38      this.splitContainer.Panel1.SuspendLayout();
     39      this.splitContainer.Panel2.SuspendLayout();
     40      this.splitContainer.SuspendLayout();
     41      this.SuspendLayout();
     42      //
     43      // nameTextBox
     44      //
     45      this.errorProvider.SetIconAlignment(this.nameTextBox, System.Windows.Forms.ErrorIconAlignment.MiddleLeft);
     46      this.errorProvider.SetIconPadding(this.nameTextBox, 2);
     47      this.nameTextBox.Size = new System.Drawing.Size(508, 20);
     48      this.nameTextBox.Visible = false;
     49      //
     50      // nameLabel
     51      //
     52      this.nameLabel.Visible = false;
     53      //
     54      // infoLabel
     55      //
     56      this.infoLabel.Location = new System.Drawing.Point(572, 3);
     57      this.infoLabel.Visible = false;
     58      //
     59      // prefixCode
     60      //
     61      this.prefixCode.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     62            | System.Windows.Forms.AnchorStyles.Left)
     63            | System.Windows.Forms.AnchorStyles.Right)));
     64      this.prefixCode.Font = new System.Drawing.Font("Consolas", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     65      this.prefixCode.Location = new System.Drawing.Point(6, 16);
     66      this.prefixCode.Multiline = true;
     67      this.prefixCode.Name = "prefixCode";
     68      this.prefixCode.ScrollBars = System.Windows.Forms.ScrollBars.Both;
     69      this.prefixCode.Size = new System.Drawing.Size(573, 100);
     70      this.prefixCode.TabIndex = 3;
     71      this.prefixCode.Validated += new System.EventHandler(this.prefixCode_Validated);
     72      //
     73      // prefixLabel
     74      //
     75      this.prefixLabel.AutoSize = true;
     76      this.prefixLabel.Location = new System.Drawing.Point(3, 0);
     77      this.prefixLabel.Name = "prefixLabel";
     78      this.prefixLabel.Size = new System.Drawing.Size(33, 13);
     79      this.prefixLabel.TabIndex = 4;
     80      this.prefixLabel.Text = "Prefix";
     81      //
     82      // suffixLabel
     83      //
     84      this.suffixLabel.AutoSize = true;
     85      this.suffixLabel.Location = new System.Drawing.Point(3, 0);
     86      this.suffixLabel.Name = "suffixLabel";
     87      this.suffixLabel.Size = new System.Drawing.Size(33, 13);
     88      this.suffixLabel.TabIndex = 5;
     89      this.suffixLabel.Text = "Suffix";
     90      //
     91      // suffixCode
     92      //
     93      this.suffixCode.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     94            | System.Windows.Forms.AnchorStyles.Left)
     95            | System.Windows.Forms.AnchorStyles.Right)));
     96      this.suffixCode.Location = new System.Drawing.Point(6, 16);
     97      this.suffixCode.Multiline = true;
     98      this.suffixCode.Name = "suffixCode";
     99      this.suffixCode.ScrollBars = System.Windows.Forms.ScrollBars.Both;
     100      this.suffixCode.Size = new System.Drawing.Size(573, 96);
     101      this.suffixCode.TabIndex = 6;
     102      this.suffixCode.Validated += new System.EventHandler(this.suffixCode_Validated);
     103      //
     104      // splitContainer
     105      //
     106      this.splitContainer.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     107            | System.Windows.Forms.AnchorStyles.Left)
     108            | System.Windows.Forms.AnchorStyles.Right)));
     109      this.splitContainer.Location = new System.Drawing.Point(6, 26);
     110      this.splitContainer.Name = "splitContainer";
     111      this.splitContainer.Orientation = System.Windows.Forms.Orientation.Horizontal;
     112      //
     113      // splitContainer.Panel1
     114      //
     115      this.splitContainer.Panel1.Controls.Add(this.prefixLabel);
     116      this.splitContainer.Panel1.Controls.Add(this.prefixCode);
     117      //
     118      // splitContainer.Panel2
     119      //
     120      this.splitContainer.Panel2.Controls.Add(this.suffixLabel);
     121      this.splitContainer.Panel2.Controls.Add(this.suffixCode);
     122      this.splitContainer.Size = new System.Drawing.Size(582, 238);
     123      this.splitContainer.SplitterDistance = 119;
     124      this.splitContainer.TabIndex = 7;
     125      //
     126      // CodeNodeView
     127      //
     128      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
     129      this.Controls.Add(this.splitContainer);
     130      this.Name = "CodeNodeView";
     131      this.Size = new System.Drawing.Size(591, 267);
     132      this.Controls.SetChildIndex(this.nameLabel, 0);
     133      this.Controls.SetChildIndex(this.nameTextBox, 0);
     134      this.Controls.SetChildIndex(this.infoLabel, 0);
     135      this.Controls.SetChildIndex(this.splitContainer, 0);
     136      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
     137      this.splitContainer.Panel1.ResumeLayout(false);
     138      this.splitContainer.Panel1.PerformLayout();
     139      this.splitContainer.Panel2.ResumeLayout(false);
     140      this.splitContainer.Panel2.PerformLayout();
     141      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).EndInit();
     142      this.splitContainer.ResumeLayout(false);
     143      this.ResumeLayout(false);
     144      this.PerformLayout();
    114145
    115146        }
     
    121152        private System.Windows.Forms.Label suffixLabel;
    122153        private System.Windows.Forms.TextBox suffixCode;
     154        private System.Windows.Forms.SplitContainer splitContainer;
    123155    }
    124156}
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode.Views/3.3/CodeNodeView.cs

    r9790 r9889  
    2121
    2222using System;
    23 using System.Windows.Forms;
    2423using HeuristicLab.Core.Views;
    2524using HeuristicLab.MainForm;
    26 
    2725
    2826namespace HeuristicLab.Problems.Robocode {
     
    4341      base.OnContentChanged();
    4442      if (Content == null) {
    45         this.prefixCode.Text = "";
    46         this.suffixCode.Text = "";
     43        this.prefixCode.Text = string.Empty;
     44        this.suffixCode.Text = string.Empty;
    4745      } else {
    4846        this.prefixCode.Text = Content.Prefix;
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode.Views/3.3/CodeNodeView.resx

    r9781 r9889  
    119119  </resheader>
    120120  <metadata name="errorProvider.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
    121     <value>107, 17</value>
    122   </metadata>
    123   <metadata name="errorProvider.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
    124     <value>107, 17</value>
     121    <value>17, 17</value>
    125122  </metadata>
    126123  <metadata name="toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
    127     <value>17, 17</value>
     124    <value>140, 17</value>
    128125  </metadata>
    129126</root>
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode.Views/3.3/HeuristicLab.Problems.Robocode.Views-3.3.csproj

    r9787 r9889  
    131131      <DependentUpon>SolutionCodeView.cs</DependentUpon>
    132132    </EmbeddedResource>
     133    <EmbeddedResource Include="SolutionProgramView.resx">
     134      <DependentUpon>SolutionProgramView.cs</DependentUpon>
     135    </EmbeddedResource>
    133136  </ItemGroup>
    134137  <ItemGroup>
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode.Views/3.3/SolutionCodeView.cs

    r9880 r9889  
    2121
    2222using System;
    23 using System.Diagnostics;
    24 using System.IO;
    25 using System.Windows.Forms;
    2623using HeuristicLab.Core.Views;
    2724using HeuristicLab.MainForm;
    28 
    2925
    3026namespace HeuristicLab.Problems.Robocode {
     
    3228  [Content(typeof(Solution), IsDefaultView = true)]
    3329  public partial class SolutionCodeView : NamedItemView {
    34     private string Path { get; set; }
    35 
    3630    public new Solution Content {
    3731      get { return (Solution)base.Content; }
     
    4236      : base() {
    4337      InitializeComponent();
    44       this.Path = "c:/robocode/";
    45       this.programCode.Text = "";
    4638    }
    4739
     
    4941      base.OnContentChanged();
    5042      if (Content == null) {
    51         this.programCode.Text = "";
     43        this.programCode.Text = string.Empty;
    5244      } else {
    53         this.Path = Content.Path;
    54         string code = Interpreter.InterpretProgramTree(Content.Tree.Root);
    55         code = code.Replace("class output extends", "class BestSolution extends");
    56         this.programCode.Text = code;
    57         File.AppendAllText(Path + "/robots/Evaluation/PreviousBestSolution.java", "\r\n/**********************************************/\r\n" + code);
    58         File.WriteAllText(Path + "/robots/Evaluation/BestSolution.java", code, System.Text.Encoding.Default);
     45        this.programCode.Text = Interpreter.InterpretProgramTree(Content.Tree.Root, "BestSolution");
    5946      }
    6047    }
    6148
    6249    private void btnRunInRobocode_Click(object sender, EventArgs e) {
    63       string formattedPath = Path.Replace("/", "\\");
    64       ProcessStartInfo javaCompileInfo = new ProcessStartInfo();
    65       javaCompileInfo.FileName = "cmd.exe";
    66       javaCompileInfo.Arguments = "/C javac -cp " + formattedPath + "\\libs\\robocode.jar " + formattedPath + "\\robots\\Evaluation\\BestSolution.java";
    67       javaCompileInfo.RedirectStandardOutput = true;
    68       javaCompileInfo.RedirectStandardError = true;
    69       javaCompileInfo.UseShellExecute = false;
    70       javaCompileInfo.CreateNoWindow = true;
    71 
    72       Process javaCompile = new Process();
    73       javaCompile.StartInfo = javaCompileInfo;
    74       javaCompile.Start();
    75       javaCompile.WaitForExit();
    76 
    77       ProcessStartInfo evaluateCodeInfo = new ProcessStartInfo();
    78       evaluateCodeInfo.FileName = "cmd.exe";
    79       //javaCompileInfo.Arguments = "/C javac -cp C:\\robocode\\libs\\robocode.jar \"" + path + "\\Spaced Up\\output.java\"";
    80       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.BestSolution*";
    81       //Console.WriteLine(javaCompileInfo.Arguments);
    82       evaluateCodeInfo.RedirectStandardOutput = true;
    83       evaluateCodeInfo.RedirectStandardError = true;
    84       evaluateCodeInfo.UseShellExecute = false;
    85 
    86       Process evaluateCode = new Process();
    87       evaluateCode.StartInfo = evaluateCodeInfo;
    88       evaluateCode.Start();
    89       evaluateCode.WaitForExit();
     50      Interpreter.EvaluateTankProgram(Content.Tree, Content.Path, "BestSolution", true);
    9051    }
    9152  }
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode.Views/3.3/SolutionProgramView.Designer.cs

    r9790 r9889  
    2020#endregion
    2121
    22 using System.Windows.Forms;
    2322using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views;
    2423
    2524namespace HeuristicLab.Problems.Robocode {
    2625  partial class SolutionProgramView {
    27     private Panel panel;
    28     private GraphicalSymbolicExpressionTreeView graphTreeView;
    29 
    3026    private void InitializeComponent() {
    31       this.panel = new System.Windows.Forms.Panel();
     27      this.graphTreeView = new HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views.GraphicalSymbolicExpressionTreeView();
    3228      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    3329      this.SuspendLayout();
     
    3834      this.errorProvider.SetIconPadding(this.nameTextBox, 2);
    3935      //
    40       // panel
     36      // graphTreeView
    4137      //
    42       this.panel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     38      this.graphTreeView.AllowDrop = true;
     39      this.graphTreeView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    4340            | System.Windows.Forms.AnchorStyles.Left)
    4441            | System.Windows.Forms.AnchorStyles.Right)));
    45       this.panel.Location = new System.Drawing.Point(3, 26);
    46       this.panel.Name = "panel";
    47       this.panel.Size = new System.Drawing.Size(345, 190);
    48       this.panel.TabIndex = 3;
     42      this.graphTreeView.Caption = "Graphical SymbolicExpressionTree View";
     43      this.graphTreeView.Content = null;
     44      this.graphTreeView.Location = new System.Drawing.Point(6, 26);
     45      this.graphTreeView.Name = "graphTreeView";
     46      this.graphTreeView.ReadOnly = false;
     47      this.graphTreeView.Size = new System.Drawing.Size(342, 190);
     48      this.graphTreeView.TabIndex = 0;
    4949      //
    5050      // SolutionProgramView
    5151      //
    52       this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    53       this.Controls.Add(this.panel);
     52      this.Controls.Add(this.graphTreeView);
    5453      this.Name = "SolutionProgramView";
    5554      this.Size = new System.Drawing.Size(351, 219);
    56       this.Controls.SetChildIndex(this.panel, 0);
    5755      this.Controls.SetChildIndex(this.nameLabel, 0);
    5856      this.Controls.SetChildIndex(this.nameTextBox, 0);
    5957      this.Controls.SetChildIndex(this.infoLabel, 0);
     58      this.Controls.SetChildIndex(this.graphTreeView, 0);
    6059      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
    6160      this.ResumeLayout(false);
     
    6362
    6463    }
     64
     65    private GraphicalSymbolicExpressionTreeView graphTreeView;
    6566  }
    6667}
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode.Views/3.3/SolutionProgramView.cs

    r9790 r9889  
    2222using System.Windows.Forms;
    2323using HeuristicLab.Core.Views;
    24 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views;
    2524using HeuristicLab.MainForm;
    2625
     
    3635    public SolutionProgramView() {
    3736      InitializeComponent();
    38       this.graphTreeView = new GraphicalSymbolicExpressionTreeView();
    39       graphTreeView.Dock = DockStyle.Fill;
    40       panel.Controls.Add(graphTreeView);
    4137    }
    4238
     
    4945      }
    5046    }
    51 
    5247  }
    5348}
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Interpreter.cs

    r9888 r9889  
    2929namespace HeuristicLab.Problems.Robocode {
    3030  public class Interpreter {
    31     public static double EvaluateTankProgram(ISymbolicExpressionTree tree, string path) {
    32       string interpretedProgram = InterpretProgramTree(tree.Root);
     31    public static double EvaluateTankProgram(ISymbolicExpressionTree tree, string path, string robotName = null, bool showUI = false) {
     32      if (robotName == null)
     33        robotName = GenerateRobotName();
     34
     35      string interpretedProgram = InterpretProgramTree(tree.Root, robotName);
    3336      string formattedPath = path.Replace("/", "\\");
    34       string outputname = "";
    3537
    3638      try {
    37         outputname = Guid.NewGuid().ToString();
    38         outputname = outputname.Remove(8, 1);
    39         outputname = outputname.Remove(12, 1);
    40         outputname = outputname.Remove(16, 1);
    41         outputname = outputname.Remove(20, 1);
    42         outputname = outputname.Remove(0, 1);
    43         outputname = outputname.Insert(0, "R");
    44 
    45         string output = interpretedProgram.Replace("class output", "class " + outputname);
    46         File.WriteAllText(path + "/robots/Evaluation/" + outputname + ".java", output, System.Text.Encoding.Default);
     39        File.WriteAllText(path + "/robots/Evaluation/" + robotName + ".java", interpretedProgram, System.Text.Encoding.Default);
    4740      }
    4841      catch (Exception ex) {
     
    5245      ProcessStartInfo javaCompileInfo = new ProcessStartInfo();
    5346      javaCompileInfo.FileName = "cmd.exe";
    54       javaCompileInfo.Arguments = "/C javac -cp " + formattedPath + "\\libs\\robocode.jar " + formattedPath + "\\robots\\Evaluation\\" + outputname + ".java";
     47      javaCompileInfo.Arguments = "/C javac -cp " + formattedPath + "\\libs\\robocode.jar " +
     48                                  formattedPath + "\\robots\\Evaluation\\" + robotName + ".java";
    5549      javaCompileInfo.RedirectStandardOutput = true;
    5650      javaCompileInfo.RedirectStandardError = true;
     
    6761      javaCompile.WaitForExit();
    6862      if (javaCompile.ExitCode != 0) {
    69         DeleteRobotFiles(path, outputname);
     63        DeleteRobotFiles(path, robotName);
    7064        throw new Exception("Compile Error: " + cmdOutput);
    7165      }
     
    7771      ProcessStartInfo evaluateCodeInfo = new ProcessStartInfo();
    7872      evaluateCodeInfo.FileName = "cmd.exe";
    79       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 + "* " + formattedPath + " false";
     73      evaluateCodeInfo.Arguments = "/C java -classpath " + formattedPath + "\\libs;" + formattedPath +
     74                                   "\\libs\\robocode.core-1.8.1.0.jar;" + formattedPath + "\\libs\\robocode.jar;" +
     75                                   formattedPath + "\\libs\\picocontainer-2.14.2.jar BattleRunner Evaluation." +
     76                                   robotName + "* " + formattedPath;
     77      if (showUI)
     78        evaluateCodeInfo.Arguments += " true";
     79
    8080      evaluateCodeInfo.RedirectStandardOutput = true;
    8181      evaluateCodeInfo.RedirectStandardError = true;
     
    8787      evaluateCode.Start();
    8888      evaluateCode.WaitForExit();
     89
    8990      if (evaluateCode.ExitCode != 0) {
    90         DeleteRobotFiles(path, outputname);
     91        DeleteRobotFiles(path, robotName);
    9192        throw new Exception("Error running Robocode: " + evaluateCode.StandardError.ReadToEnd());
    9293      }
     
    102103      }
    103104      finally {
    104         DeleteRobotFiles(path, outputname);
     105        DeleteRobotFiles(path, robotName);
    105106      }
    106107
     
    116117    }
    117118
    118     public static string InterpretProgramTree(ISymbolicExpressionTreeNode node) {
     119    private static string GenerateRobotName() {
     120      // Robocode class names are 32 char max and
     121      // Java class names have to start with a letter
     122      string outputname = Guid.NewGuid().ToString();
     123      outputname = outputname.Remove(8, 1);
     124      outputname = outputname.Remove(12, 1);
     125      outputname = outputname.Remove(16, 1);
     126      outputname = outputname.Remove(20, 1);
     127      outputname = outputname.Remove(0, 1);
     128      outputname = outputname.Insert(0, "R");
     129      return outputname;
     130    }
     131
     132    public static string InterpretProgramTree(ISymbolicExpressionTreeNode node, string robotName) {
    119133      var tankNode = node;
    120134      while (!(tankNode.Symbol is Tank))
    121135        tankNode = tankNode.GetSubtree(0);
    122       return ((CodeNode)tankNode.Symbol).Interpret(tankNode, tankNode.Subtrees);
     136
     137      string result = ((CodeNode)tankNode.Symbol).Interpret(tankNode, tankNode.Subtrees);
     138      result = result.Replace("class output", "class " + robotName);
     139      return result;
    123140    }
    124141  }
Note: See TracChangeset for help on using the changeset viewer.