protected int nextDir(final Room R)
	{
		if(lastDir < 0)
			lastDir=Directions.NORTH;
		int dir=lastDir;
		if(dir >= Directions.CODES().length)
			dir=0;
		else
			dir++;
		while(((R.getRoomInDir(dir)==null)
				||(R.getExitInDir(dir)==null)
				||(!R.getExitInDir(dir).isOpen()))
			&&(dir != lastDir))
		{
			if(dir >= Directions.CODES().length)
				dir=0;
			else
				dir++;
		}
		return dir;
	}