Tetris block Representation

Source: Internet
Author: User

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.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.