Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/26/13 15:13:05 (11 years ago)
Author:
ascheibe
Message:

#2069

  • added license headers
  • corrected version information
  • fixed formatting
File:
1 edited

Legend:

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

    r9781 r9790  
    1 using System;
    2 using System.Collections.Generic;
    3 using System.ComponentModel;
    4 using System.Drawing;
    5 using System.Data;
    6 using System.Linq;
    7 using System.Text;
    8 using System.Threading.Tasks;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22using System;
     23using System.Diagnostics;
     24using System.IO;
    925using System.Windows.Forms;
    1026using HeuristicLab.Core.Views;
    11 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views;
    1227using HeuristicLab.MainForm;
    13 using System.Diagnostics;
    14 using System.IO;
    1528
    1629
    17 namespace HeuristicLab.Problems.Robocode
    18 {
    19     [View("Robocode Tank Code View")]
    20     [Content(typeof(Solution), IsDefaultView = true)]
    21     public partial class SolutionCodeView : NamedItemView
    22     {
    23         private string Path { get; set; }
     30namespace HeuristicLab.Problems.Robocode {
     31  [View("Robocode Tank Code View")]
     32  [Content(typeof(Solution), IsDefaultView = true)]
     33  public partial class SolutionCodeView : NamedItemView {
     34    private string Path { get; set; }
    2435
    25         public new Solution Content
    26         {
    27             get { return (Solution)base.Content; }
    28             set { base.Content = value; }
    29         }
     36    public new Solution Content {
     37      get { return (Solution)base.Content; }
     38      set { base.Content = value; }
     39    }
    3040
    31         public SolutionCodeView() : base()
    32         {
    33             InitializeComponent();
    34             this.Path = "F:/robocode/";
    35             this.programCode.Text = "";
    36         }
     41    public SolutionCodeView()
     42      : base() {
     43      InitializeComponent();
     44      this.Path = "F:/robocode/";
     45      this.programCode.Text = "";
     46    }
    3747
    38         protected override void OnContentChanged()
    39         {
    40             base.OnContentChanged();
    41             if (Content == null)
    42             {
    43                 this.programCode.Text = "";
    44             }
    45             else
    46             {
    47                 this.Path = Content.Path;
    48                 string code = Interpreter.InterpretProgramTree(Content.Tree.Root);
    49                 code = code.Replace("class output extends", "class BestSolution extends");
    50                 this.programCode.Text = code;
    51                 File.AppendAllText(Path + "/robots/Evaluation/PreviousBestSolution.java", "\r\n/**********************************************/\r\n" + code);
    52                 File.WriteAllText(Path + "/robots/Evaluation/BestSolution.java", code, System.Text.Encoding.Default);
    53             }
    54         }
     48    protected override void OnContentChanged() {
     49      base.OnContentChanged();
     50      if (Content == null) {
     51        this.programCode.Text = "";
     52      } 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);
     59      }
     60    }
    5561
    56         private void btnRunInRobocode_Click(object sender, EventArgs e)
    57         {
    58             string formattedPath = Path.Replace("/", "\\");
    59             ProcessStartInfo javaCompileInfo = new ProcessStartInfo();
    60             javaCompileInfo.FileName = "cmd.exe";
    61             javaCompileInfo.Arguments = "/C javac -cp " + formattedPath + "\\libs\\robocode.jar " + formattedPath + "\\robots\\Evaluation\\BestSolution.java";
    62             javaCompileInfo.RedirectStandardOutput = true;
    63             javaCompileInfo.RedirectStandardError = true;
    64             javaCompileInfo.UseShellExecute = false;
    65             javaCompileInfo.CreateNoWindow = true;
     62    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;
    6671
    67             Process javaCompile = new Process();
    68             javaCompile.StartInfo = javaCompileInfo;
    69             javaCompile.Start();
    70             javaCompile.WaitForExit();
     72      Process javaCompile = new Process();
     73      javaCompile.StartInfo = javaCompileInfo;
     74      javaCompile.Start();
     75      javaCompile.WaitForExit();
    7176
    72             ProcessStartInfo evaluateCodeInfo = new ProcessStartInfo();
    73             evaluateCodeInfo.FileName = "cmd.exe";
    74             //javaCompileInfo.Arguments = "/C javac -cp C:\\robocode\\libs\\robocode.jar \"" + path + "\\Spaced Up\\output.java\"";
    75             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*";
    76             //Console.WriteLine(javaCompileInfo.Arguments);
    77             evaluateCodeInfo.RedirectStandardOutput = true;
    78             evaluateCodeInfo.RedirectStandardError = true;
    79             evaluateCodeInfo.UseShellExecute = false;
     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;
    8085
    81             Process evaluateCode = new Process();
    82             evaluateCode.StartInfo = evaluateCodeInfo;
    83             evaluateCode.Start();
    84             evaluateCode.WaitForExit();
    85         }
     86      Process evaluateCode = new Process();
     87      evaluateCode.StartInfo = evaluateCodeInfo;
     88      evaluateCode.Start();
     89      evaluateCode.WaitForExit();
    8690    }
     91  }
    8792}
Note: See TracChangeset for help on using the changeset viewer.