Changeset 9926
- Timestamp:
- 09/02/13 15:11:53 (11 years ago)
- Location:
- branches/Robocode.TrunkInt
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode.Views/3.3/SolutionCodeView.cs
r9890 r9926 50 50 51 51 private void btnRunInRobocode_Click(object sender, EventArgs e) { 52 Interpreter.EvaluateTankProgram(Content.Tree, Content.Path, programName, true );52 Interpreter.EvaluateTankProgram(Content.Tree, Content.Path, programName, true, Content.NrOfRounds); 53 53 } 54 54 } -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/BestSolutionAnalyzer.cs
r9892 r9926 38 38 private const string BestSolutionParameterName = "Best solution"; 39 39 private const string ResultsParameterName = "Results"; 40 private const string RobocodePathParamaterName = "Path"; 40 private const string RobocodePathParamaterName = "RobocodePath"; 41 private const string NrOfRoundsParameterName = "NrOfRounds"; 41 42 42 43 public bool EnabledByDefault { … … 60 61 get { return (ILookupParameter<DirectoryValue>)Parameters[RobocodePathParamaterName]; } 61 62 } 63 public ILookupParameter<IntValue> NrOfRoundsParameter { 64 get { return (ILookupParameter<IntValue>)Parameters[NrOfRoundsParameterName]; } 65 } 62 66 #endregion 63 67 … … 73 77 Parameters.Add(new LookupParameter<ResultCollection>(ResultsParameterName, "The result collection of the algorithm.")); 74 78 Parameters.Add(new LookupParameter<DirectoryValue>(RobocodePathParamaterName, "Path of the Robocode installation.")); 79 Parameters.Add(new LookupParameter<IntValue>(NrOfRoundsParameterName, "Nr. of Rounds a Robot has to fight against each opponent.")); 75 80 } 76 81 … … 92 97 93 98 // create a solution instance 94 var bestSolution = new Solution(bestTree, RobocodePathParameter.ActualValue.Value );99 var bestSolution = new Solution(bestTree, RobocodePathParameter.ActualValue.Value, NrOfRoundsParameter.ActualValue.Value); 95 100 // store the new solution in the best solution parameter 96 101 BestSolutionParameter.ActualValue = bestSolution; -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/External Evaluator/BattleRunner.java
r9899 r9926 40 40 public static List<Double> score = new ArrayList<Double>(); 41 41 42 //43 42 // This program requires at least 1 argument: the name of the robot. 44 43 // The second argument is the path to the robocode installation. If not give, c:\robocode is assumed. 45 44 // The third argument is optional. If it is true, robocode is shown, otherwise it is hidden. 46 // 47 45 // The fourth argument is the number of rounds. 46 public static void main(String[] args) { 48 47 String roboCodePath = "C:\\robocode"; 49 48 Boolean visible = false; … … 70 69 roboCodePath = args[1]; 71 70 visible = Boolean.valueOf(args[2]); 71 } 72 else if (args.length == 4) 73 { 74 robots[0] = args[0]; 75 player = args[0]; 76 roboCodePath = args[1]; 77 visible = Boolean.valueOf(args[2]); 78 numberOfRounds = Integer.valueOf(args[3]); 72 79 } 73 80 else -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Interpreter.cs
r9898 r9926 29 29 30 30 namespace HeuristicLab.Problems.Robocode { 31 public class Interpreter {32 public static double EvaluateTankProgram(ISymbolicExpressionTree tree, string path, string robotName = null, bool showUI = false ) {31 public static class Interpreter { 32 public static double EvaluateTankProgram(ISymbolicExpressionTree tree, string path, string robotName = null, bool showUI = false, int nrOfRounds = 3) { 33 33 if (robotName == null) 34 34 robotName = GenerateRobotName(); … … 43 43 string srcRobotPath = Path.Combine(robotsPath, robotName + ".java"); 44 44 45 try { 46 File.WriteAllText(srcRobotPath, interpretedProgram, System.Text.Encoding.Default); 47 } 48 catch (Exception ex) { 49 throw; 50 } 45 File.WriteAllText(srcRobotPath, interpretedProgram, System.Text.Encoding.Default); 51 46 52 47 ProcessStartInfo javaCompileInfo = new ProcessStartInfo(); … … 81 76 ";" + picocontainerJar + ";" + " BattleRunner Evaluation." + robotName + "* " + path; 82 77 83 if (showUI) 84 evaluateCodeInfo.Arguments += " true"; 78 if (showUI) { 79 evaluateCodeInfo.Arguments += " true " + nrOfRounds; 80 } else { 81 evaluateCodeInfo.Arguments += " false " + nrOfRounds; 82 } 85 83 86 84 evaluateCodeInfo.RedirectStandardOutput = true; -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/RobocodeEvaluator.cs
r9892 r9926 35 35 private const string QualityParameterName = "Quality"; 36 36 private const string TankProgramParameterName = "TankProgram"; 37 private const string RobocodePathParamaterName = "Path"; 37 private const string RobocodePathParamaterName = "RobocodePath"; 38 private const string NrOfRoundsParameterName = "NrOfRounds"; 38 39 39 40 #region Parameters … … 46 47 public ILookupParameter<DirectoryValue> RobocodePathParameter { 47 48 get { return (ILookupParameter<DirectoryValue>)Parameters[RobocodePathParamaterName]; } 49 } 50 public ILookupParameter<IntValue> NrOfRoundsParameter { 51 get { return (ILookupParameter<IntValue>)Parameters[NrOfRoundsParameterName]; } 48 52 } 49 53 #endregion … … 58 62 Parameters.Add(new LookupParameter<ISymbolicExpressionTree>(TankProgramParameterName, "The Robocode tank program to evaluate represented as a symbolic expression tree.")); 59 63 Parameters.Add(new LookupParameter<DirectoryValue>(RobocodePathParamaterName, "Path of the Robocode installation.")); 64 Parameters.Add(new LookupParameter<IntValue>(NrOfRoundsParameterName, "Nr. of Rounds a Robot has to fight against each opponent.")); 60 65 } 61 66 … … 63 68 ISymbolicExpressionTree tree = TankProgramParameter.ActualValue; 64 69 string path = RobocodePathParameter.ActualValue.Value; 65 QualityParameter.ActualValue = new DoubleValue(Interpreter.EvaluateTankProgram(tree, path ));70 QualityParameter.ActualValue = new DoubleValue(Interpreter.EvaluateTankProgram(tree, path, null, false, NrOfRoundsParameter.ActualValue.Value)); 66 71 67 72 return base.Apply(); -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/RobocodeProblem.cs
r9892 r9926 42 42 private const string MaxTankProgramDepthParameterName = "MaxProgramDepth"; 43 43 private const string TankGrammarParameterName = "Grammar"; 44 private const string RobocodePathParamaterName = "Path"; 44 private const string RobocodePathParamaterName = "RobocodePath"; 45 private const string NrOfRoundsParameterName = "NrOfRounds"; 45 46 #endregion 46 47 … … 57 58 public IFixedValueParameter<DirectoryValue> RobocodePathParameter { 58 59 get { return (IFixedValueParameter<DirectoryValue>)Parameters[RobocodePathParamaterName]; } 60 } 61 public IFixedValueParameter<IntValue> NrOfRoundsParameter { 62 get { return (IFixedValueParameter<IntValue>)Parameters[NrOfRoundsParameterName]; } 59 63 } 60 64 #endregion … … 77 81 Parameters.Add(new ValueParameter<Grammar>(TankGrammarParameterName, "Grammar for the tank program.", new Grammar())); 78 82 Parameters.Add(new FixedValueParameter<DirectoryValue>(RobocodePathParamaterName, "Path of the Robocode installation.", robocodeDir)); 83 Parameters.Add(new FixedValueParameter<IntValue>(NrOfRoundsParameterName, "Nr. of Rounds a Robot has to fight against each opponent.", new IntValue(3))); 79 84 80 85 Maximization.Value = true; -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Solution.cs
r9890 r9926 35 35 public string Path { get; set; } 36 36 37 [Storable] 38 public int NrOfRounds { get; set; } 39 37 40 [StorableConstructor] 38 41 private Solution(bool deserializing) : base(deserializing) { } … … 41 44 Tree = cloner.Clone(original.Tree); 42 45 Path = (string)original.Path.Clone(); 46 NrOfRounds = original.NrOfRounds; 43 47 } 44 48 45 public Solution(ISymbolicExpressionTree tree, string path )49 public Solution(ISymbolicExpressionTree tree, string path, int nrOfRounds) 46 50 : base() { 47 51 this.Tree = tree; 48 52 this.Path = path; 53 this.NrOfRounds = nrOfRounds; 49 54 } 50 55
Note: See TracChangeset
for help on using the changeset viewer.