# TGM1 Randomizer

Thread in 'Research & Development' started by slowbrosif, 30 Jul 2015.

1. ### slowbrosif

Hello,

So I'm casually playing TGM1 and today I pulled three of the same blocks in a row. It baffled me; I was unaware that this is even possible. What are the chances of something like this even happening?

Overall I've enjoyed my experience with TGM1, but often I find the randomizer to be frustrating. Is the algorithm in TGM2 different/better? I'm new to the TGM series and an explanation of this would be appreciated. Thanks.

2. ### Elision

TGM2 is noticeably better; TGM3 very slightly better on top of that. See an explanation here: http://tetris.wikia.com/wiki/TGM_randomizer
Basically: it remembers the last four pieces, and mildly avoids giving you one of those again by rerolling up to four times if you are going to get a repeat. 3 in a row is fairly rare, but not impossible.
In TGM2, it rerolls up to 6 times instead, so 3 in a row is very rare (but happens).
TGM3 does fancy shit to also avoid long droughts (which is a big problem in tgm1 in my experience). There's some other info and nerd shit in this other thread: http://tetrisconcept.net/threads/randomizer-theory.512/

3. ### zzymyn

Huh, that wiki page is actually slightly incorrect, although it doesn't actually make a difference. I've been reverse-engineering the TGM2 randomizer for my TAS project.

The initial history state is actually [ Z, Z, S, S ], and the first block overwrites the first element, so in practice the initial history is [ X, Z, S, S ], where X is the first block. Functionally this should be identical to starting with [ Z, S, Z, S ].

If you'd like to see the actual RNG function used in TGM2, you can check out: http://tetrisconcept.net/wiki/User:Zzymyn#Random-Number_Generator

4. ### TGGC

In TGM1 3 pieces in a row have roughly a change of 1 in 4000 if I am not completely mistaken. But as the number of piece sequences is limited by the number of bits of the RNG, one would have to look at all sequences to give an exact answer.

@zzymyn: But you have a different history after the second piece?

5. ### slowbrosif

Wow, I haven't even played TGM1 500 times!

Yes, I'm glad it's not just me noticing these droughts. I felt reluctant to blame the game for my failings since I'm not a very good player overall, but there were certainly instances where I simply lost because no l blocks were being pulled. I've already began playing TGM2 and I can notice the difference between the two randomizers. While TGM2 is more difficult, all blocks needed are pulled consistently enough and I can manage to play and simply blame myself for my failures. It's a lot more comfortable to leave areas untouched until the appropriate block shows up.

7. ### slowbrosif

Oh thanks. I already knew the basics of skimming without being able to put it into terms, but that article explains additional strategy I haven't been aware of. I'll also need a better understanding of ARS too it looks like.

8. ### bigwig

Hate to hijack this thread, but while we're comparing them, does anyone have a link explaining how the tgm3 randomizer differs from TAP? The wiki implies it has a 35 bag or something? But that can't be all there is as it feels even more "fair" than TAP.

9. ### TGGC

It is not really a 35 bag, but more like a dice with 35 sides. In the beginning, the dice has all 7 pieces 5 times. But after rolling the dice, the game modifies whats on the dice. So the idea is: if you roll the dice very often, but there is no I piece appearing, there are more and more I pieces on sides of the dice. So it gets more and more probable to roll an I next up to the point where every 35 sides are an I.

10. ### Sumez

Getting the "wrong" pieces in Tetris should never be a problem for survival. The worst consequence is losing the ability to perform Tetrises, but the longer your game lasts, the more it evens out. The TGM1 randomizer is not bad, and still a lot more fair than, say, the NES one, which still manages to have a very active community of people getting amazing scores.
I would say the biggest advantage of the much more fair TGM2 randomizer, is how it helps you predict what you will be getting at all times. You can never be sure (which IMO is the charm of Tetris, and why I dislike 7-bag and 3+ piece previews), but when you have to make a split descision, base it on the last 4 pieces you've received - or rather, the pieces that are not among those 4.
I still get 3 of the same piece in a row fairly "regularly" on TGM2... maybe once every second day if I'm playing a lot. And two in a row is quite common, usually several times during a game. So you should always prepare for anything.

11. ### Melinda

First game I played on my PCB gave me 3 O's in a row. I was pretty surprised

12. ### cyberguile

Another question: I've played TGM1 2 hours a day for three months this year (with almost 70% of the games ending before 300, so you can imagine it's a lot of games ) and I never ever started a single game with an S or a Z.
@zzymyn is it because what you have explained ? Would be logical since the game is purely speed based that they put something in the randomizer that does not break your game on the very first tetromino.

13. ### Qlex

Starting off with three Os can be doable on a calculator. My calculations indicate that it's quite unlikely and could lead to s or z possibly popping up afterwards, which is a bummer.

@cyberguile : There is an extra rule that only applies to the first piece. It cannot be a s or a z. Even if the history system would not influence it enough you still have this rule to prevent an early hole

14. ### TGGC

AFAIK you never start with an O. Second piece can be an S or Z, so if you start with O-Z or O-S you cannot prevent a hole.

15. ### zzymyn

I've only disassembled the TAP Death code, but it will keep re-rolling until the first block is not an S, Z or O block, so the first block will never be S, Z or O.

16. ### rednefed

I have honestly felt that TGM1's randomizer can lead to perceived droughts of 20+ levels (pieces + line clears). I tend to play more conservatively in TGM1 as a result. TGM games never start you off with S, Z, or O. Getting three of the same piece in a row is not uncommon at all. Pretty nice when you roll three I's with a nice high stack...

17. ### nightmareci

Hm, I did reverse out the TGM1 randomizer, would you folks like a Python script or something to play with?

18. ### TGGC

I am fine with the ASM Code or just a technical description, too.

19. ### Zaphod77Resident Misinformer

Go play bastet, and see how well you survive. (that game tries to give you the wrong piece on purpose. it very often succeeds)

In fact, it's proven that an endless sequence of S and Z alternating will end your game unless the playfield is a multiple of 4 wide. Hold will not save you. try it in nullpomino, which i think allows you to pick sz as a randomizer.

That said, TGMs randomizer makes the odds VERY small you will end up with a sequence that cannot be dealt with by playing defensively. In fact i'm pretty sure it's possible to GM on every seed.