|This is the archived CodeCup 2016 website.|
Click here to go to the new CodeCup website.
The game 6561 is a cooperative two-player game. Players A and B take turns placing pieces on the board and then ‘tilting’ the board so all pieces slide towards a side of the board.
The score of the board is the sum of the values of all pieces on the board. The score of the game is the maximum score of the board during the entire game. Both players obtain the same score if they both play correctly (see Technical Information). Note that the maximum score may not be the ﬁnal score on the board.
The game is played on a board with dimensions 4x4 that consists of 16 square ﬁelds. The game is played with pieces of different colors (red, blue and gray), and the different colors are used by both players.
The game 6561 is a variation of the single-player game 2048.
In the game 6561 the players alternate in making a move. There are four types of move: ‘place a red piece’, ‘place a blue piece’, ‘place a gray piece’ and ‘slide the board’. The 4 moves deliver a rhythm of 10 turns as shown in the following table:
This rhythm keeps on repeating during the entire game until 1000 moves have been made. (So 100 times the full rhythm). The game ends earlier when no valid move can be made.
A player can place a piece on any empty ﬁeld. If there are no empty squares when the player must place a piece, the game ends.
When a player must slide the board, the player chooses a direction: up, down, left or right. A move to slide the board must change the board in order to be a valid move. If there is no valid slide move when a slide move is required, the game ends.
When sliding the board, the game looks at the pieces starting from the edge towards which you are sliding. When moving up or down the game looks only at consecutive pieces in the same column. When moving left or right the game looks only at consecutive pieces in the same row. Note that consecutive includes consecutive pieces that have one or more empty ﬁelds between them.
When two consecutive pieces have the same value but a different color they will both disappear.
When two consecutive pieces have both the same value and color they will be replaced by a single new piece that has the same color and as value 3 times the value on the original pieces.
A piece that is newly created in this manner will not be removed or changed within the same move.
At the end of a sliding move all pieces will be touching on the side that they have been slid to.
The requirement that the board must be changed during a slide move basically means that the game ends when the board is empty after the first slide, or when the board is completely full without any consecutive same value pieces. In any other situation you can make a slide move where the board changes.
As shown in the example above, the board consists of 16 square ﬁelds arranged in a 4x4 grid. Every ﬁeld is labeled with two coordinates. Those are shown in the lower left corner of each ﬁeld in the example.
You should write a computer program that receives from the judging software the last move that your opponent has made. Your program then calculates its move, and writes that move back to the judging software.
You will communicate with the judging software using stdin (standard input) and stdout (standard output).
Your program should always start reading information from the judging software.
The judging software will start by sending you ‘A’ to indicate you are player A, or ‘B’ to indicate you are player B.
If your program reads ‘A’, you are the ﬁrst player and the judging software will wait for your ﬁrst move. If your program reads ‘B’, you are player 2 and should start by reading the ﬁrst move of your opponent.
The judging software guarantees that any move it sends to you, is a valid move.
After the game starts you should alternate between reading the move from your opponent and writing back your move. Don’t forget the rhythm of the moves!
A move from your program is indicated as follows:
If you make an illegal move, your program crashes, or your program uses up the total allotted time, your program will score 0 points. The judging software will take over from you and will play random moves in a deterministic way. This gives your opponent still a chance to score points.
If the judging software sends you the command ‘Quit’, your program should terminate gracefully. If you do not terminate properly, your program will be killed.
When you write to the judging software you should end each string with a newline. You should also ﬂush your output immediately.
The total time limit for your program is 60 seconds. This means that you cannot use more than 60 seconds of calculation time for all your moves together. The time that the judging software uses, and the time that your opponent uses, is not added to your time.
All programs that work well with our judging software will be admitted to the competition.
The judging software historically talks about the ‘white player’ for the ﬁrst player and the ‘black player’ for the second player. Because of the colors in this game we labelled the ﬁrst player ‘Player A’ and the second player ‘Player B’.
CodeCup is a computer programming competition that is organized the Nederlandse Informatica Olympiade (NIO), the Dutch Olympiad in Informatics. The competition is hosted online and can be followed live on the internet. Programmers from all over the world can enter the CodeCup competition. CodeCup staff and NIO staff do not participate.