Robot Mouse in Java


public static Cons
  mouse (String[][] maze, int x, int y, Cons prev){
  Cons path;
  if ( maze[y][x].equals("*") ) return null;
  Cons here = list(new Integer(x),new Integer(y));
  if ( memberv(here, prev) != null ) return null;
  else if ( maze[y][x].equals("C") )
      return list("C");
    else if ((path = mouse(maze, x - 1, y,
                           cons(here,prev)))
             != null )
        return cons("W", path);
      else if ((path = mouse(maze, x, y - 1,
                             cons(here,prev)))
               != null )
          return cons("N", path);
        else if ((path = mouse(maze, x + 1, y,
                               cons(here,prev)))
                 != null )
            return cons("E", path);
          else if ((path = mouse(maze, x, y + 1,
                                 cons(here,prev)))
                   != null )
              return cons("S", path);
            else return null; }

Contents    Page-10    Prev    Next    Page+10    Index