Warlight AI Challenge 2 is finally here!

Getting started with the Warlight AI Challenge 2 is easy. You can download one of the starterbots from the list to the right in the language of your choice. The starterbots will mostly do only random moves, so it is up to you to make it as smart as possible!

Is the language you’re looking for not listed or do you want to start from scratch? No problem! Look at the Languages page for a list of all available languages to code your bot in.

All communication between your bot and the engine works through the standard input and output channels. In the section "Communicating with the game engine" you can find a detailed explanation regarding the protocol all bots should implement to communicate with the game server.

This is a simple example of a working bot. However, as the output for selecting the starting regions is not according to the required format, random regions will be picked by the engine. The bot will try to place 1 army on the first 5 regions of the map and then try to attack/transfer 1 army from the first 5 regions to the next neighboring region.

Communicating
with the game engine

Output from engine

Description

setup_map super_regions [-i -i ...]

The superregions are given, with their bonus armies reward, all separated by spaces. Odd numbers are superregion ids, even numbers are rewards.

setup_map regions [-i -i ...]

The regions are given, with their parent superregion, all separated by spaces. Odd numbers are the region ids, even numbers are the superregion ids.

setup_map neighbors [-i [-i,...] ...]

The connectivity of the regions are given, first is the region id. Then the neighboring regions' ids, separated by commas. Connectivity is only given in one way: 'region id' < 'neighbour id'.

setup_map wastelands [-i ...]

The regions ids of the regions that are wastelands are given. These are neutral regions with more than 2 armies on them.

setup_map opponent_starting_regions [-i ...]

All the regions your opponent has picked to start on, called after distribution of starting regions.

settings timebank -i

The maximum (and initial) amount of time in the timebank is given in ms.

settings time_per_move -i

The amount of time that is added to your timebank each time a move is requested in ms.

settings max_rounds -i

The maximum amount of rounds in this game. When this number is reached it's a draw.

settings your_bot -b

The name of your bot is given.

settings opponent_bot -b

The name of your opponent bot is given.

settings starting_armies -i

The amount of armies your bot can place on the map at the start of this round.

settings starting_regions [-i ...]

The complete list of starting regions your bot can pick from is given, before pick_starting_regions is called.

settings starting_pick_amount -i

The amount of regions your bot can pick from the above list.

update_map [-i -b -i ...]

Visible map for the bot is given like this: region id; player owning region; number of armies.

opponent_moves [‑m ...]

all the visible moves the opponent has done are given in consecutive order. -m can be any move and has the same format as in the table below

pick_starting_region -t [-i ...]

Starting regions to be chosen from are given, one region id is to be returned by your bot

go place_armies -t

Request for the bot to return his place armies moves.

go attack/transfer -t

Request for the bot to return his attack and/or transfer moves

Output from bot

Description

-i

A single id of a region, returned when the pick_starting_region request has been made.

[-b place_armies -i -i, ...]

Place armies moves, returned after request. With bot name, region id and number of armies.

[-b attack/transfer -i -i -i, ...]

Attack/transfer moves, returned after request. With bot name, source region, target region, number of armies.

No moves

return this if you want the bot to do nothing at all

Note: If the output for the preferred starting regions is not correct, the engine will pick random ones. If a bot's output for a move is not correct, the engine will do nothing and skip the move.

Each "-i" you see in the lines above can be any positive integer and each "-b" represents the name of the bot (as far as the engine is concerned) and can be either
player1
or
player2
. "-t" represents the time in milliseconds the bot has to respond to the engine, which is the amount that is left in the timebank. "-m" is a move and has a format as seen in the bot output table. Pay attention to the way the arguments are separated. This is mostly done by spaces, however "setup_map neighbors" and the bot's moves are comma separated.

By
example

Below you find a simplified example of how communication goes between the engine and a bot.

A simple map has been set up, and the bot names have been given to the bot, together with the round and timebank information. In this case we have 2 super regions: the first one has a bonus value of 2, the second one a bonus value of 5. Also, there are 5 regions: the first two are part of super region 1, the last three are part of super region 2. We can also see that regions 1, 2 and 3 are all connected to each other. Region 4 is only connected to region 1 and 5. Both region 3's neighbors were given already, so it's left out in the line, continuing with region 4. Finally we see that region 3 is a wasteland.

pick_starting_region 10000 2 4

Then the engine will ask for the bot to return his preferred starting regions. The engine will initially give a list that consists of one random region from each super region. Region 2 and region 4 are picked in this case. These are also always given at the start of the game, so both players know the complete list beforehand (see second to last line of previous code section). The bot must now return one region id; the amount you can pick is given, as can be seen in the last line of previous code section. The other bot receives the remaining list of regions that can be picked from and he gets to choose one region as well. This continues until the list is empty, but in this simplified case only twice. After this is done the actual game rounds will start. The following is a simplified example of what the engine output will look like each round:

The first line is pretty simple: the bot starts with 7 armies. That's 5 by default and 2 as a bonus because he completely owns super region 1 (continue reading to see why). In the second line we can see that player1 (our bot) has region 1 with 2 armies on it and region 2 with 4 armies on it, so super region 1 is fully owned by our bot. Region 3 is neutral (and a wasteland!) and region 4 is owned by the opponent. Keep in mind that the game has fog of war! So our bot cannot see what is on region 5, because he doesn't own a neighboring region of region 5. The opponent bot would get input like this, because he cannot see regions 2 and 3:

update_map 1 neutral 2 4 player2 5 5 neutral 2

Then the bot could respond to line 3 like this:

player1 place_armies 1 2, player1 place_armies 2 5

He will place 2 armies on region 1 and 5 armies on region 2. After the bot has responded to line 3, the engine will output line 4. Then our bot can respond like this:

player1 attack/transfer 1 2 3, player1 attack/transfer 2 3 8

First the bot will transfer 3 armies from region 1 to region 2. Both regions are owned by our bot, player1, so it's automatically a transfer. He moves the maximum amount, because 1 army must remain on region 1. Then the bot attacks the neutral region 3 with 8 armies. This is also the maximum amount, because transferred armies cannot be used in the same round.