Free cookie consent management tool by TermsFeed Policy Generator

Changeset 9985


Ignore:
Timestamp:
09/18/13 10:24:33 (9 years ago)
Author:
jkarder
Message:

#2069:

  • fixed deserialization of the RobocodeProblem
  • added a BattleRunnerDialog that allows to configure some arguments of the battle runner
  • added functionality to save a Solution in a java file
Location:
branches/Robocode.TrunkInt
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode.Views/3.3/HeuristicLab.Problems.Robocode.Views-3.3.csproj

    r9971 r9985  
    108108    <None Include="Plugin.cs.frame" />
    109109    <None Include="Properties\AssemblyInfo.cs.frame" />
     110    <Compile Include="BattleRunnerDialog.cs">
     111      <SubType>Form</SubType>
     112    </Compile>
     113    <Compile Include="BattleRunnerDialog.Designer.cs">
     114      <DependentUpon>BattleRunnerDialog.cs</DependentUpon>
     115    </Compile>
    110116    <Compile Include="EnemyCollectionView.cs">
    111117      <SubType>UserControl</SubType>
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode.Views/3.3/SolutionCodeView.Designer.cs

    r9890 r9985  
    2626      this.programCode = new System.Windows.Forms.TextBox();
    2727      this.btnRunInRobocode = new System.Windows.Forms.Button();
     28      this.btnSave = new System.Windows.Forms.Button();
     29      this.saveFileDialog = new System.Windows.Forms.SaveFileDialog();
    2830      this.SuspendLayout();
    2931      //
     
    3941      this.programCode.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
    4042      this.programCode.Size = new System.Drawing.Size(345, 203);
    41       this.programCode.TabIndex = 3;
     43      this.programCode.TabIndex = 0;
    4244      //
    4345      // btnRunInRobocode
     
    4850      this.btnRunInRobocode.Name = "btnRunInRobocode";
    4951      this.btnRunInRobocode.Size = new System.Drawing.Size(101, 23);
    50       this.btnRunInRobocode.TabIndex = 4;
     52      this.btnRunInRobocode.TabIndex = 2;
    5153      this.btnRunInRobocode.Text = "Run in Robocode";
    5254      this.btnRunInRobocode.UseVisualStyleBackColor = true;
    5355      this.btnRunInRobocode.Click += new System.EventHandler(this.btnRunInRobocode_Click);
     56      //
     57      // btnSave
     58      //
     59      this.btnSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
     60      this.btnSave.AutoSize = true;
     61      this.btnSave.Location = new System.Drawing.Point(166, 212);
     62      this.btnSave.Name = "btnSave";
     63      this.btnSave.Size = new System.Drawing.Size(75, 23);
     64      this.btnSave.TabIndex = 1;
     65      this.btnSave.Text = "Save...";
     66      this.btnSave.UseVisualStyleBackColor = true;
     67      this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
     68      //
     69      // saveFileDialog
     70      //
     71      this.saveFileDialog.DefaultExt = "java";
     72      this.saveFileDialog.Filter = "Java |*java";
    5473      //
    5574      // SolutionCodeView
     
    5776      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    5877      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
     78      this.Controls.Add(this.btnSave);
    5979      this.Controls.Add(this.btnRunInRobocode);
    6080      this.Controls.Add(this.programCode);
     
    7090    private System.Windows.Forms.TextBox programCode;
    7191    private System.Windows.Forms.Button btnRunInRobocode;
     92    private System.Windows.Forms.Button btnSave;
     93    private System.Windows.Forms.SaveFileDialog saveFileDialog;
    7294  }
    7395}
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode.Views/3.3/SolutionCodeView.cs

    r9947 r9985  
    2121
    2222using System;
     23using System.IO;
     24using System.Windows.Forms;
    2325using HeuristicLab.Core.Views;
    2426using HeuristicLab.MainForm;
     27using HeuristicLab.Problems.Robocode.Views;
    2528
    2629namespace HeuristicLab.Problems.Robocode {
     
    4952    }
    5053
     54    private void btnSave_Click(object sender, EventArgs e) {
     55      saveFileDialog.FileName = programName;
     56      var result = saveFileDialog.ShowDialog(this);
     57      if (result == DialogResult.OK)
     58        File.WriteAllText(saveFileDialog.FileName, programCode.Text);
     59    }
     60
    5161    private void btnRunInRobocode_Click(object sender, EventArgs e) {
    52       Interpreter.EvaluateTankProgram(Content.Tree, Content.Path, Content.Enemies, programName, true, Content.NrOfRounds);
     62      using (var battleRunnerDlg = new BattleRunnerDialog(Content)) {
     63        var result = battleRunnerDlg.ShowDialog(this);
     64        if (result == DialogResult.OK) {
     65          var enemies = battleRunnerDlg.Enemies;
     66          string path = enemies.RobocodePath;
     67          int nrOfRounds = battleRunnerDlg.NrOfRounds;
     68          Interpreter.EvaluateTankProgram(Content.Tree, path, enemies, programName, true, nrOfRounds);
     69        }
     70      }
    5371    }
    5472  }
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/RobocodeProblem.cs

    r9971 r9985  
    6969
    7070    [StorableConstructor]
    71     protected RobocodeProblem(bool deserializing)
    72       : base(deserializing) {
    73       if (deserializing) {
    74         RegisterRobocodePathEvent();
    75       }
    76     }
     71    protected RobocodeProblem(bool deserializing) : base(deserializing) { }
    7772    protected RobocodeProblem(RobocodeProblem original, Cloner cloner)
    7873      : base(original, cloner) {
    79       RegisterRobocodePathEvent();
     74      RegisterEventHandlers();
    8075    }
    8176
     
    9792      Maximization.Value = true;
    9893      InitializeOperators();
     94      RegisterEventHandlers();
    9995    }
    10096
     
    10399    }
    104100
     101    [StorableHook(HookType.AfterDeserialization)]
     102    private void AfterDeserialization() {
     103      RegisterEventHandlers();
     104    }
     105
    105106    private void InitializeOperators() {
    106       Operators.AddRange(
    107         ApplicationManager.Manager.GetInstances<ISymbolicExpressionTreeOperator>());
     107      Operators.AddRange(ApplicationManager.Manager.GetInstances<ISymbolicExpressionTreeOperator>());
    108108      Operators.Add(new MinAverageMaxSymbolicExpressionTreeLengthAnalyzer());
    109109      Operators.Add(new SymbolicExpressionSymbolFrequencyAnalyzer());
     
    111111      ParameterizeOperators();
    112112      ParameterizeAnalyzers();
    113       RegisterRobocodePathEvent();
    114113    }
    115114
    116     private void RegisterRobocodePathEvent() {
     115    private void RegisterEventHandlers() {
    117116      RobocodePathParameter.Value.StringValue.ValueChanged += RobocodePathParameter_ValueChanged;
    118117    }
Note: See TracChangeset for help on using the changeset viewer.