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

CodeCup 2014 - An online programming competition

The Rules of Poly-Y

Poly-Y is a connection game where two players compete against each other by placing stones on a board. The goal of the game is to control the corners of the board.

A group of connected stones may connect two or more sides of the board. If a group of stones is connected to two adjacent sides of the board and is also connected to a third side, the corner between the two adjacent sides of the board is controlled by this group of stones.

The first player to control three or more corners of the board wins.

The board

The board consists of 106 fields, as shown in the figure. Most of the fields are hexagons and are connected to six other fields. The fields at the edges are half hexagons and are only connected to three or four other fields. The middle field (field 43) is a pentagon and has only five adjacent fields.

The board has five sides. An example of a side are the fields 1-4-9-16-25-36-49.


Players take turns placing a piece of their colour in an empty field. White moves first. The first player to control three or more corners wins the game. A draw is not possible.

Swap rule

In this game the first player has a small advantage. To offset this advantage the second player may decide to continue playing as white if he feels that the first move was a great move. The second player can indicate this only when making his first move. He indicates this by writing '-1' to stdout. The first player will receive '-1' on his stdin before making his second move. This means that instead of continuing play as white he now has to make the first move for black. Both player will continue playing with the opposite colour until there is a winner. In this case the first player wins when he controls at least three corners with black, and vice versa.

The score

The player that wins gets 2 points. The other player gets 1 point.

Illegal moves

If a player makes an illegal move, crashes, or runs out of time, this player gets a score of 0.

The jury software will take control of the problematic player and will finish the game for this player. The jury software will find all legal moves in an undisclosed and possibly non-deterministic way and will make the first legal move it finds. This method will allow the second player to score points.

If the second player also makes an illegal move later during the game this player also receives a score of 0.

Playing the game

You have to write a computer program to play the game. Your program will never communicate directly with your opponent; instead you communicate with the jury program using standard input (stdin) and standard output (stdout).

Your program should read information from the jury program from stdin and write your moves to stdout.

Your program must begin by reading from stdin. The jury writes 'Start' on stdin for the White player. The Black player receives the first move of the White player on stdin. This means you have to determine yourself whether you are Black or White based on the first line that you read.

Your program determines a move and writes this move to stdout. After making a move your program should read the move of the opponent from stdin. Any move that you read from stdin is guaranteed by the judging software to be a legal move. Note that all moves will be terminated with a newline. You must flush your output after each move.

The program must continue until the text 'Quit' is read on stdin. This indicates that your program has to terminate normally. In the case that no more input is expected, your program may quit by itself.

Example Game

The following table describes a sample game. For each consecutive move the table shows what a player had read on stdin, and what was written to stdout.

In this example White places on field 73 and wins. Both programs receive a 'Quit' by the jury software. Crashes after the winning move are ignored.

Time limit

Your program has a total playing time of exactly 30 seconds for all moves combined. The jury computer uses an Intel Xeon E5405 running at 2.0 Ghz, with 64 MB memory available for your program. You can decide how to divide the 30 seconds over the various moves. Your program is suspended when the system receives your output and turned to an active state when there is input for your program. Only your active time is counted towards the timelimit.

About CodeCup

CodeCup is organized by 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.

More information

Click here to see a sample game. Poly-Y is a remarkable connection game from the coinventor of Y. For more information: