9

The Classic Tetris World Championship uses original NES consoles that are modded to provide the same RNG for both players:

Players WILL have the same RNG

I am wondering how this was done. So, my question is two-fold:

  1. What random seed is used by the NES?
  2. How can this seed be manipulated?
11
  • 4
    Since this question pertains to a computing aspect of a particular retro console, rather than a gaming aspect, this site seemed more appropriate. Dec 22, 2020 at 22:36
  • 4
    @Raffzahn I think it's be on-topic on both sites. It's about a modern gaming competition, but also about contemporary use of retro hardware. The specific “how was it done in this modern instance” might make it off-topic here, I suppose; is that the main issue?
    – wizzwizz4
    Dec 22, 2020 at 22:55
  • 1
    The rule is "Players WILL have the same RNG", not "Players WILL have the same RNG that is set to the starting condition". But that doesn't make sense based on what you observed. Thus, I really think this would be better answered at gaming.SE since they know more about how these tournaments are run.
    – RonJohn
    Dec 23, 2020 at 6:29
  • 1
    According to this comment and this one on Reddit, CTWC uses a modified cartridge with significantly different piece generation code. (They modify it on the fly, Game Genie style, to avoid problems with copyright.) I'm not sure that answers your general question though.
    – benrg
    Dec 23, 2020 at 23:38
  • 1
    There is a difference between systems with hardware RNG support (e.g. Atari POKEY) and those without. Identifying the nature of pseudo-randomness on the NES seems appropriate to RC.
    – fadden
    Dec 24, 2020 at 15:48

1 Answer 1

8

Community Wiki, as it's unclear to me why @JaapJorisVens deleted his answer given that it appears to contain the necessary clues:

The carts are special carts we have made that contain 1000 selectable games. It is worth mentioning that the carts are actually adapters - essentially Game Genies - which do nothing unless you have an original NES Tetris cart plugged in.

Each of the 1000 games corresponds to a unique random seed which initializes the RNG for each game. The seed is iterated once per piece to produce the sequence. ...

Part of the RNG algorithm in the cart makes use of fairly large tables ... Each year we shuffle the contents of these tables to make a new cart.

So:

  • the original Tetris is used;
  • a competition-specific cartridge acts as a passthrough to replace Tetris's random number generator; and
  • specifically, that passthrough device spots when Tetris is performing its new-piece sequence and at that point inserts the next random number.

The NES itself doesn't inherently generate random numbers, that's a per-game process, implemented however each game sees fit. For the purposes of this competition they've engineered an intermediary that substitutes its own random numbers, generating them exactly on-demand.

Per other parts of Jaap's answer:

The math involved in 'iterating' the seed is fairly detailed, involving a LFSR (as is used in the standard NES cart), a few looping counters, and some lookup tables. Just before each game, a random number between 0 and 999 is chosen and players are told which game to select on the cart. After a game is played, it is never re-played.

So both the new implementation and the original are linear feedback shift registers ('LFSR's), which are shift registers in which the bit going out is exclusive-ORd onto some other combination of bits in the current state. Through that means an n-bit register can iterate through 2n − 1 states in a fixed sequence that is sufficiently oblique that a human might interpret it as random.

That said, it sounds like the passthrough device goes further in using the LFSR to index random number tables, so it's likely that the LFSR is being used just because it's easier to throw together than a classic ripple counter.

Quite probably the original just uses the output of its software LFSR directly.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .