This is the archived CodeCup 2009 website.
Click here to go to the new CodeCup website.
CodeCup 2009 - An online programming competition  

CodeCup 2009 - An online programming competition

Rules of the game Pillars

Game board layout

Introduction

Pillars is a two player game that is played on a 10 by 10 board. One player plays with red tiles; the other player plays the blue tiles. The object of the game is to let the opponent player make the last move.

The board

The initial board contains 10 randomly placed pillars. The pillars are placed in 10 different rows and in 10 different columns.

Moves

The red player starts. He selects a rectangle of empty fields on the board and fills it with red tiles. A single field also counts as a valid rectangle. Players continue taking turns until no empty fields are left on the board. At that point, the game is lost by the player who made the last move.

Moves are written as 4-letter strings, specifying the top row, left column, bottom row and right column of the rectangle, in that order. An example of a possible move is "BdCh".

Joker

At each turn, a player may use a joker to claim the victory. Claming victory will gain you extra points if you win, but cost you extra points if you lose. You may claim the victory only once during a game.
To claim the victory, put an exclamation mark before your move: "!BdCh".

Playing the game

Your program communicates with the jury program using standard input (stdin) and standard output (stdout). You read information from stdin and you write your moves to stdout. At the start of the game, both players read the positions of the 10 initial pillars (each on a separate line). The next line read by the red player contains the word "Start", telling him to make the first move. The blue player does not get the word "Start", but instead gets a line with Red's first move. If it is your turn to make a move, determine your move and write it to stdout (followed by a newline character to end the line). After you have made your move, you read the move of your opponent from stdin (also on a separate line). Any move that the jury software sends to you is guaranteed to be a valid move.
If either player's program makes an invalid move or if someone wins, you will read "Quit" from stdin. This indicates that your program has to terminate normally.

Game score

The winner of the game scores 18 points plus his joker points. The loser scores 9 points minus his joker points.

Joker points are computed as follows: When a player claims victory, the number of empty fields is counted before his move is carried out. That number is divided by 10 and rounded down. For example: if 49 empty fields are counted, his joker is worth 4 points. There is one exception for the blue player: he can get the maximum of 9 joker points by claiming victory in his first move. If a player did not claim victory, his number of joker points is zero.

If a player makes an illegal move, crashes or runs out of time, the opponent wins. The player who caused the irregular game end will get a score of 0. The winner's score will be calculated as follows:

  • If the player already played the joker, the score is calculated normally, i.e. 18 points for winning plus his joker points.
  • If the player didn't play his joker, the score is calculated as if he just played the joker, i.e. 18 points plus the number of open squares divided by 10.

Example Game

The following table shows how a game is started.

RedBlue
InputOutputInputOutput
AaAa
BbBb
CcCc
DdDd
EeEe
FfFf
GgGg
HhHh
IiIi
JjJj
Start
AcBd
AcBd
!AeAj
AeAj
...

Time limit

Your program has a total playing time of 5 seconds. The jury computers use a Pentium IV, 2.8 GHz that has 64 Mb of internal memory available for your program. It is up to you to decide how to divide these 5 seconds over the various moves.
Your program is suspended after the system receives your output and turned to an active state when there is input for your program, only the active time is counted.

About CodeCup

CodeCup is a computer programming competition that is organized by the organizers of the Nederlandse Informatica Olympiade (NIO), the Dutch organizers of the International Olympiad in Informatics.
The competition is hosted online and can be followed live from the internet.
Programmers from all over the world can enter the CodeCup competition. Enter the competition on the website http://www.codecup.nl. The organizers of the NIO are not eligible to participate.

Click here to see a sample game.