TGM randomizer

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. It involves keeping a history of the four most recent tetrominoes and trying to choose a random tetromino not in the history. It "rolls the dice" a given number of times and takes the first tetromino that doesn't match any in the history. TGM1 uses 4 tries; subsequent games using the TGM randomizer use 6 tries.

The history is not a unique list. If the randomizer fails to generate a unique tetromino, which happens about 3.5 percent of the time in a 6-try system, then two or more of one 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.
 * The state of the history is initialized to a fixed state:
 * In TGM1, the history begins filled with 4 Z pieces.
 * In TGM2, the history begins with a Z,S,Z,S sequence.

Tetris The Grand Master Ace does not use the TGM randomizer; it uses TTC's Random Generator algorithm instead. (But TGM-ACE also never deals an S, Z or O as the first piece.)

FIELD_MESSAGE_dronsi