-
Notifications
You must be signed in to change notification settings - Fork 267
Protocol Reference
(This page is mostly incomplete and may be inaccurate. See testplan.org (or just run the tests) for definitive examples on how each command should behave.)
The tests communicate with your game through standard i/o.
To make this happen, you will need to create a very simple interactive prompt that allows the test to issue commands.
Here are the first three commands:
cmd | meaning | notes |
q | quit | quit the loop |
p | print the state of the board | |
g | given | as in: /given the following data…/ |
The p
and g
commands deal with 2d arrays of characters, which you will need to to be able to read and generate. The characters are separated by spaces and newlines, which you will need to insert when printing and discard when reading.
Here is an example of what the format looks like:
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . m . . . r r . . . . m m . r r y y . . . m c c c c y y
The 22 lines correspond to the official Tetris matrix. (The official size is 10 × 20. The Tetriminos spawn in the extra 2 lines at the top.)
The .
character is meant to indicate an empty square, and the letters represent colors.
The color codes are:
char | meaning | tetramino |
. | empty | n/a |
m | magenta | T |
c | cyan | I |
b | blue | J |
r | red | Z (or N) |
g | green | S |
y | yellow | O |
o | orange | L |
When the input
This command will be followed by 22 lines, each containing 10 space-separated characters. For example: