Block Representation
One has seven types of building blocks:
■
■
■ (Both positive and negative)
■
■
■
■
■
■
■
■
■
■
■
■
■
■ (19 blocks in total)
■
A three-dimensional array block [4] [4] [4] [4] can be used to represent each building block. The first dimension is used to represent the four rotation states of the building blocks, the last two dimensions use a 4x4 0/1 digital array to represent the shapes of these products, such:
{
{
{0, 0, 1, 0 },
{0, 0, 1, 0 },
{0, 1, 1, 0 },
{0, 0, 0, 0}
},
{
{0, 0, 0, 0 },
{0, 1, 0, 0 },
{0, 1, 1, 1 },
{0, 0, 0, 0}
},
{
{0, 0, 0, 0 },
{0, 1, 1, 0 },
{0, 1, 0, 0 },
{0, 1, 0, 0}
},
{
{0, 0, 0, 0 },
{1, 1, 1, 0 },
{0, 0, 1, 0 },
{0, 0, 0, 0}
}
} // This is an L-shaped building block
The one-and Z-shaped tianzi building blocks are also made in four states, but the state is repetitive, so different rotation methods are not required for different building blocks.
Deformation of building blocks
The building block deformation is very good, that is, reading the rotation status in the equivalent building block matrix cyclically
For example, if the current block type is block [4] [4] and the array of the T-shaped block type is block2 [4] [4] [4], the rotation is to convert block2 [0], block [1], block [2], block [3]… -> Block [0] is repeatedly assigned to the block array. The current rotation value (that is, the index of the array, range: {0, 1, 2, 3}) plus one. If it is equal to 4, it is returned to 0 again.