TGM randomizer

From TetrisWiki
Jump to navigation Jump to search

Most games in Arika's Tetris The Grand Master series randomize the order of tetrominoes using an algorithm that makes successive identical tetrominoes less common. The system involves keeping a history of the four most recent tetrominoes and trying to choose a random tetromino not in the history. Each time a piece is generated, the game will try a certain number of times to generate a tetromino that doesn't match any in the history; if all tries fail and generate a recent piece, the game will settle with that recent piece. The overall effect is to minimize several of the same tetromino showing up in succession, while maintaining a certain amount of unpredictability. TGM1 uses 4 tries, while later games use 6 tries.

The four-piece history is not necessarily a unique list. If the randomizer fails to generate a non-recent tetromino, which happens about 3.5 percent of the time in a 6-try system, then two or more of the same tetromino may occupy elements of the history.

A few additional behaviors exist in the beginning of the game:

  • The game never deals an S, Z or O as the first piece, to avoid a forced overhang.
  • The state of the history is initialized to a fixed state:
    • In TGM1, the history begins filled with 4 Z pieces.
    • In TGM2 (and TGM2+), the history begins with a Z,Z,S,S sequence. However, as the first piece of the game overwrites the first Z rather than pushing off the last S, this is effectively a Z,S,S,Z or Z,S,Z,S sequence.

Tetris The Grand Master Ace uses the "7-bag" Random Generator algorithm to comply with the Tetris guideline, but slightly modified so that it also never deals an S, Z or O as the first piece.

Tetris The Grand Master 3 Terror-Instinct

Unlike TGM1 and TA (P), Ti uses a bag of 35 pieces to draw from rather than drawing uniformly randomly from the seven pieces (while performing history checking). The bag initially contains 5 of each piece. However, unlike a true bag (which slowly empties with each drawn piece before being completely refilled), Ti's random generator puts a copy of the least recent piece back into the bag each time a piece is taken out. While the TGM randomizer naturally prevents "floods" (many of the same piece in a row), this additional behavior has the effect of preventing "droughts" (where a certain piece fails to show up for a long time). At an extreme, it is impossible for any piece to fail to appear for longer than a 35-piece sequence.

This is not a perfect description of Ti's randomizer; for full elaboration including some subtle bugs in the algorithm, see the reference link below.