@Test public void testFindLeastSquaresLeft() throws Exception { Assert.assertEquals(2, board.calculateLandingHeight(Tetromino.S, 0, 0)); Assert.assertEquals(3, board.calculateLandingHeight(Tetromino.S, 0, 1)); Assert.assertEquals(2, board.calculateLandingHeight(Tetromino.Z, 0, 0)); Assert.assertEquals(3, board.calculateLandingHeight(Tetromino.Z, 0, 1)); }
int calculateLandingHeight(Tetromino tetromino, int position, int rotation) { int highestColumn = Integer.MIN_VALUE; int[] bottomTiles = tetromino.getBottomTiles(rotation); for (int col = 0; col < bottomTiles.length; col++) { int height = skyline[position + col] + bottomTiles[col]; highestColumn = Math.max(highestColumn, height); } return highestColumn; }
TetrisBoard implements Board { int calculateLandingHeight(Tetromino tetromino, int position, int rotation) { int highestColumn = Integer.MIN_VALUE; int[] bottomTiles = tetromino.getBottomTiles(rotation); for (int col = 0; col < bottomTiles.length; col++) { int height = skyline[position + col] + bottomTiles[col]; highestColumn = Math.max(highestColumn, height); } return highestColumn; } }
TetrisBoard implements Board { int calculateLandingHeight(Tetromino tetromino, int position, int rotation) { int highestColumn = Integer.MIN_VALUE; int[] bottomTiles = tetromino.getBottomTiles(rotation); for (int col = 0; col < bottomTiles.length; col++) { int height = skyline[position + col] + bottomTiles[col]; highestColumn = Math.max(highestColumn, height); } return highestColumn; } TetrisBoard(); private  TetrisBoard(TetrisBoard board); }
TetrisBoard implements Board { int calculateLandingHeight(Tetromino tetromino, int position, int rotation) { int highestColumn = Integer.MIN_VALUE; int[] bottomTiles = tetromino.getBottomTiles(rotation); for (int col = 0; col < bottomTiles.length; col++) { int height = skyline[position + col] + bottomTiles[col]; highestColumn = Math.max(highestColumn, height); } return highestColumn; } TetrisBoard(); private  TetrisBoard(TetrisBoard board); RectSize getSize(); int getMaxColumnHeight(); int[] getSkyline(); boolean isHeightExceeded(); @Override int getWidth(); @Override int getHeight(); @Override int getValue(int row, int col); @Override void setValue(int row, int col, int color); @Override int getValue(int pos); @Override void setValue(int pos, int color); @Override void invert(); @Override Board createAfterState(int row, int col, int player); @Override TetrisBoard clone(); IntArrayList placeTetromino(Tetromino tetromino, int column, int rotation); IntArrayList placeTetrominoCustom(Tetromino tetromino, int column, int rotation, int piece); Pair<IntArrayList, Integer> simulatePlaceTetrominoNaive(Tetromino tetromino, int column, int rotation); SimulationResult simulatePlaceTetromino(Tetromino tetromino, int column, int rotation); IntSortedSet eraseCompleteLines(IntArrayList changedPositions); @Override String toString(); @Override boolean equals(Object obj); @Override int hashCode(); int getHolesCount(); }
TetrisBoard implements Board { int calculateLandingHeight(Tetromino tetromino, int position, int rotation) { int highestColumn = Integer.MIN_VALUE; int[] bottomTiles = tetromino.getBottomTiles(rotation); for (int col = 0; col < bottomTiles.length; col++) { int height = skyline[position + col] + bottomTiles[col]; highestColumn = Math.max(highestColumn, height); } return highestColumn; } TetrisBoard(); private  TetrisBoard(TetrisBoard board); RectSize getSize(); int getMaxColumnHeight(); int[] getSkyline(); boolean isHeightExceeded(); @Override int getWidth(); @Override int getHeight(); @Override int getValue(int row, int col); @Override void setValue(int row, int col, int color); @Override int getValue(int pos); @Override void setValue(int pos, int color); @Override void invert(); @Override Board createAfterState(int row, int col, int player); @Override TetrisBoard clone(); IntArrayList placeTetromino(Tetromino tetromino, int column, int rotation); IntArrayList placeTetrominoCustom(Tetromino tetromino, int column, int rotation, int piece); Pair<IntArrayList, Integer> simulatePlaceTetrominoNaive(Tetromino tetromino, int column, int rotation); SimulationResult simulatePlaceTetromino(Tetromino tetromino, int column, int rotation); IntSortedSet eraseCompleteLines(IntArrayList changedPositions); @Override String toString(); @Override boolean equals(Object obj); @Override int hashCode(); int getHolesCount(); static final int EMPTY; static final int PIECE; static final int NUM_VALUES; static final int MARGIN_WIDTH; static final int BOARD_WIDTH; static final int BOARD_HEIGHT; static final int WIDTH; static final int HEIGHT; static final RectSize DEFAULT_BOARD_SIZE; }