Playing tetris is fun. Watching an AI play tetris is also fun.
Some tetris AIs will always ignore the possibility of maneuvering a piece under an overhang, which makes me sad.
It means that the programmer said to himself, "What are all the possible places the tile could be at the top of the board, and from each place, what happens when I hard drop the tile?"
The input of your program will be a game piece, a board, and a newline.
The output of your program will be two integers (with a space between them) and a newline.
Your program should generates all possible "moves", distinguishing those "moves" which could be produced by a naive AI (rotation and shifting left/right may only occur at the top), from those "moves" which can only be produced either the naive way or if rotation and horizontal shifting are allowed below the top.
The count of how many "moves" are in each of the two categories (smaller number first), are the two numbers output.
Each "move" is a game board where the tile has a
+ square below it, or where the tile would go off the edge of the grid if it were moved one row downward.
The format of the game piece is a single byte which is one of
i). The board consists of 180 bytes, each being either space (
) or a plus (
+), representing a grid 10 squares wide by 18 tall.
Each piece starts with the top row of its bounding box on the top grid row, and is centered, rounding to the left.
The piece letters represent the same tetrominoes used by what's called the Super Rotation System, and obviously the same rotations.
When maneuvering a piece, it may be shifted left or right, rotated clockwise or counterclockwise, or moved one row down, except if doing so will cause part of the piece to go off the edge or top or bottom of the grid, or overlap with any of the
+ marks. There are no wall kicks.
Shortest source code wins.
I suggest (but don't require) that you use some sort of transposition table to avoid infinite loops of repeatedly shifting left/right, or rotating infinitely, etc.