getBoard() confusion

I just saw that getBoard() method should return PieceType[][] array I dont understand how I can represent a board with this array, does it not matter where exactly pieces are currently positioned?

The two-dimensional array contains all relevant information of the board: Which field is occupied by what shape.

If you mean if for instance, the rotation points of the pieces matter, you can think about the following:
Screenshot_2022-06-27_21-46-21
Does it matter if the blue I piece in the fifth column had its rotation point in the second or third (180° rotated) of its rows?

Think about it, would a single PieceType array element be sufficient to represent a whole piece?
As you already noticed, the answer is no. Informations about shape, rotation, removed rows etc. would get lost.

Now think about how you can represent a piece’s body in this PieceType[][] array and why the board isn’t just a boolean array.

You are right that for basic gameplay, we only need to know whether the field is occupied or free.
But for instance, for colors, we also want the type.

1 Like