The Challenge
Find out the details of your mission!
Download SDK
Getting started by downloading the Java SDK.
Read the Tutorial
The tutorial will give you an overview on all SDK tools. Try to implement and run your first AI.
Upload your AI
Happy about your first version? Get into the game by uploading it.
Lookup your Rank
Now it's time to compare your AI against the others.

Development Tutorial

First Run of your AI

  1. Now it is time to let your AI run against the local opponents. Run the Run CodeBattle configuration to start the game engine.
    For Eclipse: Right click on Run CodeBattle.launch and click on Run As > Run CodeBattle to start the game engine.
  2. The results of the battle are saved in the /temp/ directory of the SDK installation path. There you will find a recoding.json file which you can use to replay the game on our web player.
  3. To debug your AI implementation use the Configure CodeBattle to run the game engine in configuration mode. Check the debug check box for the client jar file you want to start in debug mode (by default player1 runs with your implementation). When you have started the game you will be prompted to connect with your client. To connect your client you have to run the launch configuration Debug Client in debug mode.
    Before you connect you should set a breakpoint within your implementation so the client does not immediately start processing.
    Should your AI implementation behave differently when running in debug mode your client probably violates the Java SecurityManager policy (see also the chapter on Constraints), which is deactivated in the debug mode. You will find the errors in the log files in the /temp/ directory of the CodeBattle SDK.


Your starting implementation class is ai.implementation.MyCodeBattleClient. This class already has a rudimentary implementation of the AI to give you an overview of the CodeBattle API. For each game round the method processRound of your client is called by the game engine with the current ClientRoundState roundState as parameter.
Before you start coding please read the notes at the top of the method MyCodeBattleClient.processRound.
In the next section the classes of the CodeBattle API are explained. You will also find all details about all methods and class fields integrated in Javadoc.

Class ClientRoundState
This is the main class that comes with all the information about the current round. This class provides the information about all fields on the map, your own base, your own units and the current round number. Class Field
This class contains all the information about a map field. Class Unit
This class contains all the information about a unit. A unit can be a WARRIOR, a COLLECTOR or an ARCHER. Class Position
Contains x and y position on the field map. Class Base
Contains x and y position on the field map. Class GameConfiguration
This class contains some static information about the current game battle: your own player name, unit costs and the damage warrior, collector and archer can do, the maximum number of resources a unit can carry, the initial amount of health of each unit type and the number of rounds that will be played for this battle. You can retrieve the instance of the class GameConfiguration by calling this.getGameConfiguration() in your MyCodeBattleClient class.
You do not have to consider that these values will change during the CodeBattle. The GameConfiguration will remain constant for all battles played this year.


System Constraints: Your client is executed in a separate process that has the following constraints:
If your client exceeds the 500 ms round time limit, it will be restarted with force. If the client keeps violating the round time limit for 5 rounds in one single game, it will be disabled for the rest of the game.
Note that it is forbidden to waste time in an exaggerated manner. Clients which purposely perform useless operations (e.g. sleep()) during their computation time may be disqualified.
The binary size of your client (including third-party libraries that you use) must not exceed 10.240 kB. If your client exceeds 10.240 kB the upload of the client will fail.
Java Security Constraints: The Security Manager prevents your client from: Game Play Constraints:

Configuration of the Battle Engine

When you start the configuration with Configure CodeBattle you can do the following configuration: