- Timestamp:
- 09/13/13 14:05:13 (11 years ago)
- Location:
- branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Interpreter.cs
r9947 r9962 79 79 80 80 if (showUI) { 81 evaluateCodeInfo.Arguments += " true " + nrOfRounds ;81 evaluateCodeInfo.Arguments += " true " + nrOfRounds + " "; 82 82 } else { 83 evaluateCodeInfo.Arguments += " false " + nrOfRounds ;83 evaluateCodeInfo.Arguments += " false " + nrOfRounds + " "; 84 84 } 85 85 86 foreach (var enemy in enemies )86 foreach (var enemy in enemies.CheckedItems) 87 87 evaluateCodeInfo.Arguments += enemy.Value + "* "; 88 88 -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/RobocodeProblem.cs
r9947 r9962 40 40 public class RobocodeProblem : SingleObjectiveHeuristicOptimizationProblem<RobocodeEvaluator, 41 41 ISymbolicExpressionTreeCreator> { 42 #region parameter names42 #region Parameter Names 43 43 private const string TankProgramParameterName = "TankProgram"; 44 44 private const string MaxTankProgramLengthParameterName = "MaxProgramLength"; … … 84 84 robocodeDir.Value = @"C:\robocode"; 85 85 86 var robotsDir = new DirectoryInfo(Path.Combine(robocodeDir.Value, "robots")); 87 var robotFiles = robotsDir.GetFiles("*", SearchOption.AllDirectories) 88 .Where(x => x.Extension == ".class" || x.Extension == ".jar"); 89 var robotSet = new Dictionary<string, StringValue>(); 90 foreach (var robot in robotFiles) { 91 string robotName = Path.Combine(robot.DirectoryName, Path.GetFileNameWithoutExtension(robot.FullName)); 92 robotName = robotName.Remove(0, robotsDir.FullName.Length); 93 string[] nameParts = robotName.Split(new[] { Path.DirectorySeparatorChar }, StringSplitOptions.RemoveEmptyEntries); 94 robotName = string.Join(".", nameParts); 95 robotSet[robot.FullName] = new StringValue(robotName); 96 } 97 var robotList = new CheckedItemList<StringValue>(robotSet.Values); 86 var robotList = ReloadEnemies(robocodeDir.Value); 98 87 99 88 Parameters.Add(new FixedValueParameter<IntValue>(MaxTankProgramDepthParameterName, "Maximal depth of the Robocode tank program.", new IntValue(6))); … … 110 99 public override IDeepCloneable Clone(Cloner cloner) { 111 100 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; 112 121 } 113 122
Note: See TracChangeset
for help on using the changeset viewer.