|This is the archived CodeCup 2006 website.|
Click here to go to the new CodeCup website.
Rules of the game Turn Right
Turn Right is a game in which two players strategically place game pieces on a game board. In the first phase of the game, the players situate their game pieces on the board. When the board is completely filled, the second phase begins. During this phase, each player will take turns choosing a circuit on which the game pieces will rotate clockwise. Players strategize how to choose their next circuit in order to create 2x2 squares of the player's own colored game pieces and to prevent or break down 2x2 squares of the opponent's color.
Turn Right is played on a square game board made up of 36 smaller squares (6x6). These squares are named according to the chess naming system; the lower left square is called a1. The upper right square is called f6.
Each player gets 18 game pieces. During the first phase, the white player and the black player (White and Black hereafter) take turns placing one game piece on a free square, beginning with White. In the second phase, Black takes the first turn to create a circuit. Black and White alternately make 13 moves.
In order to make a move in the second phase, the player must create a circuit, a closed path on the board, for which they name a beginning square and a number of other squares. Two consecutive squares (including the first and last of the circuit) must lie either in the same row or the same column. Each square may be included only once in a circuit. All of the game pieces that lie on the chosen circuit are rotated one space clockwise, and all other game pieces remain in their old positions.
The following example shows a second phase turn in which the circuit is chosen as a1-a2-b2-b3-f3-f1.
Throughout the second phase, the circuits can become increasingly complicated. If it is the Nth turn (out of 13 total), the circuit can have a maximum of 2*(N+1) corners. Therefore, on their first turns, Black and White must each make a rectangular circuit. By their 13th turns, they may choose a circuit with up to 28 corners.
During the second phase, the object is to make 2x2 squares of the player's own color. After each turn, the number of these squares is counted, each worth one point. The game pieces may count toward the formation of more than one square. To compensate for any advantage Black may have by beginning the second phase, White is automatically awarded 5 free points. If any player makes a square of 3x3 of his own color, he wins immediately and the game is over.
If after all 13 turns no player has achieved a 3x3 square, the number of points is tallied. If one player has more points than the other, say Black, then Black wins two game points and White wins no game points. If there is a tie, each player receives one game point. The winner gets 50 points plus the point difference between him and his opponent. The loser's point total is equal to 100 minus the winner's point total. For example, a final score of 32-26 would translate to a point score of 56-44. If the difference is greater than 50, the winner receives 100 points and the loser receives none.
If one player wins by making a 3x3 square of his own color, he receives 3 game points and his opponent receives none. The points are calculated in the same way as above, except that the winner will also receive a 50 point bonus. Therefore, if Black wins by forming a 3x3, but by points he was behind at 22-15, Black would receive 93 points and White would receive 57. If a turn enables both players to form a 3x3 square simultaneously, the winner is he whose turn it was NOT.
If a program makes an illegal move or takes longer than the time limit, that player loses. His opponent, the winner, receives 3 game points and 50 bonus points beyond those points that he had already earned up to that moment. The player whose program violated the rules receives neither game points nor points. For example, if Black exceeds the time limit but was ahead with a score of 14-18, White wins 3-0 in game points and 96-0 in points.
Write a program that reads from standard input and writes to standard output. For each turn, your program reads one line of input, and based on the given information, makes a move. That continues to happen until the game is completed. At that point your program must stop.
If the first line contains the word 'Start', it means that your program will play with the white game pieces, and may make the first move. If the first line contains a move, then it is the first move of your opponent, and you will play with the black game pieces.
If it is your program's turn to make a move, choose your move. Write a line with your move. In the first phase, write the name of a free square, for example 'a4'. In the second phase, write the names of the squares on which you want your circuit to rotate, separated by a minus ('-') sign. The circuit from the example would be written as 'a1-a2-b2-b3-f3-f1'. You may begin your circuit at any of the corners, but you must put the subsequent corners in the correct order. In the example, the game piece on b3 moves on space in the direction of f3, therefore onto square c3. The jury software will process the circuit and pass it on to the opponent as input. The circuit will always be rewritten to start with the lowest numbered square yet still indicate the same circuit. When ordering squares, a2 comes before b1.
When there are 35 game pieces already on the board, there is only one possible place for Black to place his last game piece. Therefore, Black does not take this last turn. Both players know that this turn will be automatically taken, so Black writes his first move of the second phase.
When you have taken a turn, you read the move of your opponent as input. Your program will only receive valid moves. If your program or the program of your opponent makes an invalid move, the line will only contain the character 'x'. This indicates that your program must gracefully terminate. Your program must also terminate normally if the 13 turns of the second phase are completed or if a 3x3 square has been formed.
Your program has 30 seconds to play one game. A Pentium IV, 2.8 GHz, with 64MB RAM-memory available for your program, will keep the time. You have the choice of dividing this time among the different turns. Only the time between the reading from standard input and the writing to standard output will be counted.
Example input and output
Click here to see a sample game.
With each game both players may obtain game points and/or points. The result of a game can be 3-0, 2-0 or 1-1 in game points. The number of points may vary.
Doing an irregular move or exceeding the time limit results in losing the game. The loss will be counted as an irregular loss for the loser. The opponent automatically wins the game.
Winner of the tournament will be the one player with the highest number of game points. In case of a tie, the number of points is taken into account. If needed, the one with the least number of irregular losses prevails. If there is still a tie, both programs end with the same ranking.