TGM randomizer: Difference between revisions

From TetrisWiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(19 intermediate revisions by 12 users not shown)
Line 1: Line 1:
Most games in [[TGM series|Arika's ''Tetris The Grand Master'' series]] randomize the order of [[tetromino]]es 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.
Most games in [[TGM series|Arika's ''Tetris The Grand Master'' series]] randomize the order of [[tetromino]]es using an algorithm that makes successive identical tetrominoes less common. The system involves keeping a history of the most recent tetrominoes and trying to choose a random tetromino not in the history.


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.
== ''Tetris The Grand Master'' ==
In ''[[TGM]]'' he system involves keeping a history of the four most recent tetrominoes and trying to choose a random tetromino not in the history. The state of the history is initialized to a fixed state of [Z, Z, Z, Z]. 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.
Each time a piece is generated, the game will try '''4''' 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.  
*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.


== Pseudocode ==
The game never deals an S, Z or O as the first piece, to avoid a forced overhang.
:Function tgmRandomize(''history'' as list of 4 pieces) as piece:
 
::For try = 1 to numTries:
== ''Tetris The Absolute The Grand Master 2'' ==
:::''candidatePiece'' = random element of set {I, J, L, O, S, T, Z}
''[[TGM2]]''<nowiki>'</nowiki>s randomizer works the same as in ''TGM'', but with a few changes:
:::If ''candidatePiece'' is not in ''history'':
 
::::Exit loop
*In ''TGM2'' (and ''TAP''), the game will try '''6''' times to generate a tetromino that doesn't match any in the history.
::Move all tetrominoes in history back by one position
*In ''TGM2'' (and ''TAP''), 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.
::Put ''candidatePiece'' at front of history
 
::Return ''candidatePiece''
== ''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.
 
== ''Tetris The Grand Master Ace'' ==
''[[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 4 Absolute Eye'' ==
''[[TGM4]]'' presents two different randomizer methods, depending on modes and the ruleset used. 'Show Tetrimino randomization type' can be toggled on in the game settings to show which randomizer is currently being used.
=== Standard ===
'''Standard''' uses the "7-bag" Random Generator, modified similarly to ACE to never deal S, Z, or O as the first piece. It is referred to as '''"7BS"''' ingame.
 
=== TGM ===
'''TGM''' appears to use a similar randomizer to the one found in the previous game. It is referred to as '''"IRM"''' ('''I'''nitialize '''R'''andom '''M'''ino) ingame.
 
=== Konoha/Shiranui ===
Konoha will always use IRM regardless of the picked ruleset. Similarly, Shiranui will always use 7BS.


== References ==
== References ==
*[http://www.tetrisconcept.com/forum/viewtopic.php?p=2038#2038 colour_thief's description of the TGM randomizer]
*[https://web.archive.org/web/20151107011715/http://tetrisconcept.net/wiki/User:Zzymyn#Random-Number_Generator Disassembly of the ''TAP'' randomizer]
 
*[http://tetrisconcept.net/threads/randomizer-theory.512/page-9#post-55478 ''Ti'' randomizer explanation]
**[https://tetrisconcept.net/threads/randomizer-theory.512/page-12#post-65418 ''Ti'' randomizer commented C code] including cause of bug
 
 
{{Arika games}}
 
[[Category:Randomizers]]

Latest revision as of 06:53, 19 May 2025

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 most recent tetrominoes and trying to choose a random tetromino not in the history.

Tetris The Grand Master

In TGM he system involves keeping a history of the four most recent tetrominoes and trying to choose a random tetromino not in the history. The state of the history is initialized to a fixed state of [Z, Z, Z, Z]. 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.

Each time a piece is generated, the game will try 4 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.

The game never deals an S, Z or O as the first piece, to avoid a forced overhang.

Tetris The Absolute The Grand Master 2

TGM2's randomizer works the same as in TGM, but with a few changes:

  • In TGM2 (and TAP), the game will try 6 times to generate a tetromino that doesn't match any in the history.
  • In TGM2 (and TAP), 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 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.

Tetris The Grand Master Ace

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 4 Absolute Eye

TGM4 presents two different randomizer methods, depending on modes and the ruleset used. 'Show Tetrimino randomization type' can be toggled on in the game settings to show which randomizer is currently being used.

Standard

Standard uses the "7-bag" Random Generator, modified similarly to ACE to never deal S, Z, or O as the first piece. It is referred to as "7BS" ingame.

TGM

TGM appears to use a similar randomizer to the one found in the previous game. It is referred to as "IRM" (Initialize Random Mino) ingame.

Konoha/Shiranui

Konoha will always use IRM regardless of the picked ruleset. Similarly, Shiranui will always use 7BS.

References