Changeset 13013


Ignore:
Timestamp:
10/15/15 16:39:12 (4 years ago)
Author:
gkronber
Message:

#2069: reviewing and minor changes

Location:
branches/Robocode.TrunkInt
Files:
75 edited

Legend:

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

    r13011 r13013  
    1919 */
    2020#endregion
    21 namespace HeuristicLab.Problems.GeneticProgramming.Views.RoboCode {
     21namespace HeuristicLab.Problems.GeneticProgramming.Views.Robocode {
    2222  partial class BattleRunnerDialog {
    2323    /// <summary>
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode.Views/3.3/BattleRunnerDialog.cs

    r13011 r13013  
    2323using System.Windows.Forms;
    2424using HeuristicLab.Common;
    25 using HeuristicLab.Problems.GeneticProgramming.RoboCode;
     25using HeuristicLab.Problems.GeneticProgramming.Robocode;
    2626
    27 namespace HeuristicLab.Problems.GeneticProgramming.Views.RoboCode {
     27namespace HeuristicLab.Problems.GeneticProgramming.Views.Robocode {
    2828  public partial class BattleRunnerDialog : Form {
    2929    public int NrOfRounds {
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode.Views/3.3/CodeNodeView.Designer.cs

    r13011 r13013  
    1919 */
    2020#endregion
    21 namespace HeuristicLab.Problems.GeneticProgramming.Views.RoboCode {
     21namespace HeuristicLab.Problems.GeneticProgramming.Views.Robocode {
    2222  partial class CodeNodeView {
    2323    /// <summary>
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode.Views/3.3/CodeNodeView.cs

    r13011 r13013  
    2323using HeuristicLab.Core.Views;
    2424using HeuristicLab.MainForm;
    25 using HeuristicLab.Problems.GeneticProgramming.RoboCode;
     25using HeuristicLab.Problems.GeneticProgramming.Robocode;
    2626
    27 namespace HeuristicLab.Problems.GeneticProgramming.Views.RoboCode {
     27namespace HeuristicLab.Problems.GeneticProgramming.Views.Robocode {
    2828  [View("CodeNode View")]
    2929  [Content(typeof(CodeNode), IsDefaultView = true)]
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode.Views/3.3/EnemyCollectionView.Designer.cs

    r13011 r13013  
    2121
    2222
    23 namespace HeuristicLab.Problems.GeneticProgramming.Views.RoboCode {
     23namespace HeuristicLab.Problems.GeneticProgramming.Views.Robocode {
    2424  partial class EnemyCollectionView {
    2525    /// <summary>
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode.Views/3.3/EnemyCollectionView.cs

    r13011 r13013  
    2020#endregion
    2121
    22 using System.Windows.Forms;
     22using HeuristicLab.Core.Views;
     23using HeuristicLab.Data;
    2324using HeuristicLab.MainForm;
    24 using HeuristicLab.Problems.GeneticProgramming.RoboCode;
     25using HeuristicLab.Problems.GeneticProgramming.Robocode;
    2526
    26 namespace HeuristicLab.Problems.GeneticProgramming.Views.RoboCode {
     27namespace HeuristicLab.Problems.GeneticProgramming.Views.Robocode {
    2728  [View("EnemyCollection View")]
    2829  [Content(typeof(EnemyCollection), true)]
    29   public partial class EnemyCollectionView : Core.Views.CheckedItemListView<HeuristicLab.Data.StringValue> {
     30  public partial class EnemyCollectionView : CheckedItemListView<StringValue> {
    3031    public new EnemyCollection Content {
    3132      get { return (EnemyCollection)base.Content; }
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode.Views/3.3/Plugin.cs.frame

    r13011 r13013  
    2727using HeuristicLab.PluginInfrastructure;
    2828
    29 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode.Views
     29namespace HeuristicLab.Problems.GeneticProgramming.Robocode.Views
    3030{
    3131    [Plugin("HeuristicLab.Problems.Robocode.Views", "The Robocode problem for genetic programming.", "3.3.9.$WCREV$")]
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode.Views/3.3/SolutionCodeView.Designer.cs

    r13011 r13013  
    1919 */
    2020#endregion
    21 namespace HeuristicLab.Problems.GeneticProgramming.Views.RoboCode {
     21namespace HeuristicLab.Problems.GeneticProgramming.Views.Robocode {
    2222  partial class SolutionCodeView {
    2323    /// <summary>
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode.Views/3.3/SolutionCodeView.cs

    r13011 r13013  
    2525using HeuristicLab.Core.Views;
    2626using HeuristicLab.MainForm;
    27 using HeuristicLab.Problems.GeneticProgramming.RoboCode;
     27using HeuristicLab.Problems.GeneticProgramming.Robocode;
    2828
    29 namespace HeuristicLab.Problems.GeneticProgramming.Views.RoboCode {
     29namespace HeuristicLab.Problems.GeneticProgramming.Views.Robocode {
    3030  [View("Robocode Tank Code View")]
    3131  [Content(typeof(Solution), IsDefaultView = true)]
     
    4545    protected override void OnContentChanged() {
    4646      base.OnContentChanged();
    47       if (Content == null) {
    48         programCode.Text = string.Empty;
    49       } else {
    50         programCode.Text = Interpreter.InterpretProgramTree(Content.Tree.Root, programName);
    51       }
     47      programCode.Text = Content == null ? string.Empty : Interpreter.InterpretProgramTree(Content.Tree.Root, programName);
    5248    }
    5349
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode.Views/3.3/SolutionProgramView.Designer.cs

    r13011 r13013  
    2222using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views;
    2323
    24 namespace HeuristicLab.Problems.GeneticProgramming.Views.RoboCode {
     24namespace HeuristicLab.Problems.GeneticProgramming.Views.Robocode {
    2525  partial class SolutionProgramView {
    2626    private void InitializeComponent() {
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode.Views/3.3/SolutionProgramView.cs

    r13011 r13013  
    2222using HeuristicLab.Core.Views;
    2323using HeuristicLab.MainForm;
    24 using HeuristicLab.Problems.GeneticProgramming.RoboCode;
     24using HeuristicLab.Problems.GeneticProgramming.Robocode;
    2525
    26 namespace HeuristicLab.Problems.GeneticProgramming.Views.RoboCode {
     26namespace HeuristicLab.Problems.GeneticProgramming.Views.Robocode {
    2727  [View("Robocode Tank Program Tree View")]
    2828  [Content(typeof(Solution), IsDefaultView = false)]
     
    3939    protected override void OnContentChanged() {
    4040      base.OnContentChanged();
    41       if (Content == null) {
    42         graphTreeView.Content = null;
    43       } else {
    44         graphTreeView.Content = Content.Tree;
    45       }
     41      graphTreeView.Content = Content == null ? null : Content.Tree;
    4642    }
    4743  }
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/BattleRunner.java

    r13010 r13013  
    2727//
    2828public class BattleRunner {
    29     public static String player = "Evaluation.output*";   
    30     public static List<Double> score = new ArrayList<Double>();
     29  public static String player = "Evaluation.output*";   
     30  public static List<Double> score = new ArrayList<Double>();
    3131
    32   // This program requires 5 arguments:
     32  // This program requires 5 arguments:
    3333  // The first argument is the name of the robot.
    34   // The second argument is the path to the robocode installation. If not give, c:\robocode is assumed.
    35   // The third argument: true if Robocode should be shown, otherwise it is hidden.
    36   // The fourth argument is the number of rounds.
     34  // The second argument is the path to the robocode installation. If not give, c:\robocode is assumed.
     35  // The third argument: true if Robocode should be shown, otherwise it is hidden.
     36  // The fourth argument is the number of rounds.
    3737  // The remaining arguments are the names of the opponents. At least 1 must be provided.
    38   public static void main(String[] args) {
    39     if (args.length < 5)
    40       System.exit(-1); 
     38  public static void main(String[] args) {
     39    if (args.length < 5)
     40      System.exit(-1); 
    4141
    42     String roboCodePath = "C:\\robocode";
    43     Boolean visible = false;   
    44     String bots = "";
    45     int numberOfRounds = 3;
    46         String[] robots = new String[1 + args.length - 4];     
     42    String roboCodePath = "C:\\robocode";
     43    Boolean visible = false;
     44    String bots = "";
     45    int numberOfRounds = 3;
     46    String[] robots = new String[1 + args.length - 4];
    4747
    48     player = robots[0] = args[0];       
    49     roboCodePath = args[1];
    50     visible = Boolean.valueOf(args[2]);
    51     numberOfRounds = Integer.valueOf(args[3]);
    52     for (int i = 4; i < args.length; i++)
    53       robots[i - 3] = args[i];
     48    player = robots[0] = args[0];
     49    roboCodePath = args[1];
     50    visible = Boolean.valueOf(args[2]);
     51    numberOfRounds = Integer.valueOf(args[3]);
     52    for (int i = 4; i < args.length; i++) {
     53      robots[i - 3] = args[i];
     54    }
    5455
    55         RobocodeEngine.setLogMessagesEnabled(false);
    56         RobocodeEngine engine = new RobocodeEngine(new java.io.File(roboCodePath));
    57     engine.setVisible(visible);       
    58         engine.addBattleListener(new BattleObserver());       
     56    RobocodeEngine.setLogMessagesEnabled(false);
     57    RobocodeEngine engine = new RobocodeEngine(new java.io.File(roboCodePath));
     58    engine.setVisible(visible);
     59    engine.addBattleListener(new BattleObserver());
    5960
    60     BattlefieldSpecification battlefield = new BattlefieldSpecification(800, 600);
    61         RobotSpecification[] all = engine.getLocalRepository();
    62     List<RobotSpecification> selectedRobots = new ArrayList<RobotSpecification>();
    63    
    64     for(RobotSpecification rs : all) {
    65       for(String r : robots) {
    66         if(r.equals(rs.getClassName())) {
    67           selectedRobots.add(rs);       
    68         }     
    69       }
    70     }   
    71    
    72     for (int i = 1; i < selectedRobots.size(); i++) {
    73       BattleSpecification battleSpec = new BattleSpecification(numberOfRounds, battlefield,
    74       new RobotSpecification[] { selectedRobots.get(0), selectedRobots.get(i) });
     61    BattlefieldSpecification battlefield = new BattlefieldSpecification(800, 600);
     62    RobotSpecification[] all = engine.getLocalRepository();
     63    List<RobotSpecification> selectedRobots = new ArrayList<RobotSpecification>();
     64   
     65    for(RobotSpecification rs : all) {
     66      for(String r : robots) {
     67        if(r.equals(rs.getClassName())) {
     68          selectedRobots.add(rs);
     69        }
     70      }
     71    }
    7572
    76             // run our specified battle and wait till the battle finishes
    77             engine.runBattle(battleSpec, true);
    78         }
    79         engine.close();
     73    for (int i = 1; i < selectedRobots.size(); i++) {
     74      BattleSpecification battleSpec = new BattleSpecification(numberOfRounds, battlefield, new RobotSpecification[] { selectedRobots.get(0), selectedRobots.get(i) });
    8075
    81     // print out result which is then parsed by HeuristicLab
    82         System.out.println(avg(score));
    83         System.exit(0);
     76      // run our specified battle and wait till the battle finishes
     77      engine.runBattle(battleSpec, true);
    8478    }
    85  
    86   private static double avg(List <Double> lst) {
    87     double sum = 0;
    88     for (double val : lst) {
    89       sum += val;
    90     }
    91     return sum / lst.size();
    92   }
     79    engine.close();
     80
     81    // print out result which is then parsed by HeuristicLab
     82    System.out.println(avg(score));
     83    System.exit(0);
     84  }
     85
     86  private static double avg(List <Double> lst) {
     87    double sum = 0;
     88    for (double val : lst) {
     89      sum += val;
     90    }
     91    return sum / lst.size();
     92  }
    9393}
    9494
     
    9797//
    9898class BattleObserver extends BattleAdaptor {
    99   public void onBattleCompleted(BattleCompletedEvent e) {   
    100     double robotScore = -1.0;
    101     double opponentScore = -1.0;
    102    
    103         for (robocode.BattleResults result : e.getSortedResults()) {     
     99  public void onBattleCompleted(BattleCompletedEvent e) {
     100    double robotScore = -1.0;
     101    double opponentScore = -1.0;
     102   
     103        for (robocode.BattleResults result : e.getSortedResults()) {
    104104            if (result.getTeamLeaderName().contains(BattleRunner.player))
    105105                robotScore = result.getScore();
     
    107107                opponentScore = result.getScore();
    108108        }
    109    
    110     //prevent div / 0 which can happen if both robots do not score
    111     if((robotScore + opponentScore) == 0) {
    112       BattleRunner.score.add(0.0);   
    113     } else {
    114       BattleRunner.score.add(robotScore / (robotScore + opponentScore));   
    115     }
     109   
     110    //prevent div / 0 which can happen if both robots do not score
     111    if((robotScore + opponentScore) == 0) {
     112      BattleRunner.score.add(0.0);
     113    } else {
     114      BattleRunner.score.add(robotScore / (robotScore + opponentScore));
    116115    }
     116  }
    117117}
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/BestSolutionAnalyzer.cs

    r13011 r13013  
    2929using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3030
    31 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode {
     31namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
    3232  [StorableClass]
    3333  [Item("Best Tank Program Analyzer",
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/EnemyCollection.cs

    r13011 r13013  
    2929using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3030
    31 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode {
    32   [Item("EnemyCollection", "A collection of enemy robots.")]
     31namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
     32  [Item("EnemyCollection", "A collection of enemy robots for the Robocode genetic programming problem.")]
    3333  [StorableClass]
    3434  public class EnemyCollection : CheckedItemList<StringValue> {
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Grammar.cs

    r13011 r13013  
    2525using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2626
    27 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode {
     27namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
    2828  [StorableClass]
    2929  [Item("Robocode Grammar", "The grammar for the Robocode GP problem.")]
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Interpreter.cs

    r13011 r13013  
    2626using System.Linq;
    2727using System.Reflection;
    28 using HeuristicLab.Core;
    29 using HeuristicLab.Data;
    3028using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    3129
    32 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode {
     30namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
    3331  public static class Interpreter {
    3432    public static double EvaluateTankProgram(ISymbolicExpressionTree tree, string path, EnemyCollection enemies, string robotName = null, bool showUI = false, int nrOfRounds = 3) {
     
    4745      File.WriteAllText(srcRobotPath, interpretedProgram, System.Text.Encoding.Default);
    4846
     47      // compile java source to class file
    4948      ProcessStartInfo javaCompileInfo = new ProcessStartInfo();
    5049      javaCompileInfo.FileName = "cmd.exe";
     
    5554      javaCompileInfo.CreateNoWindow = true;
    5655
    57       Process javaCompile = new Process();
    58       javaCompile.StartInfo = javaCompileInfo;
    59       javaCompile.Start();
     56      using (Process javaCompile = new Process()) {
     57        javaCompile.StartInfo = javaCompileInfo;
     58        javaCompile.Start();
    6059
    61       string cmdOutput = javaCompile.StandardOutput.ReadToEnd();
    62       cmdOutput += javaCompile.StandardError.ReadToEnd();
     60        string cmdOutput = javaCompile.StandardOutput.ReadToEnd();
     61        cmdOutput += javaCompile.StandardError.ReadToEnd();
    6362
    64       javaCompile.WaitForExit();
    65       if (javaCompile.ExitCode != 0) {
    66         DeleteRobotFiles(path, robotName);
    67         throw new Exception("Compile Error: " + cmdOutput);
     63        javaCompile.WaitForExit();
     64        if (javaCompile.ExitCode != 0) {
     65          DeleteRobotFiles(path, robotName);
     66          throw new Exception("Compile Error: " + cmdOutput);
     67        }
    6868      }
    6969
    7070      //parallel execution of multiple robocode instances can sometimes lead to a damaged robot.database
    71       try { File.Delete(path + @"\robots\robot.database"); }
    72       catch { }
     71      var robotsDbFileName = Path.Combine(path, "robots", "robot.database");
     72      if (File.Exists(robotsDbFileName))
     73        File.Delete(robotsDbFileName);
    7374
    7475      ProcessStartInfo evaluateCodeInfo = new ProcessStartInfo();
    7576
     77      // execute a battle with numberOfRounds against a number of enemies
     78      // TODO: seems there is a bug when selecting multiple enemies
    7679      evaluateCodeInfo.FileName = "cmd.exe";
    77       evaluateCodeInfo.Arguments = "/C java -cp " + battleRunnerPath + ";" + robocodeCoreJar + ";" + robocodeJar +
    78                                   ";" + picocontainerJar + ";" + " BattleRunner Evaluation." + robotName + " " + path;
    79 
    80       if (showUI) {
    81         evaluateCodeInfo.Arguments += " true " + nrOfRounds + " ";
    82       } else {
    83         evaluateCodeInfo.Arguments += " false " + nrOfRounds + " ";
    84       }
    85 
    86       foreach (var enemy in enemies.CheckedItems)
    87         evaluateCodeInfo.Arguments += enemy.Value + " ";
     80      var classpath = string.Join(";", new[] { battleRunnerPath, robocodeCoreJar, robocodeJar, picocontainerJar });
     81      var enemyRobotNames = string.Join(" ", enemies.CheckedItems.Select(i => i.Value));
     82      evaluateCodeInfo.Arguments = string.Format("/C java -cp {0} BattleRunner Evaluation.{1} {2} {3} {4} {5}", classpath, robotName, path, showUI, nrOfRounds, enemyRobotNames);
    8883
    8984      evaluateCodeInfo.RedirectStandardOutput = true;
     
    9287      evaluateCodeInfo.CreateNoWindow = true;
    9388
    94       Process evaluateCode = new Process();
    95       evaluateCode.StartInfo = evaluateCodeInfo;
    96       evaluateCode.Start();
    97       evaluateCode.WaitForExit();
     89      double evaluation;
     90      using (Process evaluateCode = new Process()) {
     91        evaluateCode.StartInfo = evaluateCodeInfo;
     92        evaluateCode.Start();
     93        evaluateCode.WaitForExit();
    9894
    99       if (evaluateCode.ExitCode != 0) {
    100         DeleteRobotFiles(path, robotName);
    101         throw new Exception("Error running Robocode: " + evaluateCode.StandardError.ReadToEnd());
    102       }
     95        if (evaluateCode.ExitCode != 0) {
     96          DeleteRobotFiles(path, robotName);
     97          throw new Exception("Error running Robocode: " + evaluateCode.StandardError.ReadToEnd() + Environment.NewLine +
     98                              evaluateCode.StandardOutput.ReadToEnd());
     99        }
    103100
    104       string scoreString = "";
    105       double evaluation = -1.0;
    106       try {
    107         scoreString = evaluateCode.StandardOutput.ReadToEnd().Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).Last();
    108         evaluation = Double.Parse(scoreString, CultureInfo.InvariantCulture);
    109       }
    110       catch (Exception ex) {
    111         throw new Exception("Error parsing score string: " + ex.ToString());
    112       }
    113       finally {
    114         DeleteRobotFiles(path, robotName);
     101        try {
     102          string scoreString =
     103            evaluateCode.StandardOutput.ReadToEnd()
     104              .Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)
     105              .Last();
     106          evaluation = Double.Parse(scoreString, CultureInfo.InvariantCulture);
     107        }
     108        catch (Exception ex) {
     109          throw new Exception("Error parsing score string: " + ex);
     110        }
     111        finally {
     112          DeleteRobotFiles(path, robotName);
     113        }
    115114      }
    116115
     
    119118
    120119    private static void DeleteRobotFiles(string path, string outputname) {
    121       try {
    122         File.Delete(path + @"\robots\Evaluation\" + outputname + ".java");
    123         File.Delete(path + @"\robots\Evaluation\" + outputname + ".class");
    124       }
    125       catch { }
     120      File.Delete(path + @"\robots\Evaluation\" + outputname + ".java");
     121      File.Delete(path + @"\robots\Evaluation\" + outputname + ".class");
    126122    }
    127123
     
    132128      }
    133129      catch {
    134         throw new Exception("Error finding required RoboCode files.");
     130        throw new Exception("Error finding required Robocode files.");
    135131      }
    136132      return fileName;
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Plugin.cs.frame

    r13011 r13013  
    2727using HeuristicLab.PluginInfrastructure;
    2828
    29 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode
     29namespace HeuristicLab.Problems.GeneticProgramming.Robocode
    3030{
    3131    [Plugin("HeuristicLab.Problems.Robocode", "The Robocode problem for genetic programming.", "3.3.9.$WCREV$")]
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/RobocodeEvaluator.cs

    r13011 r13013  
    2929using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3030
    31 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode {
     31namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
    3232  [StorableClass]
    3333  [Item("Robocode Evaluator", "Evaluator for the Robocode GP problem.")]
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/RobocodeProblem.cs

    r13011 r13013  
    3030using HeuristicLab.PluginInfrastructure;
    3131
    32 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode {
     32namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
    3333  [StorableClass]
    3434  [Creatable("Problems")]
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Solution.cs

    r13011 r13013  
    2525using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2626
    27 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode {
     27namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
    2828  [StorableClass]
    2929  [Item("Solution", "Robocode program and configuration.")]
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Block.cs

    r13011 r13013  
    2626using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2727
    28 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode {
     28namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
    2929  [StorableClass]
    3030  public class Block : CodeNode {
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/CodeNode.cs

    r13011 r13013  
    2525using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2626
    27 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode {
     27namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
    2828  [StorableClass]
    2929  public abstract class CodeNode : Symbol {
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Event Methods/Events/EmptyEvent.cs

    r13011 r13013  
    2525using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2626
    27 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode {
     27namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
    2828  [StorableClass]
    2929  public class EmptyEvent : CodeNode {
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Event Methods/Events/OnBulletHit.cs

    r13011 r13013  
    2727using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2828
    29 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode {
     29namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
    3030  [StorableClass]
    3131  public class OnBulletHit : CodeNode {
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Event Methods/Events/OnBulletMissed.cs

    r13011 r13013  
    2727using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2828
    29 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode {
     29namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
    3030  [StorableClass]
    3131  public class OnBulletMissed : CodeNode {
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Event Methods/Events/OnHitByBullet.cs

    r13011 r13013  
    2727using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2828
    29 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode {
     29namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
    3030  [StorableClass]
    3131  public class OnHitByBullet : CodeNode {
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Event Methods/Events/OnHitRobot.cs

    r13011 r13013  
    2727using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2828
    29 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode {
     29namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
    3030  [StorableClass]
    3131  public class OnHitRobot : CodeNode {
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Event Methods/Events/OnHitWall.cs

    r13011 r13013  
    2727using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2828
    29 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode {
     29namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
    3030  [StorableClass]
    3131  public class OnHitWall : CodeNode {
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Event Methods/Events/OnScannedRobot.cs

    r13011 r13013  
    2727using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2828
    29 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode {
     29namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
    3030  [StorableClass]
    3131  public class OnScannedRobot : CodeNode {
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Event Methods/Run.cs

    r13011 r13013  
    2727using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2828
    29 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode {
     29namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
    3030  [StorableClass]
    3131  public class Run : CodeNode {
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Logical Expressions/BooleanTreeNode.cs

    r13011 r13013  
    2525using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2626
    27 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode {
     27namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
    2828  [StorableClass]
    2929  public class BooleanTreeNode : SymbolicExpressionTreeTerminalNode {
     
    5353
    5454    public override void ResetLocalParameters(IRandom random) {
    55       value = random.Next(0, 2) == 1;
     55      // initialization
     56      value = random.NextDouble() > 0.5;
     57    }
     58
     59    public override void ShakeLocalParameters(IRandom random, double shakingFactor) {
     60      // mutation: flip value with 5% probability
     61      if (random.NextDouble() < 0.05) value = !value;
    5662    }
    5763  }
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Logical Expressions/Conjunction.cs

    r13011 r13013  
    2727using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2828
    29 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode {
     29namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
    3030  [StorableClass]
    3131  public class Conjunction : CodeNode {
     
    5555    public override string Interpret(ISymbolicExpressionTreeNode node, IEnumerable<ISymbolicExpressionTreeNode> children) {
    5656      if (children.Count() < 2)
    57         throw new ArgumentException("Expected at leaset 2 children.", "children");
     57        throw new ArgumentException("Expected at least two children.", "children");
    5858
    5959      string result = string.Join(" && ", children.Select(c => ((CodeNode)c.Symbol).Interpret(c, c.Subtrees)));
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Logical Expressions/Disjunction.cs

    r13011 r13013  
    2727using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2828
    29 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode {
     29namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
    3030  [StorableClass]
    3131  public class Disjunction : CodeNode {
     
    5555    public override string Interpret(ISymbolicExpressionTreeNode node, IEnumerable<ISymbolicExpressionTreeNode> children) {
    5656      if (children.Count() < 2)
    57         throw new ArgumentException("Expected at leaset 2 children.", "children");
     57        throw new ArgumentException("Expected at least two children.", "children");
    5858
    5959      string result = string.Join(" || ", children.Select(c => ((CodeNode)c.Symbol).Interpret(c, c.Subtrees)));
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Logical Expressions/Logical Comparators/Equal.cs

    r13011 r13013  
    2727using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2828
    29 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode {
     29namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
    3030  [StorableClass]
    3131  public class Equal : CodeNode, ILogicalComparator {
     
    5252      ISymbolicExpressionTreeNode lhs = null, rhs = null;
    5353      if (children.Count() != 2)
    54         throw new Exception("Unexpected number of children. Expected 2 children.");
     54        throw new Exception("Unexpected number of children. Expected two children.");
    5555
    5656      lhs = children.First();
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Logical Expressions/Logical Comparators/GreaterThan.cs

    r13011 r13013  
    2727using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2828
    29 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode {
     29namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
    3030  [StorableClass]
    3131  public class GreaterThan : CodeNode, ILogicalComparator {
     
    5252      ISymbolicExpressionTreeNode lhs = null, rhs = null;
    5353      if (children.Count() != 2)
    54         throw new Exception("Unexpected number of children. Expected 2 children.");
     54        throw new Exception("Unexpected number of children. Expected two children.");
    5555
    5656      lhs = children.First();
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Logical Expressions/Logical Comparators/GreaterThanOrEqual.cs

    r13011 r13013  
    2727using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2828
    29 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode {
     29namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
    3030  [StorableClass]
    3131  public class GreaterThanOrEqual : CodeNode, ILogicalComparator {
     
    5252      ISymbolicExpressionTreeNode lhs = null, rhs = null;
    5353      if (children.Count() != 2)
    54         throw new Exception("Unexpected number of children. Expected 2 children.");
     54        throw new Exception("Unexpected number of children. Expected two children.");
    5555
    5656      lhs = children.First();
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Logical Expressions/Logical Comparators/ILogicalComparator.cs

    r13011 r13013  
    2020#endregion
    2121
    22 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode {
     22namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
    2323  public interface ILogicalComparator { }
    2424}
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Logical Expressions/Logical Comparators/LessThan.cs

    r13011 r13013  
    2727using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2828
    29 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode {
     29namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
    3030  [StorableClass]
    3131  public class LessThan : CodeNode, ILogicalComparator {
     
    5252      ISymbolicExpressionTreeNode lhs = null, rhs = null;
    5353      if (children.Count() != 2)
    54         throw new Exception("Unexpected number of children. Expected 2 children.");
     54        throw new Exception("Unexpected number of children. Expected two children.");
    5555
    5656      lhs = children.First();
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Logical Expressions/Logical Comparators/LessThanOrEqual.cs

    r13011 r13013  
    2727using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2828
    29 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode {
     29namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
    3030  [StorableClass]
    3131  public class LessThanOrEqual : CodeNode, ILogicalComparator {
     
    5252      ISymbolicExpressionTreeNode lhs = null, rhs = null;
    5353      if (children.Count() != 2)
    54         throw new Exception("Unexpected number of children. Expected 2 children.");
     54        throw new Exception("Unexpected number of children. Expected two children.");
    5555
    5656      lhs = children.First();
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Logical Expressions/LogicalExpression.cs

    r13011 r13013  
    2727using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2828
    29 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode {
     29namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
    3030  [StorableClass]
    3131  public class LogicalExpression : CodeNode {
     
    5656      var symbol = exprTree.Symbol;
    5757      if (!(symbol is LogicalValue || symbol is Conjunction || symbol is Disjunction || symbol is Negation))
    58         throw new System.Exception("LogicalExpression was given a child of type " + symbol.GetType() +
    59             ". The expected child must be of type " + typeof(LogicalValue)
    60                                            + " or " + typeof(Conjunction)
    61                                            + " or " + typeof(Disjunction)
    62                                            + " or " + typeof(Negation) + ".");
     58        throw new InvalidProgramException("Negation was given a child of type " + symbol.GetType() +
     59            ". The expected child must be of type LogicalValue or Conjunction or Disjunction or Negation.");
    6360
    6461      return Prefix + ((CodeNode)symbol).Interpret(exprTree, exprTree.Subtrees) + Suffix;
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Logical Expressions/LogicalValue.cs

    r13011 r13013  
    2525using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2626
    27 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode {
     27namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
    2828  [StorableClass]
    2929  public class LogicalValue : CodeNode {
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Logical Expressions/Negation.cs

    r13011 r13013  
    2727using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2828
    29 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode {
     29namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
    3030  [StorableClass]
    3131  public class Negation : CodeNode {
     
    6060      var symbol = exprTree.Symbol;
    6161      if (!(symbol is LogicalValue || symbol is Conjunction || symbol is Disjunction || symbol is Negation || symbol is ILogicalComparator))
    62         throw new System.Exception("Negation was given a child of type " + symbol.GetType() +
    63             ". The expected child must be of type " + typeof(LogicalValue)
    64                                            + " or " + typeof(Conjunction)
    65                                            + " or " + typeof(Disjunction)
    66                                            + " or " + typeof(Negation)
    67                                            + " or " + typeof(ILogicalComparator) + ".");
     62        throw new InvalidProgramException("Negation was given a child of type " + symbol.GetType() +
     63            ". The expected child must be of type LogicalValue or Conjunction or Disjunction or Negation or ILogicalComparator.");
    6864
    6965      return Prefix + ((CodeNode)symbol).Interpret(exprTree, exprTree.Subtrees) + Suffix;
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Numerical Expressions/Number.cs

    r13011 r13013  
    2626using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2727
    28 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode {
     28namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
    2929  [StorableClass]
    3030  public class Number : CodeNode {
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Numerical Expressions/NumberTreeNode.cs

    r13011 r13013  
    2525using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2626
    27 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode {
     27namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
    2828  [StorableClass]
    2929  public class NumberTreeNode : SymbolicExpressionTreeTerminalNode {
     
    5353
    5454    public override void ResetLocalParameters(IRandom random) {
     55      // random initialization
    5556      value = random.Next(-360, 360);
     57    }
     58
     59    public override void ShakeLocalParameters(IRandom random, double shakingFactor) {
     60      // random mutation (cyclic)
     61      value = value + random.Next(-20, 20);
     62      if (value < -360) value += 2 * 360;
     63      else if (value > 359) value -= 2 * 360;
    5664    }
    5765  }
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Numerical Expressions/Numerical Operators/Addition.cs

    r13011 r13013  
    2727using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2828
    29 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode {
     29namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
    3030  [StorableClass]
    3131  public class Addition : CodeNode, INumericalOperator {
     
    5555    public override string Interpret(ISymbolicExpressionTreeNode node, IEnumerable<ISymbolicExpressionTreeNode> children) {
    5656      if (children.Count() < 2)
    57         throw new ArgumentException("Expected at leaset 2 children.", "children");
     57        throw new ArgumentException("Expected at least two children.", "children");
    5858
    5959      string result = string.Join(" + ", children.Select(c => ((CodeNode)c.Symbol).Interpret(c, c.Subtrees)));
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Numerical Expressions/Numerical Operators/Division.cs

    r13011 r13013  
    2727using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2828
    29 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode {
     29namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
    3030  [StorableClass]
    3131  public class Division : CodeNode, INumericalOperator {
     
    5555    public override string Interpret(ISymbolicExpressionTreeNode node, IEnumerable<ISymbolicExpressionTreeNode> children) {
    5656      if (children.Count() < 2)
    57         throw new ArgumentException("Expected at leaset 2 children.", "children");
     57        throw new ArgumentException("Expected at least two children.", "children");
    5858
    5959      string result = string.Join(" / ", children.Select(c => ((CodeNode)c.Symbol).Interpret(c, c.Subtrees)));
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Numerical Expressions/Numerical Operators/INumericalOperator.cs

    r13011 r13013  
    2020#endregion
    2121
    22 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode {
     22namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
    2323  public interface INumericalOperator { }
    2424}
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Numerical Expressions/Numerical Operators/Modulus.cs

    r13011 r13013  
    2727using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2828
    29 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode {
     29namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
    3030  [StorableClass]
    3131  public class Modulus : CodeNode, INumericalOperator {
     
    5555    public override string Interpret(ISymbolicExpressionTreeNode node, IEnumerable<ISymbolicExpressionTreeNode> children) {
    5656      if (children.Count() < 2)
    57         throw new ArgumentException("Expected at leaset 2 children.", "children");
     57        throw new ArgumentException("Expected at least two children.", "children");
    5858
    5959      string result = string.Join(" % ", children.Select(c => ((CodeNode)c.Symbol).Interpret(c, c.Subtrees)));
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Numerical Expressions/Numerical Operators/Multiplication.cs

    r13011 r13013  
    2727using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2828
    29 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode {
     29namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
    3030  [StorableClass]
    3131  public class Multiplication : CodeNode, INumericalOperator {
     
    5555    public override string Interpret(ISymbolicExpressionTreeNode node, IEnumerable<ISymbolicExpressionTreeNode> children) {
    5656      if (children.Count() < 2)
    57         throw new ArgumentException("Expected at leaset 2 children.", "children");
     57        throw new ArgumentException("Expected at least two children.", "children");
    5858
    5959      string result = string.Join(" * ", children.Select(c => ((CodeNode)c.Symbol).Interpret(c, c.Subtrees)));
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Numerical Expressions/Numerical Operators/Subtraction.cs

    r13011 r13013  
    2727using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2828
    29 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode {
     29namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
    3030  [StorableClass]
    3131  public class Subtraction : CodeNode, INumericalOperator {
     
    5555    public override string Interpret(ISymbolicExpressionTreeNode node, IEnumerable<ISymbolicExpressionTreeNode> children) {
    5656      if (children.Count() < 2)
    57         throw new ArgumentException("Expected at leaset 2 children.", "children");
     57        throw new ArgumentException("Expected at least two children.", "children");
    5858
    5959      string result = string.Join(" - ", children.Select(c => ((CodeNode)c.Symbol).Interpret(c, c.Subtrees)));
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Numerical Expressions/NumericalExpression.cs

    r13011 r13013  
    2727using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2828
    29 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode {
     29namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
    3030  [StorableClass]
    3131  public class NumericalExpression : CodeNode {
     
    5656      var symbol = exprTree.Symbol;
    5757      if (!(symbol is Number || symbol is INumericalMethod || symbol is INumericalOperator))
    58         throw new System.Exception("NumericalExpression was given a child of type " + symbol.GetType() +
    59             ". The expected child must be of type " + typeof(Number)
    60                                            + " or " + typeof(INumericalMethod)
    61                                            + " or " + typeof(INumericalOperator) + ".");
     58        throw new InvalidProgramException("NumericalExpression was given a child of type " + symbol.GetType() +
     59            ". The expected child must be of type Number or INumericalMethod or INumericalOperator .");
    6260
    6361      return Prefix + ((CodeNode)symbol).Interpret(exprTree, exprTree.Subtrees) + Suffix;
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Numerical Expressions/ShotPower.cs

    r13011 r13013  
    2626using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2727
    28 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode {
     28namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
    2929  [StorableClass]
    3030  public class ShotPower : CodeNode {
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Numerical Expressions/ShotPowerTreeNode.cs

    r13011 r13013  
    2626using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2727
    28 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode {
     28namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
    2929  [StorableClass]
    3030  public class ShotPowerTreeNode : SymbolicExpressionTreeTerminalNode {
     
    5454
    5555    public override void ResetLocalParameters(IRandom random) {
     56      // random initialization
    5657      value = Math.Max(0.1, random.NextDouble() * 3);
     58    }
     59
     60    public override void ShakeLocalParameters(IRandom random, double shakingFactor) {
     61      // mutation
     62      var d = random.NextDouble() * 2.0 - 1.0;
     63      value = Math.Max(0.1, value + shakingFactor * d);
    5764    }
    5865  }
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Numerical Methods/GetEnergy.cs

    r13011 r13013  
    2525using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2626
    27 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode {
     27namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
    2828  [StorableClass]
    2929  public class GetEnergy : CodeNode, INumericalMethod {
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Numerical Methods/GetGunHeading.cs

    r13011 r13013  
    2525using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2626
    27 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode {
     27namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
    2828  [StorableClass]
    2929  public class GetGunHeading : CodeNode, INumericalMethod {
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Numerical Methods/GetHeading.cs

    r13011 r13013  
    2525using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2626
    27 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode {
     27namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
    2828  [StorableClass]
    2929  public class GetHeading : CodeNode, INumericalMethod {
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Numerical Methods/GetRadarHeading.cs

    r13011 r13013  
    2525using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2626
    27 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode {
     27namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
    2828  [StorableClass]
    2929  public class GetRadarHeading : CodeNode, INumericalMethod {
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Numerical Methods/GetX.cs

    r13011 r13013  
    2525using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2626
    27 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode {
     27namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
    2828  [StorableClass]
    2929  public class GetX : CodeNode, INumericalMethod {
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Numerical Methods/GetY.cs

    r13011 r13013  
    2525using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2626
    27 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode {
     27namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
    2828  [StorableClass]
    2929  public class GetY : CodeNode, INumericalMethod {
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Numerical Methods/INumericalMethod.cs

    r13011 r13013  
    2020#endregion
    2121
    22 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode {
     22namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
    2323  public interface INumericalMethod { }
    2424}
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Program.cs

    r13011 r13013  
    2525using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2626
    27 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode {
     27namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
    2828  [StorableClass]
    2929  public class Program : Symbol {
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Stat.cs

    r13011 r13013  
    2727using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2828
    29 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode {
     29namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
    3030  [StorableClass]
    3131  public class Stat : CodeNode {
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Statements/IfThenElseStat.cs

    r13011 r13013  
    2727using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2828
    29 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode {
     29namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
    3030  [StorableClass]
    3131  public class IfThenElseStat : CodeNode {
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Statements/WhileStat.cs

    r13011 r13013  
    2626using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2727
    28 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode {
     28namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
    2929  [StorableClass]
    3030  public class WhileStat : CodeNode {
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Tank.cs

    r13011 r13013  
    2727using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2828
    29 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode {
     29namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
    3030  [StorableClass]
    3131  public class Tank : CodeNode {
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Void Methods/Ahead.cs

    r13011 r13013  
    2727using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2828
    29 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode {
     29namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
    3030  [StorableClass]
    3131  public class Ahead : CodeNode {
     
    6060      var symbol = exprTree.Symbol;
    6161      if (!(symbol is NumericalExpression))
    62         throw new Exception("Ahead was given a child of type " + symbol.GetType() +
    63             ". The expected child must be of type " + typeof(NumericalExpression) + ".");
     62        throw new InvalidProgramException("Ahead was given a child of type " + symbol.GetType() +
     63            ". The expected child must be of type NumericalExpression.");
    6464
    6565      string result = ((CodeNode)symbol).Interpret(exprTree, exprTree.Subtrees);
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Void Methods/Back.cs

    r13011 r13013  
    2727using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2828
    29 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode {
     29namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
    3030  [StorableClass]
    3131  public class Back : CodeNode {
     
    6060      var symbol = exprTree.Symbol;
    6161      if (!(symbol is NumericalExpression))
    62         throw new Exception("Back was given a child of type " + symbol.GetType() +
    63             ". The expected child must be of type " + typeof(NumericalExpression) + ".");
     62        throw new InvalidProgramException("Back was given a child of type " + symbol.GetType() +
     63            ". The expected child must be of type NumericalExpression.");
    6464
    6565      string result = ((CodeNode)symbol).Interpret(exprTree, exprTree.Subtrees);
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Void Methods/DoNothing.cs

    r13011 r13013  
    2525using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2626
    27 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode {
     27namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
    2828  [StorableClass]
    2929  public class DoNothing : CodeNode {
     
    4141    protected DoNothing(DoNothing original, Cloner cloner) : base(original, cloner) { }
    4242
    43     public DoNothing() : base("DoNothing", "Do nothing this turn, meaning that the robot will skip it's turn.") { }
     43    public DoNothing() : base("DoNothing", "Do nothing this turn, meaning that the robot will skip its turn.") { }
    4444
    4545    public override IDeepCloneable Clone(Cloner cloner) {
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Void Methods/Fire.cs

    r13011 r13013  
    2727using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2828
    29 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode {
     29namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
    3030  [StorableClass]
    3131  public class Fire : CodeNode {
     
    6060      var symbol = exprTree.Symbol;
    6161      if (!(symbol is ShotPower))
    62         throw new Exception("Fire was given a child of type " + symbol.GetType() +
    63             ". The expected child must be of type " + typeof(ShotPower) + ".");
     62        throw new InvalidProgramException("Fire was given a child of type " + symbol.GetType() +
     63            ". The expected child must be of type ShotPower.");
    6464
    6565      string result = ((CodeNode)symbol).Interpret(exprTree, exprTree.Subtrees);
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Void Methods/TurnGunLeft.cs

    r13011 r13013  
    2727using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2828
    29 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode {
     29namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
    3030  [StorableClass]
    3131  public class TurnGunLeft : CodeNode {
     
    6060      var symbol = exprTree.Symbol;
    6161      if (!(symbol is NumericalExpression))
    62         throw new Exception("TurnGunLeft was given a child of type " + symbol.GetType() +
    63             ". The expected child must be of type " + typeof(NumericalExpression) + ".");
     62        throw new InvalidProgramException("TurGunLeft was given a child of type " + symbol.GetType() +
     63            ". The expected child must be of type NumericalExpression.");
    6464
    6565      string result = ((CodeNode)symbol).Interpret(exprTree, exprTree.Subtrees);
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Void Methods/TurnGunRight.cs

    r13011 r13013  
    2727using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2828
    29 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode {
     29namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
    3030  [StorableClass]
    3131  public class TurnGunRight : CodeNode {
     
    6060      var symbol = exprTree.Symbol;
    6161      if (!(symbol is NumericalExpression))
    62         throw new Exception("TurnGunRight was given a child of type " + symbol.GetType() +
    63             ". The expected child must be of type " + typeof(NumericalExpression) + ".");
     62        throw new InvalidProgramException("TurnGunRight was given a child of type " + symbol.GetType() +
     63            ". The expected child must be of type NumericalExpression.");
    6464
    6565      string result = ((CodeNode)symbol).Interpret(exprTree, exprTree.Subtrees);
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Void Methods/TurnLeft.cs

    r13011 r13013  
    2727using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2828
    29 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode {
     29namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
    3030  [StorableClass]
    3131  public class TurnLeft : CodeNode {
     
    6060      var symbol = exprTree.Symbol;
    6161      if (!(symbol is NumericalExpression))
    62         throw new System.Exception("TurnLeft was given a child of type " + symbol.GetType() +
    63             ". The expected child must be of type " + typeof(NumericalExpression) + ".");
     62        throw new InvalidProgramException("TurnLeft was given a child of type " + symbol.GetType() +
     63            ". The expected child must be of type NumericalExpression.");
    6464
    6565      string result = ((CodeNode)symbol).Interpret(exprTree, exprTree.Subtrees);
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Void Methods/TurnRadarLeft.cs

    r13011 r13013  
    2727using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2828
    29 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode {
     29namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
    3030  [StorableClass]
    3131  public class TurnRadarLeft : CodeNode {
     
    6060      var symbol = exprTree.Symbol;
    6161      if (!(symbol is NumericalExpression))
    62         throw new Exception("TurnRadarLeft was given a child of type " + symbol.GetType() +
    63             ". The expected child must be of type " + typeof(NumericalExpression) + ".");
     62        throw new InvalidProgramException("TurnRadarLeft was given a child of type " + symbol.GetType() +
     63            ". The expected child must be of type NumericalExpression.");
    6464
    6565      string result = ((CodeNode)symbol).Interpret(exprTree, exprTree.Subtrees);
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Void Methods/TurnRadarRight.cs

    r13011 r13013  
    2727using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2828
    29 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode {
     29namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
    3030  [StorableClass]
    3131  public class TurnRadarRight : CodeNode {
     
    6060      var symbol = exprTree.Symbol;
    6161      if (!(symbol is NumericalExpression))
    62         throw new Exception("TurnRadarRight was given a child of type " + symbol.GetType() +
    63             ". The expected child must be of type " + typeof(NumericalExpression) + ".");
     62        throw new InvalidProgramException("TurnRadarRight was given a child of type " + symbol.GetType() +
     63            ". The expected child must be of type NumericalExpression.");
    6464
    6565      string result = ((CodeNode)symbol).Interpret(exprTree, exprTree.Subtrees);
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Void Methods/TurnRight.cs

    r13011 r13013  
    2727using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2828
    29 namespace HeuristicLab.Problems.GeneticProgramming.RoboCode {
     29namespace HeuristicLab.Problems.GeneticProgramming.Robocode {
    3030  [StorableClass]
    3131  public class TurnRight : CodeNode {
     
    6060      var symbol = exprTree.Symbol;
    6161      if (!(symbol is NumericalExpression))
    62         throw new System.Exception("TurnRight was given a child of type " + symbol.GetType() +
    63             ". The expected child must be of type " + typeof(NumericalExpression) + ".");
     62        throw new InvalidProgramException("TurnRight was given a child of type " + symbol.GetType() +
     63            ". The expected child must be of type NumericalExpression.");
    6464
    6565      string result = ((CodeNode)symbol).Interpret(exprTree, exprTree.Subtrees);
Note: See TracChangeset for help on using the changeset viewer.