| | | | | |

Solving a Maze Object - DFS Version

    bool solve ()
    {
      clear conStack;
      unset visited flags in all maze cells;
      set visited flag for start cell;
      push start onto conStack;
      while (conStack is not empty)
      {
        if (top cell has unvisited neighbor N)
        {
          set N's visited flag;
          push address of N onto the conStack;
          if N is the goal cell, return true; // note early return
        }
        pop the conStack;
      }
      return false;
    }
    

| | Top of Page | 6A. Chalktalk: The Rat and Maze Specification - 11 of 12