Changeset 9971 for branches/Robocode.TrunkInt
- Timestamp:
- 09/16/13 16:01:05 (11 years ago)
- 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 46 46 <Reference Include="HeuristicLab.Common-3.3"> 47 47 <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> 48 53 <Private>False</Private> 49 54 </Reference> … … 103 108 <None Include="Plugin.cs.frame" /> 104 109 <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> 105 116 <Compile Include="SolutionCodeView.cs"> 106 117 <SubType>UserControl</SubType> -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode.Views/3.3/Plugin.cs.frame
r9790 r9971 37 37 [PluginDependency("HeuristicLab.Operators", "3.3")] 38 38 [PluginDependency("HeuristicLab.Common", "3.3")] 39 [PluginDependency("HeuristicLab.Common.Resources", "3.3")] 39 40 [PluginDependency("HeuristicLab.Collections", "3.3")] 40 41 [PluginDependency("HeuristicLab.Encodings.SymbolicExpressionTreeEncoding", "3.4")] -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/BestSolutionAnalyzer.cs
r9947 r9971 65 65 get { return (ILookupParameter<IntValue>)Parameters[NrOfRoundsParameterName]; } 66 66 } 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]; } 69 69 } 70 70 #endregion … … 82 82 Parameters.Add(new LookupParameter<DirectoryValue>(RobocodePathParamaterName, "Path of the Robocode installation.")); 83 83 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.")); 85 85 } 86 86 -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/HeuristicLab.Problems.Robocode-3.3.csproj
r9891 r9971 101 101 <None Include="HeuristicLab.snk" /> 102 102 <None Include="Plugin.cs.frame" /> 103 <Compile Include="EnemyCollection.cs" /> 103 104 <Compile Include="RobocodeEvaluator.cs" /> 104 105 <Compile Include="Grammar.cs" /> -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Interpreter.cs
r9966 r9971 32 32 namespace HeuristicLab.Problems.Robocode { 33 33 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) { 35 35 if (robotName == null) 36 36 robotName = GenerateRobotName(); -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/RobocodeEvaluator.cs
r9947 r9971 52 52 get { return (ILookupParameter<IntValue>)Parameters[NrOfRoundsParameterName]; } 53 53 } 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]; } 56 56 } 57 57 #endregion … … 67 67 Parameters.Add(new LookupParameter<DirectoryValue>(RobocodePathParamaterName, "Path of the Robocode installation.")); 68 68 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.")); 70 70 } 71 71 -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/RobocodeProblem.cs
r9962 r9971 20 20 #endregion 21 21 22 using System;23 using System.Collections.Generic;24 using System.IO;25 22 using System.Linq; 26 23 using HeuristicLab.Common; … … 66 63 get { return (IFixedValueParameter<IntValue>)Parameters[NrOfRoundsParameterName]; } 67 64 } 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]; } 70 67 } 71 68 #endregion … … 74 71 protected RobocodeProblem(bool deserializing) 75 72 : base(deserializing) { 73 if (deserializing) { 74 RegisterRobocodePathEvent(); 75 } 76 76 } 77 77 protected RobocodeProblem(RobocodeProblem original, Cloner cloner) 78 78 : base(original, cloner) { 79 RegisterRobocodePathEvent(); 79 80 } 80 81 … … 84 85 robocodeDir.Value = @"C:\robocode"; 85 86 86 var robotList = ReloadEnemies(robocodeDir.Value); 87 var robotList = EnemyCollection.ReloadEnemies(robocodeDir.Value); 88 robotList.RobocodePath = robocodeDir.Value; 87 89 88 90 Parameters.Add(new FixedValueParameter<IntValue>(MaxTankProgramDepthParameterName, "Maximal depth of the Robocode tank program.", new IntValue(6))); … … 91 93 Parameters.Add(new FixedValueParameter<DirectoryValue>(RobocodePathParamaterName, "Path of the Robocode installation.", robocodeDir)); 92 94 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)); 94 96 95 97 Maximization.Value = true; … … 99 101 public override IDeepCloneable Clone(Cloner cloner) { 100 102 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;121 103 } 122 104 … … 129 111 ParameterizeOperators(); 130 112 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; 131 122 } 132 123 -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Solution.cs
r9947 r9971 22 22 using HeuristicLab.Common; 23 23 using HeuristicLab.Core; 24 using HeuristicLab.Data;25 24 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 26 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 40 39 41 40 [Storable] 42 public ICheckedItemList<StringValue>Enemies { get; set; }41 public EnemyCollection Enemies { get; set; } 43 42 44 43 [StorableConstructor] … … 52 51 } 53 52 54 public Solution(ISymbolicExpressionTree tree, string path, int nrOfRounds, ICheckedItemList<StringValue>enemies)53 public Solution(ISymbolicExpressionTree tree, string path, int nrOfRounds, EnemyCollection enemies) 55 54 : base() { 56 55 this.Tree = tree;
Note: See TracChangeset
for help on using the changeset viewer.