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

CodeCup 2015 - An online programming competition

Ayu

Ayu is a dynamic connection game invented by Luis BolaƱos Mures in 2011. Ayu is played on the intersections of an 11x11 sized square grid.

At the start of the game, white and black pieces are arranged in an interspersed pattern as shown in the image below.

Terminology:

  • adjacent: orthogonally adjacent.
  • singleton: a piece that has no adjacent pieces of the same color
  • group: a collection of adjacent pieces of the same color
  • unit: a unit can be a single piece or a group of adjacent pieces with the same color.

Rules

Player alternate taking turns. White begins. A player is only allowed to move pieces of his own color.

Each turn the players can chose one of the following actions:

  • Move a singleton to an adjacent empty point.
  • Take a piece from a group and place it on an empty point that is adjacent tot the same group. You are not allowed to split up the group by moving this piece.
Every move you make must decrease the distance between the group of the piece you moved and a nearest group of the same color.

The distance between two pieces is the shortest path of adjacent empty points between them.

Object

The first player that cannot make a move wins. Usually this is the case when a player has joined all his pieces into a single group.

Draw

We think that draws are not possible.

Score

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

Strategy

An essential part of the strategy lies in building long walls between enemy units, thus forcing the opponent to spend many more turns connecting them. However, one should be careful not to lock up all available moves. Also, playing from the outside inwards is more efficient, as it helps you not to leave any units behind. the distance rule has some interesting tactical implications: sometimes, in order to move a unit (A) in the desired direction, you'll have to first move away the unit (B) which is closest to it so that A isn't "engaged" to B anymore.

Ayu stands for Attach Your Units. The rules have been kept to a minimum so as to let the featured mechanism unfold by itself. The result is a very organic and innovative game with great strategic potential.

The diagram on the left shows the relative distances between every pair of the white units A, B and C. Four moves are needed to join A and B, while C and A are only two moves away from each other. Therefore, if A is moved, it must get closer to C. The next two pictures show the only moves available to that group in its current position. Note that the center piece in it cannot be moved, as the group would be left split after the move.

In the diagram above, if White plays the marked moe, he will lose immediately, as Black will have no moves available on his next turn. Note that this is a legal move, even if the white group is momentarily split during the move.

White can win, instead, by entering the sequence below. In the last diagram Black still must (and can) move, after which White's one unit is immobile.

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 but always 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 you 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 you 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.

WhiteBlack
1StartJ1-I1
2J1-I1A2-A3
3A2-A3B1-C1
4B1-C1A3-A5
etc...
E5-K6B4-A3
QuitQuit

In this example white plays B4-A3 and wins. Both programs receive a "Quit" by the jury software. Crashes after the winning move are ignored.

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. For more information: http://www.mindsports.nl/index.php/arena/ayu.