title: Improving maze search
body: <p>I made a simple maze search algorithm that blindly runs into every direction of a cell
  to check if the goal has been found. It can find the goal, but the solution is still bad, because it doesn't terminate the other recursive calls when the goal has been found
  and it draws all the paths it has gone and not only one possible path to the goal. How could I improve that? </p>
  
  <p>The basic algorithm in pseudocode is like that: </p>
  
  <pre><code>function searchMaze(start_point, end_point, maze) {
  
   // If current point is goal I would like to abort other recursive calls
   if(start_point.equals(end_point)) {
     pathFound = true;
     drawPathInArray(); 
      return;
    }
   else {
      // if current point is not inside the array
     if(start_point_not_within_array)
     return
     else {
       // if current point is a wall or a cell that has already been visited
       if(cell_is_wall || cell_is_visited)
         return;
        else {
             // mark cell as possible path
             markCellInPathArray("#");
             setCellVisited();
             searchMaze(left_from_start_point, end_point, maze);
             searchMaze(right_from_start_point, end_point, maze);
             searchMaze(above_start_point, end_point, maze);
             searchMaze(below_start_point, end_point, maze); 
        }
     }
    }
  }
  </code></pre>