protected void expandChildren(SearchState oldState, int oldDist) {

    HashMap<Integer, HashMap<Board, ListStateBuffer>> cache = new HashMap<>();

    TetrisStateBuffer buf = stateBufferMap.get(oldState);
    for (Entry<Short, StateBuffer> stateEntry : buf.getMap().entrySet()) {
      int pieceIndex = stateEntry.getKey() & 0b111;
      if (!cache.containsKey(pieceIndex)) {
        System.out.println("Expand with piece " + Piece.PIECE_NAMES[pieceIndex]);
        SBLockPiece lockPiece = new SBLockPiece(oldState.board.board, pieceIndex, initialDropDelay, veryFirstPiece ? LockPiece.ZERO_DROP_DELAY : initialDropDelay, stateEntry.getValue());
        cache.put(pieceIndex, lockPiece.lockPiece());
      }
      HashMap<Board, ListStateBuffer> locks = cache.get(pieceIndex);
      for (Entry<Board, ListStateBuffer> e : locks.entrySet()) {
        Board board = e.getKey();
        int clearedLines = board.clearLines();
        int newRowsToGo = oldState.rowsToGo - clearedLines;
        if (newRowsToGo != oldState.rowsToGo && (newRowsToGo+3) / 4 == (oldState.rowsToGo+3) / 4)
          continue;
        SearchState newState = new SearchState(board, oldState.numDroppedPieces + 1, newRowsToGo, oldState, pieceIndex);
        addState(newState, e.getValue(), stateEntry.getValue(), clearedLines > 0);
      }
    }
  }