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

CodeCup 2008 - An online programming competition

Rules of the game Alquerque


Alquerque is a two player game that is played on a 7 by 7 board. One player controls the white pieces; the other player controls the black pieces. The object of the game is to capture all of the opponent pieces.


There are two types of moves: the normal move and the capture move.
In a normal move, the player moves one of his pieces to an adjacent unoccupied space in any direction along the lines of the board. It is prohibited to move a piece back to the space it occupied in the previous turn.
A capture move captures an opponent's piece. A piece jumps over an opponent's adjacent piece (according to the lines of the board) in a straight line to the first unoccupied space (adjacent to the piece that was captured). If the first capture move puts the piece in a position to capture another piece, the player is required to do so. This is part of the same turn. The direction of movement can change for each capture. If multiple captures are possible from a specific location, the player can freely choose which piece to capture. If both a normal move and a capture move are possible, the player is required to do the capture move.

Notation of the moves

Example normal move notation: c3-d4.
Example capture move notation: e5*c3. In this example, the piece on d4 has been captured.
If multiple pieces are captured in one move, the following notation will be used: a1*c1*c3 (or something similar).

Playing the game

Your program should communicate with the jury program using standard-input (stdin) and standard-output (stdout). You will read information from stdin and you will write your move(s) to stdout. At first the player must read from the stdin. The white player will read Start and the black player will receive white's first move. If it is your turn to make a move, determine your move and write it to stdout. After you have made your move, you read the move of your opponent from stdin. A 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.

End of the game

The game ends in two possible ways: with a winner or in a tie. A player wins when he captures his opponent's last piece or when none of his opponent's pieces can make a valid move in his next turn. The winner must terminate his own program. The loser always receives a Quit. The game ends in a tie if no one wins after both players have each made 100 moves. In case of a tie, a player must terminate his own program and must not wait for a Quit.
Note: If the black player traps the white player in his 100th turn, therefore the last turn of the game since white starts, the game ends in a tie.

Game score

If a player wins the game, the score will be 12-0 in his favour.
In case of a tie, a player gets a score of seven points minus the number of the opponent pieces left on the board. Negative scores will be rounded up to zero. Example: if the white player has three pieces left and the black player one piece, the final score will be white 6 - black 4.
If a player makes an illegal move, crashes or runs out of time, the opponent wins with a score of 12-0.

Time limit

Your program has a total playing time of 30 seconds. The jury computers use a Pentium IV, 2.8GHz that has 64Mb of internal memory available for your program.
It is up to you to decide how to divide these 30 seconds over the various moves.
Only the time between reading from stdin and writing to stdout is counted.

Example Game

The following table shows how a game is started.

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 The organizers of the NIO are not eligible to participate.

Click here to see a sample game.