Changeset 9971


Ignore:
Timestamp:
09/16/13 16:01:05 (8 years ago)
Author:
ascheibe
Message:

#2069 added a view for displaying/reloading enemies

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

Legend:

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

    r9890 r9971  
    4646    <Reference Include="HeuristicLab.Common-3.3">
    4747      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Common-3.3.dll</HintPath>
     48      <Private>False</Private>
     49    </Reference>
     50    <Reference Include="HeuristicLab.Common.Resources-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     51      <SpecificVersion>False</SpecificVersion>
     52      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Common.Resources-3.3.dll</HintPath>
    4853      <Private>False</Private>
    4954    </Reference>
     
    103108    <None Include="Plugin.cs.frame" />
    104109    <None Include="Properties\AssemblyInfo.cs.frame" />
     110    <Compile Include="EnemyCollectionView.cs">
     111      <SubType>UserControl</SubType>
     112    </Compile>
     113    <Compile Include="EnemyCollectionView.Designer.cs">
     114      <DependentUpon>EnemyCollectionView.cs</DependentUpon>
     115    </Compile>
    105116    <Compile Include="SolutionCodeView.cs">
    106117      <SubType>UserControl</SubType>
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode.Views/3.3/Plugin.cs.frame

    r9790 r9971  
    3737    [PluginDependency("HeuristicLab.Operators", "3.3")]
    3838    [PluginDependency("HeuristicLab.Common", "3.3")]
     39    [PluginDependency("HeuristicLab.Common.Resources", "3.3")]
    3940    [PluginDependency("HeuristicLab.Collections", "3.3")]
    4041    [PluginDependency("HeuristicLab.Encodings.SymbolicExpressionTreeEncoding", "3.4")]
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/BestSolutionAnalyzer.cs

    r9947 r9971  
    6565      get { return (ILookupParameter<IntValue>)Parameters[NrOfRoundsParameterName]; }
    6666    }
    67     public ILookupParameter<ICheckedItemList<StringValue>> EnemiesParameter {
    68       get { return (ILookupParameter<ICheckedItemList<StringValue>>)Parameters[EnemiesParameterName]; }
     67    public ILookupParameter<EnemyCollection> EnemiesParameter {
     68      get { return (ILookupParameter<EnemyCollection>)Parameters[EnemiesParameterName]; }
    6969    }
    7070    #endregion
     
    8282      Parameters.Add(new LookupParameter<DirectoryValue>(RobocodePathParamaterName, "Path of the Robocode installation."));
    8383      Parameters.Add(new LookupParameter<IntValue>(NrOfRoundsParameterName, "Nr. of Rounds a Robot has to fight against each opponent."));
    84       Parameters.Add(new LookupParameter<ICheckedItemList<StringValue>>(EnemiesParameterName, "The enemies that should be battled."));
     84      Parameters.Add(new LookupParameter<EnemyCollection>(EnemiesParameterName, "The enemies that should be battled."));
    8585    }
    8686
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/HeuristicLab.Problems.Robocode-3.3.csproj

    r9891 r9971  
    101101    <None Include="HeuristicLab.snk" />
    102102    <None Include="Plugin.cs.frame" />
     103    <Compile Include="EnemyCollection.cs" />
    103104    <Compile Include="RobocodeEvaluator.cs" />
    104105    <Compile Include="Grammar.cs" />
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Interpreter.cs

    r9966 r9971  
    3232namespace HeuristicLab.Problems.Robocode {
    3333  public static class Interpreter {
    34     public static double EvaluateTankProgram(ISymbolicExpressionTree tree, string path, ICheckedItemList<StringValue> enemies, string robotName = null, bool showUI = false, int nrOfRounds = 3) {
     34    public static double EvaluateTankProgram(ISymbolicExpressionTree tree, string path, EnemyCollection enemies, string robotName = null, bool showUI = false, int nrOfRounds = 3) {
    3535      if (robotName == null)
    3636        robotName = GenerateRobotName();
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/RobocodeEvaluator.cs

    r9947 r9971  
    5252      get { return (ILookupParameter<IntValue>)Parameters[NrOfRoundsParameterName]; }
    5353    }
    54     public ILookupParameter<ICheckedItemList<StringValue>> EnemiesParameter {
    55       get { return (ILookupParameter<ICheckedItemList<StringValue>>)Parameters[EnemiesParameterName]; }
     54    public ILookupParameter<EnemyCollection> EnemiesParameter {
     55      get { return (ILookupParameter<EnemyCollection>)Parameters[EnemiesParameterName]; }
    5656    }
    5757    #endregion
     
    6767      Parameters.Add(new LookupParameter<DirectoryValue>(RobocodePathParamaterName, "Path of the Robocode installation."));
    6868      Parameters.Add(new LookupParameter<IntValue>(NrOfRoundsParameterName, "Nr. of Rounds a Robot has to fight against each opponent."));
    69       Parameters.Add(new LookupParameter<ICheckedItemList<StringValue>>(EnemiesParameterName, "The enemies that should be battled."));
     69      Parameters.Add(new LookupParameter<EnemyCollection>(EnemiesParameterName, "The enemies that should be battled."));
    7070    }
    7171
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/RobocodeProblem.cs

    r9962 r9971  
    2020#endregion
    2121
    22 using System;
    23 using System.Collections.Generic;
    24 using System.IO;
    2522using System.Linq;
    2623using HeuristicLab.Common;
     
    6663      get { return (IFixedValueParameter<IntValue>)Parameters[NrOfRoundsParameterName]; }
    6764    }
    68     public IValueParameter<ICheckedItemList<StringValue>> EnemiesParameter {
    69       get { return (IValueParameter<ICheckedItemList<StringValue>>)Parameters[EnemiesParameterName]; }
     65    public IValueParameter<EnemyCollection> EnemiesParameter {
     66      get { return (IValueParameter<EnemyCollection>)Parameters[EnemiesParameterName]; }
    7067    }
    7168    #endregion
     
    7471    protected RobocodeProblem(bool deserializing)
    7572      : base(deserializing) {
     73      if (deserializing) {
     74        RegisterRobocodePathEvent();
     75      }
    7676    }
    7777    protected RobocodeProblem(RobocodeProblem original, Cloner cloner)
    7878      : base(original, cloner) {
     79      RegisterRobocodePathEvent();
    7980    }
    8081
     
    8485      robocodeDir.Value = @"C:\robocode";
    8586
    86       var robotList = ReloadEnemies(robocodeDir.Value);
     87      var robotList = EnemyCollection.ReloadEnemies(robocodeDir.Value);
     88      robotList.RobocodePath = robocodeDir.Value;
    8789
    8890      Parameters.Add(new FixedValueParameter<IntValue>(MaxTankProgramDepthParameterName, "Maximal depth of the Robocode tank program.", new IntValue(6)));
     
    9193      Parameters.Add(new FixedValueParameter<DirectoryValue>(RobocodePathParamaterName, "Path of the Robocode installation.", robocodeDir));
    9294      Parameters.Add(new FixedValueParameter<IntValue>(NrOfRoundsParameterName, "Nr. of Rounds a Robot has to fight against each opponent.", new IntValue(3)));
    93       Parameters.Add(new ValueParameter<ICheckedItemList<StringValue>>(EnemiesParameterName, "The enemies that should be battled.", robotList));
     95      Parameters.Add(new ValueParameter<EnemyCollection>(EnemiesParameterName, "The enemies that should be battled.", robotList));
    9496
    9597      Maximization.Value = true;
     
    99101    public override IDeepCloneable Clone(Cloner cloner) {
    100102      return new RobocodeProblem(this, cloner);
    101     }
    102 
    103     private ICheckedItemList<StringValue> ReloadEnemies(string robocodeDir) {
    104       var robotsDir = new DirectoryInfo(Path.Combine(robocodeDir, "robots"));
    105       var robotFiles = robotsDir.GetFiles("*", SearchOption.AllDirectories)
    106                                 .Where(x => x.Extension == ".class" || x.Extension == ".jar");
    107       var robotSet = new Dictionary<string, StringValue>();
    108       foreach (var robot in robotFiles) {
    109         string robotName = Path.Combine(robot.DirectoryName, Path.GetFileNameWithoutExtension(robot.FullName));
    110         robotName = robotName.Remove(0, robotsDir.FullName.Length);
    111         string[] nameParts = robotName.Split(new[] { Path.DirectorySeparatorChar }, StringSplitOptions.RemoveEmptyEntries);
    112         robotName = string.Join(".", nameParts);
    113         robotSet[robot.FullName] = new StringValue(robotName);
    114       }
    115       var robotList = new CheckedItemList<StringValue>(robotSet.Values);
    116       foreach (var robot in robotList) {
    117         robotList.SetItemCheckedState(robot, false);
    118       }
    119 
    120       return robotList;
    121103    }
    122104
     
    129111      ParameterizeOperators();
    130112      ParameterizeAnalyzers();
     113      RegisterRobocodePathEvent();
     114    }
     115
     116    private void RegisterRobocodePathEvent() {
     117      RobocodePathParameter.Value.StringValue.ValueChanged += RobocodePathParameter_ValueChanged;
     118    }
     119
     120    void RobocodePathParameter_ValueChanged(object sender, System.EventArgs e) {
     121      EnemiesParameter.Value.RobocodePath = RobocodePathParameter.Value.Value;
    131122    }
    132123
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Solution.cs

    r9947 r9971  
    2222using HeuristicLab.Common;
    2323using HeuristicLab.Core;
    24 using HeuristicLab.Data;
    2524using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    2625using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    4039
    4140    [Storable]
    42     public ICheckedItemList<StringValue> Enemies { get; set; }
     41    public EnemyCollection Enemies { get; set; }
    4342
    4443    [StorableConstructor]
     
    5251    }
    5352
    54     public Solution(ISymbolicExpressionTree tree, string path, int nrOfRounds, ICheckedItemList<StringValue> enemies)
     53    public Solution(ISymbolicExpressionTree tree, string path, int nrOfRounds, EnemyCollection enemies)
    5554      : base() {
    5655      this.Tree = tree;
Note: See TracChangeset for help on using the changeset viewer.