Free cookie consent management tool by TermsFeed Policy Generator

Changeset 9926


Ignore:
Timestamp:
09/02/13 15:11:53 (11 years ago)
Author:
ascheibe
Message:

#2069

  • renamed path parameter to robocode path
  • made number of rounds configurable
Location:
branches/Robocode.TrunkInt
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode.Views/3.3/SolutionCodeView.cs

    r9890 r9926  
    5050
    5151    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);
    5353    }
    5454  }
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/BestSolutionAnalyzer.cs

    r9892 r9926  
    3838    private const string BestSolutionParameterName = "Best solution";
    3939    private const string ResultsParameterName = "Results";
    40     private const string RobocodePathParamaterName = "Path";
     40    private const string RobocodePathParamaterName = "RobocodePath";
     41    private const string NrOfRoundsParameterName = "NrOfRounds";
    4142
    4243    public bool EnabledByDefault {
     
    6061      get { return (ILookupParameter<DirectoryValue>)Parameters[RobocodePathParamaterName]; }
    6162    }
     63    public ILookupParameter<IntValue> NrOfRoundsParameter {
     64      get { return (ILookupParameter<IntValue>)Parameters[NrOfRoundsParameterName]; }
     65    }
    6266    #endregion
    6367
     
    7377      Parameters.Add(new LookupParameter<ResultCollection>(ResultsParameterName, "The result collection of the algorithm."));
    7478      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."));
    7580    }
    7681
     
    9297
    9398      // 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);
    95100      // store the new solution in the best solution parameter
    96101      BestSolutionParameter.ActualValue = bestSolution;
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/External Evaluator/BattleRunner.java

    r9899 r9926  
    4040    public static List<Double> score = new ArrayList<Double>();
    4141
    42   //
    4342  // This program requires at least 1 argument: the name of the robot.
    4443  // The second argument is the path to the robocode installation. If not give, c:\robocode is assumed.
    4544  // The third argument is optional. If it is true, robocode is shown, otherwise it is hidden.
    46   //
    47     public static void main(String[] args) {
     45  // The fourth argument is the number of rounds.
     46  public static void main(String[] args) {
    4847    String roboCodePath = "C:\\robocode";
    4948    Boolean visible = false;   
     
    7069      roboCodePath = args[1];
    7170            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]);
    7279        }
    7380        else
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Interpreter.cs

    r9898 r9926  
    2929
    3030namespace 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) {
    3333      if (robotName == null)
    3434        robotName = GenerateRobotName();
     
    4343      string srcRobotPath = Path.Combine(robotsPath, robotName + ".java");
    4444
    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);
    5146
    5247      ProcessStartInfo javaCompileInfo = new ProcessStartInfo();
     
    8176                                  ";" + picocontainerJar + ";" + " BattleRunner Evaluation." + robotName + "* " + path;
    8277
    83       if (showUI)
    84         evaluateCodeInfo.Arguments += " true";
     78      if (showUI) {
     79        evaluateCodeInfo.Arguments += " true " + nrOfRounds;
     80      } else {
     81        evaluateCodeInfo.Arguments += " false " + nrOfRounds;
     82      }
    8583
    8684      evaluateCodeInfo.RedirectStandardOutput = true;
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/RobocodeEvaluator.cs

    r9892 r9926  
    3535    private const string QualityParameterName = "Quality";
    3636    private const string TankProgramParameterName = "TankProgram";
    37     private const string RobocodePathParamaterName = "Path";
     37    private const string RobocodePathParamaterName = "RobocodePath";
     38    private const string NrOfRoundsParameterName = "NrOfRounds";
    3839
    3940    #region Parameters
     
    4647    public ILookupParameter<DirectoryValue> RobocodePathParameter {
    4748      get { return (ILookupParameter<DirectoryValue>)Parameters[RobocodePathParamaterName]; }
     49    }
     50    public ILookupParameter<IntValue> NrOfRoundsParameter {
     51      get { return (ILookupParameter<IntValue>)Parameters[NrOfRoundsParameterName]; }
    4852    }
    4953    #endregion
     
    5862      Parameters.Add(new LookupParameter<ISymbolicExpressionTree>(TankProgramParameterName, "The Robocode tank program to evaluate represented as a symbolic expression tree."));
    5963      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."));
    6065    }
    6166
     
    6368      ISymbolicExpressionTree tree = TankProgramParameter.ActualValue;
    6469      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));
    6671
    6772      return base.Apply();
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/RobocodeProblem.cs

    r9892 r9926  
    4242    private const string MaxTankProgramDepthParameterName = "MaxProgramDepth";
    4343    private const string TankGrammarParameterName = "Grammar";
    44     private const string RobocodePathParamaterName = "Path";
     44    private const string RobocodePathParamaterName = "RobocodePath";
     45    private const string NrOfRoundsParameterName = "NrOfRounds";
    4546    #endregion
    4647
     
    5758    public IFixedValueParameter<DirectoryValue> RobocodePathParameter {
    5859      get { return (IFixedValueParameter<DirectoryValue>)Parameters[RobocodePathParamaterName]; }
     60    }
     61    public IFixedValueParameter<IntValue> NrOfRoundsParameter {
     62      get { return (IFixedValueParameter<IntValue>)Parameters[NrOfRoundsParameterName]; }
    5963    }
    6064    #endregion
     
    7781      Parameters.Add(new ValueParameter<Grammar>(TankGrammarParameterName, "Grammar for the tank program.", new Grammar()));
    7882      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)));
    7984
    8085      Maximization.Value = true;
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Solution.cs

    r9890 r9926  
    3535    public string Path { get; set; }
    3636
     37    [Storable]
     38    public int NrOfRounds { get; set; }
     39
    3740    [StorableConstructor]
    3841    private Solution(bool deserializing) : base(deserializing) { }
     
    4144      Tree = cloner.Clone(original.Tree);
    4245      Path = (string)original.Path.Clone();
     46      NrOfRounds = original.NrOfRounds;
    4347    }
    4448
    45     public Solution(ISymbolicExpressionTree tree, string path)
     49    public Solution(ISymbolicExpressionTree tree, string path, int nrOfRounds)
    4650      : base() {
    4751      this.Tree = tree;
    4852      this.Path = path;
     53      this.NrOfRounds = nrOfRounds;
    4954    }
    5055
Note: See TracChangeset for help on using the changeset viewer.