@Override
  public int estimateCostToGoal(SearchState state) {
    short[] board = state.board.board;
    for (int y = 0; y < maxLines - 1; y++) {
      boolean beforeCave = true;
      boolean inCave = false;
      for (int x = 0; x < Board.WIDTH; x++) {
        if (isSet(board[y+1], x)) {
          if (inCave)
            return SearchAlgorithm.OO;
          beforeCave = true;
          inCave = false;
          continue;
        }
        if (isSet(board[y], x)) {
          if (beforeCave)
            inCave = true;
          beforeCave = false;
          continue;
        }
        beforeCave = false;
        inCave = false;
      }
      if (inCave)
        return SearchAlgorithm.OO;
    }
    return 0;
  }