public static Tile nearestOpenTile(Monster movingMonster, char direction){
		
		char left=direction;
		char right=direction;
		while(!canMove(movingMonster, direction)){
			switch(randGenerator.nextInt(2)){		//at random, choose one of two actions:
			case(0):		//action 1: try moving left. otherwise, move right.
				left=leftOf(left);
				if(canMove(movingMonster, left))
					return tileInDirection(movingMonster, left);
				else{
					right=rightOf(right);
					if(canMove(movingMonster, right))
						return tileInDirection(movingMonster, right);
				}
			case(1):
				right=rightOf(right);
				if(canMove(movingMonster, right))
					return tileInDirection(movingMonster, right);
				else{
					left=leftOf(left);
					if(canMove(movingMonster, left))
						return tileInDirection(movingMonster, left);
				}
				if(left==direction||right==direction)	//this indicates a full cirlce, meaning the monster is surrounded and cannot move.
					return movingMonster.currentTile;
			}
		}
		return tileInDirection(movingMonster, direction);
	}