Index: branches/MCTS-SymbReg-2796/HeuristicLab.Algorithms.DataAnalysis/3.4/MctsSymbolicRegression/ExprHash.cs
===================================================================
--- branches/MCTS-SymbReg-2796/HeuristicLab.Algorithms.DataAnalysis/3.4/MctsSymbolicRegression/ExprHash.cs	(revision 15438)
+++ branches/MCTS-SymbReg-2796/HeuristicLab.Algorithms.DataAnalysis/3.4/MctsSymbolicRegression/ExprHash.cs	(revision 15439)
@@ -145,4 +145,5 @@
             Contract.Assert(topOfStack == 0);
             return stack[topOfStack].Sum();
+          default: throw new InvalidOperationException();
         }
       }
Index: branches/MCTS-SymbReg-2796/HeuristicLab.Algorithms.DataAnalysis/3.4/MctsSymbolicRegression/MctsSymbolicRegressionAlgorithm.cs
===================================================================
--- branches/MCTS-SymbReg-2796/HeuristicLab.Algorithms.DataAnalysis/3.4/MctsSymbolicRegression/MctsSymbolicRegressionAlgorithm.cs	(revision 15438)
+++ branches/MCTS-SymbReg-2796/HeuristicLab.Algorithms.DataAnalysis/3.4/MctsSymbolicRegression/MctsSymbolicRegressionAlgorithm.cs	(revision 15439)
@@ -74,5 +74,5 @@
     public IFixedValueParameter<IntValue> ConstantOptimizationIterationsParameter {
       get { return (IFixedValueParameter<IntValue>)Parameters[ConstantOptimizationIterationsParameterName]; }
-    }                  
+    }
     public IFixedValueParameter<DoubleValue> PunishmentFactorParameter {
       get { return (IFixedValueParameter<DoubleValue>)Parameters[PunishmentFactorParameterName]; }
@@ -260,5 +260,5 @@
       var problemData = (IRegressionProblemData)Problem.ProblemData.Clone();
       if (!AllowedFactors.CheckedItems.Any()) throw new ArgumentException("At least on type of factor must be allowed");
-      var state = MctsSymbolicRegressionStatic.CreateState(problemData, (uint)Seed, MaxVariableReferences, ScaleVariables, 
+      var state = MctsSymbolicRegressionStatic.CreateState(problemData, (uint)Seed, MaxVariableReferences, ScaleVariables,
         ConstantOptimizationIterations, Lambda,
         collectPareto,
@@ -291,5 +291,5 @@
           if (bestQ > bestQuality.Value) {
             bestSolutionIteration.Value = i;
-            if (state.BestSolutionTrainingQuality > 0.99999) break; 
+            if (state.BestSolutionTrainingQuality > 0.99999) break;
           }
           bestQuality.Value = bestQ;
@@ -317,5 +317,5 @@
 
       // final results (assumes that at least one iteration was calculated)
-      if (n > 0) {        
+      if (n > 0) {
         if (bestQ > bestQuality.Value) {
           bestSolutionIteration.Value = iterations.Value + n;
Index: branches/MCTS-SymbReg-2796/HeuristicLab.Algorithms.DataAnalysis/3.4/MctsSymbolicRegression/MctsSymbolicRegressionStatic.cs
===================================================================
--- branches/MCTS-SymbReg-2796/HeuristicLab.Algorithms.DataAnalysis/3.4/MctsSymbolicRegression/MctsSymbolicRegressionStatic.cs	(revision 15438)
+++ branches/MCTS-SymbReg-2796/HeuristicLab.Algorithms.DataAnalysis/3.4/MctsSymbolicRegression/MctsSymbolicRegressionStatic.cs	(revision 15439)
@@ -23,5 +23,4 @@
 using System.Collections.Generic;
 using System.Diagnostics;
-using System.Diagnostics.Contracts;
 using System.Linq;
 using System.Text;
@@ -61,4 +60,5 @@
     //       --> TODO: Which heuristics can we apply? 
     // TODO: Solve Poly-10
+    // TODO: rename everything as this is not MCTS anymore
     // TODO: After state unification the recursive backpropagation of results takes a lot of time. How can this be improved?
     // ~~obsolete TODO: Why is the algorithm so slow for rather greedy policies (e.g. low C value in UCB)?
@@ -247,4 +247,18 @@
       #endregion
 
+
+#if DEBUG
+      public string ExprStr(Automaton automaton) {
+        byte[] code;
+        int nParams;
+        automaton.GetCode(out code, out nParams);
+        var generator = new SymbolicExpressionTreeGenerator(problemData.AllowedInputVariables.ToArray());
+        var @params = Enumerable.Repeat(1.0, nParams).ToArray();
+        var root = generator.Exec(code, @params, nParams, null, null);
+        var formatter = new InfixExpressionFormatter();
+        return formatter.Format(new SymbolicExpressionTree(root));
+      }
+#endif
+
       private double Eval(byte[] code, int nParams) {
         double[] optConsts;
@@ -501,14 +515,17 @@
         mctsState.totalRollouts++;
       } while (!success && !tree.Done);
-      mctsState.effectiveRollouts++;
+      if (success) {
+        mctsState.effectiveRollouts++;
 
 #if DEBUG
-      Console.WriteLine(ExprStr(automaton));
+        Console.WriteLine(mctsState.ExprStr(automaton));
 #endif
-      return q;
+
+        return q;
+      } else return 0.0;
     }
 
     // search forward
-    private static bool TryTreeSearchRec2(IRandom rand, Tree tree, Automaton automaton, 
+    private static bool TryTreeSearchRec2(IRandom rand, Tree tree, Automaton automaton,
       Func<byte[], int, double> eval,
       State state,
@@ -529,5 +546,5 @@
 
       while (!automaton.IsFinalState(automaton.CurrentState)) {
-        Console.WriteLine(automaton.stateNames[automaton.CurrentState]);
+        // Console.WriteLine(automaton.stateNames[automaton.CurrentState]);
         if (state.children.ContainsKey(tree)) {
           if (state.children[tree].All(ch => ch.Done)) {
@@ -570,5 +587,5 @@
             // for selected states (EvalStates) we introduce state unification (detection of equivalent states)
             if (automaton.IsEvalState(possibleFollowStates[i])) {
-              var hc = Hashcode(automaton); // TODO fix unit test for structure enumeration
+              var hc = Hashcode(automaton) * (ulong)tree.state; // TODO fix unit test for structure enumeration
               if (!state.nodes.TryGetValue(hc, out child)) {
                 child = new Tree() {
@@ -623,12 +640,12 @@
 
       // EVALUATE TREE
-      if (automaton.IsFinalState(automaton.CurrentState)) {
+      if (!tree.Done && automaton.IsFinalState(automaton.CurrentState)) {
         tree.Done = true;
-        tree.expr = ExprStr(automaton);
+        tree.expr = state.ExprStr(automaton);
         byte[] code; int nParams;
         automaton.GetCode(out code, out nParams);
         q = eval(code, nParams);
         success = true;
-        BackpropagateQuality(tree, q, state); 
+        BackpropagateQuality(tree, q, state);
       } else {
         // we got stuck in roll-out (not evaluation necessary!)
@@ -652,5 +669,5 @@
 
       var idx = rand.Next(list.Count);
-      while(list[idx].Done) { idx = rand.Next(list.Count); }
+      while (list[idx].Done) { idx = rand.Next(list.Count); }
       return idx;
     }
@@ -717,5 +734,5 @@
       }
       return children[selectedChildIdx];
-    }                                            
+    }
 
     // scales data and extracts values from dataset into arrays
@@ -778,11 +795,4 @@
     // for debugging only
 
-
-    private static string ExprStr(Automaton automaton) {
-      byte[] code;
-      int nParams;
-      automaton.GetCode(out code, out nParams);
-      return Disassembler.CodeToString(code);
-    }
 
     private static string TraceTree(Tree tree, State state) {
Index: branches/MCTS-SymbReg-2796/Tests/HeuristicLab.Algorithms.DataAnalysis-3.4/MctsSymbolicRegressionTest.cs
===================================================================
--- branches/MCTS-SymbReg-2796/Tests/HeuristicLab.Algorithms.DataAnalysis-3.4/MctsSymbolicRegressionTest.cs	(revision 15438)
+++ branches/MCTS-SymbReg-2796/Tests/HeuristicLab.Algorithms.DataAnalysis-3.4/MctsSymbolicRegressionTest.cs	(revision 15439)
@@ -1485,5 +1485,5 @@
 
       Console.WriteLine(mctsSymbReg.ExecutionTime);
-      Assert.AreEqual(expectedNumberOfSolutions, ((IntValue)mctsSymbReg.Results["Iterations"].Value).Value);
+      Assert.AreEqual(expectedNumberOfSolutions, ((IntValue)mctsSymbReg.Results["Effective rollouts"].Value).Value);
     }
 
