private void moveRandomDirection() {
        while (true) {
            int move = (int) (Math.random() * 4);
            switch (move) {
                case 0:
                    if (up()) {
                        return;
                    }
                    break;
                case 1:
                    if (down()) {
                        return;
                    }
                    break;
                case 2:
                    if (left()) {
                        return;
                    }
                    break;
                case 3:
                    if (right()) {
                        return;
                    }
                    break;
            }
        }
    }