private boolean isBlocked(int x, int y, int i, int j) {
        int delta[] = {x, y};
        int next[]  = {i, j};
        int block[] = new int[2];

        int k;

        for(k = 0; k < 2; k++) {
            delta[k] -= next[k];

            block[k] = next[k]-delta[k];
        }

        // it is blocked if it is out of bound
        if((block[0] < 0 || block[0] >= X) ||
           (block[1] < 0 || block[1] >= Y)) {
            return true;
        } else if(state[block[0]][block[1]] != BL)
            return true;

        return false;
    }