Slashdot Mirror


Tetris Is Hard To Test

New submitter JackDW writes: Tetris is one of the best-known computer games ever made. It's easy to play but hard to master, and it's based on a NP-hard problem. But that's not all that's difficult about it. Though it's simple enough to be implemented in one line of BBC BASIC, it's complex enough to be really hard to thoroughly test.

It may seem like you can test everything in Tetris just by playing it for a few minutes, but this is very unlikely! As I explain in this article, the game is filled with special cases that rarely occur in normal play, and these can only be easily found with the help of a coverage tool.

3 of 169 comments (clear)

  1. replacing line feeds with terminators is not a 1-l by raymorris · · Score: 4, Informative

    In BBC BASIC, a colon is a statement terminator, much like a semicolon in languages with C-style syntax. The linked code is therefore not a one-liner by any meaningful definition of the term. One could replace all of the linefeeds in Linux kernel source with semicolons and other appropriate terminators. That wouldn't make the kernel a one-liner.

  2. Re:One line? by lgw · · Score: 4, Informative

    Except that is not "one line". It is six lines. Any program can be a "one-liner" if there is no limit on the line length. Well, unless you writing it in Python.

    The line length limit is 256 bytes, of course. And these hacks are the basic-equivalent of the C obfuscation contest.

    As the authors say: "I'd like to think it is self documenting. The code speaks for itself; even if what it has to say is not very nice."

    --
    Socialism: a lie told by totalitarians and believed by fools.
  3. Re:One line? by BlackHawk-666 · · Score: 4, Informative

    In ASCII, but many BASICs will reduce keywords down to a single byte.

    --
    All those moments will be lost in time, like tears in rain.