title: Algorithm for traversing a maze
body: <p>I need some help in writing a set of if-then rules for traversing a maze. This is the problem:</p>
  
  <p>"Assume that the maze is constructed on a grid of square cells by placing walls across some of the edges of cells in such a way that there is a path from any cell within the maze to an outer edge of the maze that has no wall.</p>
  
  <p>One way is left-hand rule, but this strategy can take you around in cycles.</p>
  
  <p>Write if-then rules in English for traversing the wall and detecting a cycle. Assume you know size of grid and max distance you may have to travel to escape the maze."</p>
  
  <p>This is what I have so far:</p>
  
  <ol>
  <li><p>Start</p></li>
  <li><p>If only one path (Left or Right or Straight) is found, follow the path.</p></li>
  <li><p>Else If Multiple path is found:</p>
  
  <p>If left path is found, take a left turn. </p>
  
  <p>Else if straight path is found, follow straight path. </p>
  
  <p>Else if right path is found, take a right turn. </p></li>
  <li><p>Else If Dead End is found, take a 'U' turn. </p>
  
  <p>Go To step 2</p></li>
  <li><p>End</p></li>
  </ol>
  
  <p>But this is not solving the cycle problem. Can anyone help please?</p>