private Direction getRandomDirection() { Direction direction = Direction.any(); while (!isFree(direction)) { direction = Direction.any(); } return direction; }
private boolean isUnableToMove() { for (Direction direction : Direction.values()) { if (isFree(direction)) { return false; } } return true; }