L. Multitetris (2000 points)

Here is a simple networked two-player variant of tetris - with a couple of twists. Instead of two separate boards, the players play on the same board, with their pieces falling in opposite directions; and they have some control over the pieces their opponent gets (by having the ability to select a piece that won't be spawned in the next turn).

The GAME

In every round there are two players: a left and a right player. The board is like a normal tetris board, except the pieces of left player are "falling" from left to right, the pieces of the right player "falling" from right to left. The players move after each other.
An example of "falling"
Left...................................Right 
--------------------------------------------
|..........................................|
|...x............................oo........|
|...xx.---->...............<----.oo........|
|...x......................................|
|..........................................|
|..........................................|
|..........................................|
--------------------------------------------
		
Your pieces do not fall until the end of the board, it is stopped some steps before the another player's wall.
Example
Left...................................Right 
....|.<--right player's piece 
....|....will fall until this line
--------------------------------------------
|..........................................|
|.....x..........................oo........|
|.....xx.--->..............<----..o........|
|.....x...........................o........|
|..........................................|
|...OO.....................................|
|...OO.....................................|
--------------------------------------------
..........left player's piece----->.|
..........will fall until this line.|
		
If two pieces "meet" somewhere on the board, the current player's piece is stopped. The next player has the chance to move away, however she doesn't do so her piece will be also stopped. If a piece stopped, a new piece generated and started from the player's starting wall. The stopped piece become a stationary wall.
Example of stopped pieces on the board
Left...................................Right 
--------------------------------------------
|..........................................|
|...x............................oo........|
|...xx.---->...............<----.oo........|
|...x..............O.......................|
|...............XXOO.......................|
|................XXO.......................|
|..........................................|
--------------------------------------------
		

Points

If there is a full column of stationary wall, it is destroyed, like in the normal tetris game. A player gets 1 point for each destroyed character belonging to her, and 5 points for each destroyed character belongs to the other player.
Example: left player destroys a column of stationary wall.
Left...................................Right 
--------------------------------------------
|................XX........................|
|................XOO.............oo........|
|..............x.XOO.............oo........|
|.........--->xxx..O.......................|
|.............X.XXOO.......................|
|.............X..XXO.......................|
|.............XXOOOO.......................|
--------------------------------------------

Next step:
Left...................................Right 
--------------------------------------------
|.................X........................|
|.................OO.............oo........|
|................XOO.............oo........|
|...............XX.O.......................|
|..............X.XOO.......................|
|..............X..XO.......................|
|..............XXOOO.......................|
--------------------------------------------
		
In the example above the left player got 6*1 + 1*5 = 13 points. After a column is destroyed, the stationary wall "over" the destroyed column fall towards the other player's wall. The stationary wall "under" the destroyed column DOES NOT move anywhere.

Game over

The game is over, if a player's element is stopped before it can fully leave the player's wall. Example: game over, right player lost the game
Left...................................Right 
--------------------------------------------
|...................................XX.O...|
|...x................................XXO...|
|...xx.................................OO.o|
|...x..............O................XXXOOoo| <--- piece cannot leave the wall
|...............XXOO................X......|      next step it will stop
|................XXO.................XX.O..|
|....................................XXOOO.|
--------------------------------------------
		

Moves

In one step a player can: at the same time. So, for example one can rotate clockwise AND step up in the same step.

Piece generation

A piece is uniform randomly selected. However, a player (e.g. left player) can explicitely deny an element for the other player (right player) in the next turn. So, the generator will uniform randomly select from all the pieces, except the element denied by the left player.

Scoring

There will be 12 scoring periods (starting at odd hours: 9-11, 11-13 and so on) - these will show up as 12 "inputs" in the submission system. The evaluated scores will be the sums of points gained in the given scoring period; the real scores will be scaled based on these (with the best team getting 166 points in one scoring period). The total score one can get is 12 * 166 = 1992 points.

The Protocol

One team may maintain one TCP connection to the server at once (connecting to the server will kick the previous connection, if any). Disconnecting from the server doesn't affect any game state (ongoing games will remain ongoing). A team may reconnect to continue their game where they left off.

Each connected team is either playing a game against an opponent, or waiting for the next game (it's not possible or necessary to play multiple games at once).

A new round starts every few minutes. At the beginning of a round, all teams that are currently connected but are not playing, are paired up with other teams, and a new game is started for each pair.

All communication happens over TCP, in plain text, is line based (all messages in either direction are a single line), all line endings are unix.

Messages from the server

Messages from the server may consist of multiple tokens, separated by single spaces.

The team is waiting for the next game. The next round (when there's a possibility of getting in a game with an opponent) begins in seconds seconds.

A round begins. The message contains the number of teams currently connected and not playing.

The LEFT or RIGHT message is sent to the left and right players at the beginning of each turn in the game (the message type indicates which side is the currently connected team playing).

Each LEFT or RIGHT message will be followed by board_rows * BOARD messages with the contents of the playing board (from up to down).

This message contains the subsequent row of the playing board. The row is a single string that is always the same length.

Messages sent to the server

The only kind of message a team can send is their current move. Moves are only accepted when it's the team's turn in the game; only one move is accepted per turn.

Moves are encoded in three character messages:

From the last sent BOARD message, teams have one second to make their move. Not making a move (by not sending anything, or by not even being connected) implies a ns0 move (after a one second wait).

Pieces

This game has the usual tetris pieces, indexed from 0.