MinecraftU / 2021-computer-adventures

Repository for our 2021 Computer Adventures Ruby project!
0 stars 0 forks source link

De-randomize new tetromino generation #59

Closed dealingwith closed 3 years ago

dealingwith commented 3 years ago
jamespeilunli commented 3 years ago

This r/dailyprogrammer post states:

Contrary to popular belief, the tetromino pieces you are given in a game of Tetris are not randomly selected. Instead, all seven pieces are placed into a "bag." A piece is randomly removed from the bag and presented to the player until the bag is empty. When the bag is empty, it is refilled and the process is repeated for any additional pieces that are needed. In this way, it is assured that the player will never go too long without seeing a particular piece. It is possible for the player to receive two identical pieces in a row, but never three or more. Your task for today is to implement this system.

This seems like a good way to implement "Don't let the same tetromino spawn 2x in a row".

jamespeilunli commented 3 years ago

It'll also make implementing some sort of "Next n pieces" like on tetris.com/play-tetris: image easier. (see "next" box to the right of the gameboard)