Free cookie consent management tool by TermsFeed Policy Generator

Changeset 9612 for branches/Robocode


Ignore:
Timestamp:
06/12/13 13:05:24 (12 years ago)
Author:
ascheibe
Message:

#2069

  • fixed error handling for external program calls
  • added missing StorableClass attribute
Location:
branches/Robocode/HeuristicLab.Problems.Robocode
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/Robocode/HeuristicLab.Problems.Robocode/Interpreter.cs

    r9601 r9612  
    7070      string cmdOutput = javaCompile.StandardOutput.ReadToEnd();
    7171      cmdOutput += javaCompile.StandardError.ReadToEnd();
     72
    7273      //Evaluator.tankStatLog += cmdOutput;
    7374      //Console.WriteLine(cmdOutput);
     
    7980
    8081      javaCompile.WaitForExit();
     82      if (javaCompile.ExitCode != 0) {
     83        return -1000.0;
     84      }
    8185      #endregion
    8286
     
    101105      evaluateCode.Start();
    102106
    103       // instead of p.WaitForExit(), do
    104107      StringBuilder q = new StringBuilder();
    105108      string scoreString = "";
    106       while (!evaluateCode.HasExited) {
     109      evaluateCode.WaitForExit();
     110
     111      try {
    107112        scoreString = evaluateCode.StandardOutput.ReadToEnd().Split(
    108113        new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries).Last();
    109114        q.Append("Output: " + scoreString + "\r\n");
    110115        q.Append("Error: " + evaluateCode.StandardError.ReadToEnd() + "\r\n");
    111       }
    112       cmdOutput += q.ToString();
     116        cmdOutput += q.ToString();
     117      }catch {
     118        return -1000.0;
     119      }
    113120
    114121      #endregion
  • branches/Robocode/HeuristicLab.Problems.Robocode/Symbols/Event Methods/Events/EmptyEvent.cs

    r9609 r9612  
    33using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    44
    5 namespace HeuristicLab.Problems.Robocode
    6 {
    7     class EmptyEvent: CodeNode
    8     {
    9         public override int MinimumArity { get { return 0; } }
    10         public override int MaximumArity { get { return 0; } }
     5namespace HeuristicLab.Problems.Robocode {
     6  [StorableClass]
     7  public class EmptyEvent : CodeNode {
     8    public override int MinimumArity { get { return 0; } }
     9    public override int MaximumArity { get { return 0; } }
    1110
    12         [Storable]
    13         public override string Prefix { get; set; }
     11    [Storable]
     12    public override string Prefix { get; set; }
    1413
    15         [Storable]
    16         public override string Suffix { get; set; }
     14    [Storable]
     15    public override string Suffix { get; set; }
    1716
    18         [StorableConstructor]
    19         private EmptyEvent(bool deserializing) : base(deserializing) { }
    20         private EmptyEvent(EmptyEvent original, Cloner cloner)
    21             : base(original, cloner)
    22         {
    23             this.Prefix = "";
    24             this.Suffix = "";
    25         }
     17    [StorableConstructor]
     18    private EmptyEvent(bool deserializing) : base(deserializing) { }
     19    private EmptyEvent(EmptyEvent original, Cloner cloner)
     20      : base(original, cloner) {
     21      this.Prefix = "";
     22      this.Suffix = "";
     23    }
    2624
    27         public EmptyEvent()
    28             : base("EmptyEvent", "This is a placeholder for an empty event.")
    29         {
    30             this.Prefix = "";
    31             this.Suffix = "";
    32         }
     25    public EmptyEvent()
     26      : base("EmptyEvent", "This is a placeholder for an empty event.") {
     27      this.Prefix = "";
     28      this.Suffix = "";
     29    }
    3330
    34         public override IDeepCloneable Clone(Cloner cloner)
    35         {
    36             return new EmptyEvent(this, cloner);
    37         }
     31    public override IDeepCloneable Clone(Cloner cloner) {
     32      return new EmptyEvent(this, cloner);
     33    }
    3834
    39         public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children)
    40         {
    41             return "";
    42         }
     35    public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
     36      return "";
    4337    }
     38  }
    4439}
Note: See TracChangeset for help on using the changeset viewer.