public boolean solve(Position p)
	{
		//System.out.println(p);
		maze.setVisited(p);
		
		if (maze.isEnd(p))
		{
			
			maze.setPath(p);
			moves++;
			return true;
		}
		
		else
		{
			Position u, d, l, r;
			
			u = new Position(p.x, p.y-1);
			d = new Position(p.x, p.y+1);
			l = new Position(p.x-1, p.y);
			r = new Position(p.x+1, p.y);
			
			if ( maze.isValidPos(u)  )
			{
				//System.out.println(maze);
				if (solve(u))
				{
					moves++;
					maze.setPath(p);
					return true;
				}
				//else
					//maze.setBack(u);
			}
			
			if ( maze.isValidPos(d) )
			{
				//System.out.println(maze);
				if (solve(d))
				{
					moves++;
					maze.setPath(p);
					return true;
				}
				//else
					//maze.setBack(d);
			
			}
			if (maze.isValidPos(r) )
			{
				//System.out.println(maze);
				if (solve(r))
				{
					moves++;
					maze.setPath(p);
					return true;
				}
				//else
					//maze.setBack(r);

			}
			if (maze.isValidPos(l) )
			{
				//System.out.println(maze);
				if (solve(l))
				{
					moves++;
					maze.setPath(p);
					return true;
				}
				//else
					//maze.setBack(l);
			
			}
			
			

			

		}
		
		maze.setBack(p);
		return false;
	}