private void determineInitialState(TetrisStateBuffer in) {
    Entry<Short, StateBuffer> firstEntry = in.getMap().entrySet().iterator().next();
    State firstState = firstEntry.getValue().getStates().iterator().next();

    // Determine initial Board state
    curGb.restore(firstState);
    Util.runToNextInputFrame();
    curGb.step();
    this.initialBoard = TetrisUtil.getBoard(expectedBoard.length);
    System.out.println("initial board:");
    Board.print(this.initialBoard);
    System.out.println("expected board:");
    Board.print(this.expectedBoard);

    // Determine forced pieces
    int numForcedPieces = 3;
    int[] forcedPieces = TetrisUtil.fromNextPieces(firstEntry.getKey());
    for (int i = 0; i < numForcedPieces; i++)
      if (forcedPieces[i] == 7)
        numForcedPieces = Math.min(numForcedPieces, i);
    for (short pieces : in.getMap().keySet()) {
      int[] cur = TetrisUtil.fromNextPieces(pieces);
      for (int i = 0; i < numForcedPieces; i++)
        if (cur[i] != forcedPieces[i])
          numForcedPieces = Math.min(numForcedPieces, i);
    }
    this.forcedPieces = new int[numForcedPieces];
    for (int i = 0; i < numForcedPieces; i++)
      this.forcedPieces[i] = forcedPieces[i];
    System.out.println("forced pieces: " + Arrays.toString(this.forcedPieces));
  }