title: solve maze by right hand principle
body: <p></p>
  
  <p>hello there<br>
  i am solving a text book exercise to solve a maze by right hand principle<br></p>
  
  <p>i use switch case to deal it<br></p>
  
  <p></p>
  
  <pre class="lang-html prettyprint-override"><code>switch ( face )
  {
      case face_EAST:
      {
          if( map[x][y + 1] == '.' &amp;&amp; map[x + 1][y] == '#' )
          {
              y = y + 1;
              gotoxy(x, y);
              face = face_EAST;
          }
          else if ( map[x - 1][y] == '.' &amp;&amp; map[x][y + 1] == '#' )
          {
              x = x - 1;
              gotoxy( x, y );
              face = face_NORTH;
          }
          else if ( map[x + 1][y] == '.' &amp;&amp; map[x + 1][y - 1] == '#' )
          {
              x = x + 1;
              gotoxy( x, y );
              face = face_SOUTH;
          }
          else
              face = face_SOUTH;
  
          break;
      }
      case face_SOUTH :
      {
          if( map[x + 1][y] == '.' &amp;&amp; map[x][y - 1] == '#' )
          {
              x = x + 1;
              gotoxy( x, y );
              face = face_SOUTH;
          }
          else if( map[x][y - 1] == '.' &amp;&amp; map[x - 1][y - 1] == '#' )
          {
              y = y - 1;
              gotoxy( x, y );
              face = face_WEST;
          }
          else if( map[x][y + 1] == '.' &amp;&amp; map[x + 1][y] == '#' )
          {
              y = y + 1;
              gotoxy( x, y );
              face = face_EAST;
          }
          else
              face = face_WEST;
          break;
      }
      case face_WEST:
      {
          if( map[x][y - 1] == '.' &amp;&amp; map[x - 1][y] == '#' )
          {
              y = y - 1;
              gotoxy( x, y );
              face = face_WEST;
          }
          else if( map[x - 1][y] == '.' &amp;&amp; map[x - 1][y + 1] == '#' )
          {
              x = x - 1;
              gotoxy( x, y );
              face = face_NORTH;
          }
          else if( map[x + 1][y] == '.' &amp;&amp; map[x][y - 1] == '#' )
          {
              x = x + 1;
              gotoxy( x, y );
              face = face_SOUTH;
          }
          else if( map[x][y + 1] == '.' &amp;&amp; map[x + 1][y] == '#' )
          {
              y = y + 1;
              gotoxy( x, y );
              face = face_EAST;
          }
          else if( map[x - 1][y] == '.' &amp;&amp; map[x - 1][y + 1] == '#' )
          {
              x = x - 1;
              gotoxy( x, y );
              face = face_NORTH;
          }
          else
              face = face_NORTH;
  
          break;
      }
      case face_NORTH:
      {
          if( map[x - 1][y] == '.' &amp;&amp; map[x][y + 1] == '#' )
          {
              x = x - 1;
              gotoxy( x, y );
              face = face_NORTH;
          }
          else if( map[x][y - 1] == '.' &amp;&amp; map[x - 1][y] == '#' )
          {
              y = y - 1;
              gotoxy( x, y );
              face = face_WEST;
          }
          else if( map[x][y + 1] == '.' &amp;&amp; map[x + 1][y + 1] == '#' )
          {
              y = y + 1;
              gotoxy( x, y );
              face = face_EAST;
          }
          else
              face = face_EAST;
  
          break;
      }
  }
  </code></pre>
  
  <p>i want to know if there any more easy way to make right hand principle work?<br>
  i have though to change the coordinate system, but can't implement it <br></p>