This is the archived CodeCup 2003 website.
Click here to go to the new CodeCup website.
logo  

CodeCup 2003

 

Technical rules

This section explains how you should write your program. Because the competition runs fully automated, it is important that your program works exactly according to these rules.

Sending your program

To enter the contest, you must write a program that is able to play Caïssa. You can submit the sourcecode of your program on this website. The source code must consist of one single file. We will compile and run your program under Linux.

Input and output

Your program reads input from standard input (normally "the keyboard") and writes output to standard output (normally "the screen"). Your program is started once at the beginning of a game and keeps running until the end of the game.

For each turn, your program reads one line of input describing the move made by your opponent. Your program selects a valid move and writes one line of output describing this move. The first line of input at the beginning of the game may contain the word start instead of a move, to indicate that your program is playing White. If the first line of input is a normal move, then your opponent is playing White and has already made his first move; in this case you are playing Black. If the input consists of the word end, then the game has ended and your program should exit.

A move is described by giving the names of the two cells on the board, separated by a '-'. Your output may uses upper or lower case letters; input will only consist of lower case.

Your program will only have to read valid moves.

Example dialog
input  output
start
b2-c4
e5-c5
c3-e3
and so on ...

Programming languages

You may write your program in Pascal, C, C++ or Java. The table below shows exactly which compiler and configuration we are using.

Language   Compiler   Command
Pascal FreePascal 1.0.6   fpc -Sgoh -O1 -Cr-t-
C GNU GCC 2.95   gcc -Wall -O2 -lm
C++ GNU GCC 2.95   g++ -Wall -O2 -lm
Java Sun JDK 1.3.1   javac -O

Pascal
Programs written in Pascal are compiled with FreePascal in TurboPascal mode.
FreePascal is a lot like Turbo Pascal, but it is more powerful. You can make an array of a few megabytes size without problems. Please note that the types Integer and Word can not contain numbers larger than 32767, resp. 65536. It is usually better to use the type LongInt.
You can use Read and ReadLn to read from standard input, and WriteLn to write to standard output. After each move written to the output, your program should call Flush(Output); to make sure that any output buffers are written immediately.
Using units in your program is not recommended. They will not help you very much and may cause problems when your program runs in the competition system. It is not possible to use units you have written yourself, since your source code must consist of a single file.

C and C++
Programs written in C or C++ are compiled with GCC, and linked with the standard maths library.
You can use scanf() to read from standard input, and printf() to write to standard output. After each move written to the output, your program should call fflush(stdout); to make sure that any output buffers are written immediately.

Java
Programs written in Java are compiled and run with Java JDK 1.3.1.
You can use the object System.in to read from standard input, and System.out to write to standard output. After each move written to the output, your program should call System.out.flush(); to make sure that any output buffers are written immediately.
It is possible to make more than one class for your program, but you will have to put the source for all classes in a single .java file (the compiler will produce multiple .class files anyway). When you do this, you should not declare your classes public, or the compiler will complain about it.
When submitting your Java program on the website, don't forget to enter the exact name of the main class of your program (the class which contains the main method).

Runtime environment

Computer: Pentium 200 Mhz
Memory: 32 MB total, your program can use only 10 MB
Operating system: Linux 2.4 (Debian 3.0)
Time limit: 120 seconds per game

Your program is allowed to use at most 120 seconds per game. We measure only the time that your own program spends to select a move, not the time that your opponent spends to select a move. If your program exceeds the time limit, it loses the game and receives a point for irregular loss of a game.

There is no time limit per move, only the time limit per game. So your program could use 115 seconds for the first move, but then it would have to do the rest of the game in 5 seconds. Obviously, it is better to spread the time evenly. Since the maximum number of moves per game is 100, you can use on average at least 1.2 seconds per move.
Remember that the CodeCup systems are only 200 Mhz. If your computer at home is much faster, you will have to be extra careful. For example, if your computer at home is 800 Mhz (4 times faster), then your program must use no more than 30 seconds per game on your own computer to still be fast enough on the CodeCup system.

To keep the contest fair, some things are not allowed:

  • Your program should not read or write files during a game. All input and output is done through standard input and output.
  • It is not allowed to make network connections of any sort.
  • System dependent tricks like starting other programs or creating extra processes are not allowed.
  • It is not possible to do calculations while it is your opponent's turn to make a move. That is, your program can not "think in the opponent's time".