ghostPiece method
Returns the lowest valid Y the piece can drop to (for ghost piece).
Implementation
Tetromino ghostPiece(Tetromino piece, BoardState board) {
var ghost = piece;
while (true) {
final dropped = ghost.copyWith(
position: Position(ghost.position.row + 1, ghost.position.col),
);
if (hasCollision(dropped, board)) return ghost;
ghost = dropped;
}
}