private boolean move(int d) {
        boolean changed = false;
        int in, out;
        if (d % 2 == 0) {
            out = col; in = row;
        } else {
            out = row; in = col;
        }
        int[] line = new int[in];
        for (int o = 0; o < out; o++) {
            for (int i = 0; i < in; i++) {
                int l = (d < 2) ? i : in - i - 1;
                line[i] = (d % 2 == 0) ? board[o][l] : board[l][o];
            }
            changed = merge(line) || changed;
            for (int i = 0; i < in; i++) {
                int l = (d < 2) ? i : in - i - 1;
                if (d % 2 == 0)
                    board[o][l] = line[i];
                else
                    board[l][o] = line[i];
            }
        }
        return changed;
    }