title: How can I find the shortest path in a maze?
body: <p>My maze is a int array with two dimensions, <code>int maze[][]</code> containing <code>0,1,START(2),GOAL(3)</code>. I want to print the shortest path.</p>
  
  <p>I have a function but it doesn't display the shortest path but one path to the end:</p>
  
  <pre><code>bool RenderThread::find_path(int x, int y)
  {
      int maze_size=mmaze-&gt;size*2;
  
      if ( x &lt; 0 || x &gt; maze_size  || y &lt; 0 || y &gt; maze_size  ) return FALSE;
  
      if ( toSolve1-&gt;maze_data[y][x] == G ) return TRUE;
  
      if ( toSolve1-&gt;maze_data[y][x] != PATH &amp;&amp; toSolve1-&gt;maze_data[y][x] != S ) return FALSE;
  
      toSolve1-&gt;setRed(y,x);
  
  
      if ( find_path(x, y - 1) == TRUE ) return TRUE;
  
      if ( find_path(x + 1, y) == TRUE ) return TRUE;
  
      if ( find_path(x, y + 1) == TRUE ) return TRUE;
  
      if ( find_path(x - 1, y) == TRUE ) return TRUE;
  
      toSolve1-&gt;setPath(y,x);
  
      return FALSE;
  }
  </code></pre>