Index: /branches/HeuristicLab.Problems.GPDL/CodeGenerator/BruteForceCodeGen.cs
===================================================================
--- /branches/HeuristicLab.Problems.GPDL/CodeGenerator/BruteForceCodeGen.cs	(revision 10425)
+++ /branches/HeuristicLab.Problems.GPDL/CodeGenerator/BruteForceCodeGen.cs	(revision 10426)
@@ -12,5 +12,5 @@
 
 namespace ?PROBLEMNAME? {
-  public sealed class ?IDENT?Solver {
+  public sealed class ?IDENT?BruteForceSolver {
     private static int maxDepth = 20;
 
@@ -73,11 +73,5 @@
     }
 
-    public static void Main(string[] args) {
-      if(args.Length > 0) ParseArguments(args);
-      var problem = new ?IDENT?Problem();
-      var solver = new ?IDENT?Solver(problem);
-      solver.Start();
-    }
-    private static void ParseArguments(string[] args) {
+    private void ParseArguments(string[] args) {
       var maxDepthRegex = new Regex(@""--maxDepth=(?<d>.+)"");
 
@@ -97,5 +91,5 @@
       }
     }
-    private static void PrintUsage() {
+    private void PrintUsage() {
       Console.WriteLine(""Find a solution using brute force tree search."");
       Console.WriteLine();
@@ -106,10 +100,12 @@
 
 
-    public ?IDENT?Solver(?IDENT?Problem problem) {
+
+    public ?IDENT?BruteForceSolver(?IDENT?Problem problem, string[] args) {
+      if(args.Length>1) ParseArguments(args);
       this.problem = problem;
       this.random = new Random();
     }
 
-    private void Start() {
+    public void Start() {
       var bestF = ?MAXIMIZATION? ? double.NegativeInfinity : double.PositiveInfinity;
       int n = 0;
Index: /branches/HeuristicLab.Problems.GPDL/CodeGenerator/MonteCarloTreeSearchCodeGen.cs
===================================================================
--- /branches/HeuristicLab.Problems.GPDL/CodeGenerator/MonteCarloTreeSearchCodeGen.cs	(revision 10425)
+++ /branches/HeuristicLab.Problems.GPDL/CodeGenerator/MonteCarloTreeSearchCodeGen.cs	(revision 10426)
@@ -17,8 +17,9 @@
     public bool done;
     public SearchTreeNode[] children;
+    // only for debugging
     public double[] Ucb {
       get {
         return (from c in children
-                select ?IDENT?Solver.UCB(this, c)
+                select ?IDENT?MonteCarloTreeSearchSolver.UCB(this, c)
                ).ToArray();
       }
@@ -28,5 +29,6 @@
   }
 
-  public sealed class ?IDENT?Solver {
+  public sealed class ?IDENT?MonteCarloTreeSearchSolver {
+    private int maxDepth = 20;
 
     private readonly ?IDENT?Problem problem;
@@ -34,13 +36,13 @@
     private SearchTreeNode searchTree = new SearchTreeNode();
    
-    private Tree SampleTree() {
-      var extensionsStack = new Stack<Tuple<Tree, int, int>>(); // the unfinished tree, the state, and the index of the extension point
+    private Tree SampleTree(int maxDepth) {
+      var extensionsStack = new Stack<Tuple<Tree, int, int, int>>(); // the unfinished tree, the state, the index of the extension point and the maximal depth of a tree inserted at that point
       var t = new Tree(-1, new Tree[1]);
-      extensionsStack.Push(Tuple.Create(t, 0, 0));
+      extensionsStack.Push(Tuple.Create(t, 0, 0, maxDepth));
       SampleTree(searchTree, extensionsStack);
       return t.subtrees[0];
     }
 
-    private void SampleTree(SearchTreeNode searchTree, Stack<Tuple<Tree, int, int>> extensionPoints) {
+    private void SampleTree(SearchTreeNode searchTree, Stack<Tuple<Tree, int, int, int>> extensionPoints) {
       const int RANDOM_TRIES = 1000;
       if(extensionPoints.Count == 0) {
@@ -52,4 +54,6 @@
       int state = extensionPoint.Item2;
       int subtreeIdx = extensionPoint.Item3;
+      int maxDepth = extensionPoint.Item4;
+      Debug.Assert(maxDepth >= 1);
       Tree t = null;
       if(searchTree.tries < RANDOM_TRIES || Grammar.subtreeCount[state] == 0) {
@@ -81,5 +85,5 @@
           var altIdx = SelectAlternative(searchTree);
           t = new Tree(altIdx, new Tree[1]);
-          extensionPoints.Push(Tuple.Create(t, Grammar.transition[state][altIdx], 0));
+          extensionPoints.Push(Tuple.Create(t, Grammar.transition[state][altIdx], 0, maxDepth - 1));
           SampleTree(searchTree.children[altIdx], extensionPoints);
         } else {
@@ -88,5 +92,5 @@
           t = new Tree(-1, subtrees);
           for(int i = subtrees.Length - 1; i >= 0; i--) {
-            extensionPoints.Push(Tuple.Create(t, Grammar.transition[state][i], i));
+            extensionPoints.Push(Tuple.Create(t, Grammar.transition[state][i], i, maxDepth - 1));
           }
           SampleTree(searchTree, extensionPoints);          
@@ -215,19 +219,11 @@
     }
 
-
-    public static void Main(string[] args) {
-      // if(args.Length >= 1) ParseArguments(args);
-
-      var problem = new ?IDENT?Problem();
-      var solver = new ?IDENT?Solver(problem);
-      solver.Start();
-    }
-
-    public ?IDENT?Solver(?IDENT?Problem problem) {
+    public ?IDENT?MonteCarloTreeSearchSolver(?IDENT?Problem problem, string[] args) {
+      if(args.Length > 0 ) throw new ArgumentException(""Arguments ""+args.Aggregate("""", (str, s) => str+ "" "" + s)+"" are not supported "");
       this.problem = problem;
       this.random = new Random();
     }
 
-    private void Start() {
+    public void Start() {
       Console.ReadLine();
       var bestF = ?MAXIMIZATION? ? double.NegativeInfinity : double.PositiveInfinity;
@@ -241,5 +237,5 @@
 
         int steps, depth;
-        var _t = SampleTree();
+        var _t = SampleTree(maxDepth);
         //  _t.PrintTree(0); Console.WriteLine();
 
@@ -247,4 +243,5 @@
         steps = _t.GetSize();
         depth = _t.GetDepth();
+        Debug.Assert(depth <= maxDepth);
         var f = problem.Evaluate(_t);
         if(?MAXIMIZATION?)
Index: /branches/HeuristicLab.Problems.GPDL/CodeGenerator/ProblemCodeGen.cs
===================================================================
--- /branches/HeuristicLab.Problems.GPDL/CodeGenerator/ProblemCodeGen.cs	(revision 10425)
+++ /branches/HeuristicLab.Problems.GPDL/CodeGenerator/ProblemCodeGen.cs	(revision 10426)
@@ -1,3 +1,4 @@
-﻿using System.Collections.Generic;
+﻿using System;
+using System.Collections.Generic;
 using System.Diagnostics;
 using System.IO;
@@ -19,5 +20,14 @@
     private const string problemTemplate = @"
 namespace ?PROBLEMNAME? {
+
+
+
+
   public sealed class ?IDENT?Problem {
+    public static void Main(string[] args) {
+      var problem = new ?IDENT?Problem();
+      var solver = new ?IDENT?RandomSearchSolver(problem, args);
+      solver.Start();
+    }
    
    public ?IDENT?Problem() { 
@@ -153,10 +163,27 @@
     private void GenerateSolvers(GPDefNode ast, SourceBuilder solverSourceCode) {
       var grammar = CreateGrammarFromAst(ast);
-      // var randomSearchCodeGen = new RandomSearchCodeGen();
-      // randomSearchCodeGen.Generate(grammar, ast.Terminals.OfType<TerminalNode>(), ast.FitnessFunctionNode.Maximization, solverSourceCode);
-      var bruteForceSearchCodeGen = new BruteForceCodeGen();
-      bruteForceSearchCodeGen.Generate(grammar, ast.Terminals.OfType<TerminalNode>(), ast.FitnessFunctionNode.Maximization, solverSourceCode);
-      // var mctsCodeGen = new MonteCarloTreeSearchCodeGen();
-      // mctsCodeGen.Generate(grammar, ast.Terminals.OfType<TerminalNode>(), ast.FitnessFunctionNode.Maximization, solverSourceCode);
+      try {
+        var randomSearchCodeGen = new RandomSearchCodeGen();
+        randomSearchCodeGen.Generate(grammar, ast.Terminals.OfType<TerminalNode>(), ast.FitnessFunctionNode.Maximization,
+                                     solverSourceCode);
+      }
+      catch (Exception e) {
+        Console.WriteLine(e.Message);
+      }
+      try {
+        var bruteForceSearchCodeGen = new BruteForceCodeGen();
+        bruteForceSearchCodeGen.Generate(grammar, ast.Terminals.OfType<TerminalNode>(), ast.FitnessFunctionNode.Maximization, solverSourceCode);
+      }
+      catch (Exception e) {
+        Console.WriteLine(e.Message);
+      }
+      try {
+        var mctsCodeGen = new MonteCarloTreeSearchCodeGen();
+        mctsCodeGen.Generate(grammar, ast.Terminals.OfType<TerminalNode>(), ast.FitnessFunctionNode.Maximization,
+                             solverSourceCode);
+      }
+      catch (Exception e) {
+        Console.WriteLine(e.Message);
+      }
     }
 
Index: /branches/HeuristicLab.Problems.GPDL/CodeGenerator/RandomSearchCodeGen.cs
===================================================================
--- /branches/HeuristicLab.Problems.GPDL/CodeGenerator/RandomSearchCodeGen.cs	(revision 10425)
+++ /branches/HeuristicLab.Problems.GPDL/CodeGenerator/RandomSearchCodeGen.cs	(revision 10426)
@@ -11,7 +11,7 @@
     private string solverTemplate = @"
 namespace ?PROBLEMNAME? {
-  public sealed class ?IDENT?Solver {
-    private static double baseTerminalProbability = 0.05; // 5% of all samples are only a terminal node
-    private static double terminalProbabilityInc = 0.05; // for each level the probability to sample a terminal grows by 5%
+  public sealed class ?IDENT?RandomSearchSolver {
+    private double baseTerminalProbability = 0.05; // 5% of all samples are only a terminal node
+    private double terminalProbabilityInc = 0.05; // for each level the probability to sample a terminal grows by 5%
     private static int maxDepth = 20;
 
@@ -77,12 +77,5 @@
     }
 
-    public static void Main(string[] args) {
-      if(args.Length >= 1) ParseArguments(args);
-
-      var problem = new ?IDENT?Problem();
-      var solver = new ?IDENT?Solver(problem);
-      solver.Start();
-    }
-    private static void ParseArguments(string[] args) {
+    private void ParseArguments(string[] args) {
       var baseTerminalProbabilityRegex = new Regex(@""--terminalProbBase=(?<prob>.+)"");
       var terminalProbabilityIncRegex = new Regex(@""--terminalProbInc=(?<prob>.+)"");
@@ -111,5 +104,5 @@
       }
     }
-    private static void PrintUsage() {
+    private void PrintUsage() {
       Console.WriteLine(""Find a solution using random tree search."");
       Console.WriteLine();
@@ -121,10 +114,12 @@
 
 
-    public ?IDENT?Solver(?IDENT?Problem problem) {
+    public ?IDENT?RandomSearchSolver(?IDENT?Problem problem, string[] args) {
+      if(args.Length >= 1) ParseArguments(args);
+
       this.problem = problem;
       this.random = new Random();
     }
 
-    private void Start() {
+    public void Start() {
       var bestF = ?MAXIMIZATION? ? double.NegativeInfinity : double.PositiveInfinity;
       int n = 0;
