title: 8 puzzle iterative deep search implementation
body: <p>I have implemented a depth first search (recursive) for the 8 puzzle problem in Java:</p>
  
  <pre><code>protected PuzzleState depthFirstSearch(PuzzleState state) {
          PuzzleState start = this.getStartState(); 
          PuzzleState goal = this.getGoalState(); 
          PuzzleState stop = null;
  
          int limit = 35;
          int depth = state.getDepth();
          boolean tooDeep = false;
  
          if (state.equals(goal)) {
              return state;
          } else {
              if (depth == limit) {
                  return stop;
              } else {
                  Collection&lt;Integer&gt; actions = PuzzleAction.getPuzzleActions();
                  for (Integer action : actions) {
                      PuzzleState starter = start;
                      PuzzleState next = state.succ(action);
  
                      if (next != null) {
                          starter = depthFirstSearch(next);
                      }
                      if (starter == stop) {
                          tooDeep = true;
                      } else {
                          if (!starter.equals(start)) {
                              return starter;
                          }
                      }
                  }
              }
          }
          if (tooDeep)
              return stop;
          else
              return start;
      }
  </code></pre>
  
  <p>I don't know what I have to change to transform it to a iterative deepening depth search. I know that there is no limit for the depth, because it increases in every round.
  Tried this:</p>
  
  <pre><code>protected PuzzleState iterativeDeepSearch(PuzzleState state) {
          int depth = state.getDepth();
          for(int limit = 1; limit &lt; depth; limit ++){
              depthFirstSearch(state, limit);
          }
  }
  </code></pre>
  
  <p>Does anyone know how to change it to the needed IDS? 
  Thank you in advance!</p>