private boolean isValidLocation(int tileId) {
        int x = tileId % size_x;
        int y = tileId / size_y;

        if (x < 0 || x >= size_x) {
            return false;
        } else if (y < 0 || y >= size_y) {
            return false;
        } else if (y == size_y - 1 && x % 2 == 1) {
            return false;
        } else if (tiles[tileId] != null) {
            return false;
        } else {
            return true;
        }
    }