API Details
API Details - V1 (Legacy)
API Overview
To provide the most uniform API across all languages, the input to the user code of the current map state,
and the output from the user code of the players instructions are passed as a comma separated string of commands,
passed through the stdin
and
stdout
functions.
Coordinates
The Arena is a 16 x 16
grid of squares and tiles – The X
Axis is the horizontal axis, with the left most square starting at 1
, with the right most square ending at 16
. The Y
Axis is the vertical axis, with the bottom most square starting at 1
, with the top most square ending at 16
.
Within the API coordinates must always be passed in the format of X:Y
–
Where X
is an unsigned integer value from 1 to 16, the colon
:
separates the X and Y values, and the
Y
is an unsigned integer value from 1 to 16.
Bot Input - STDIN
At the start of each turn the bot will receive an input on stdin
, which the bot should interpret.
The input will identify the current placement of all alive Friendly and Enemy bots within the arena at the start of the turn, and their current health within an integer form ranging from 1
to 100
.
The input will be provided within a comma ,
separated format, which is further separated by hyphens –
into three sub elements.
-
Friendly / Enemy – The first sub element will be a single uppercase
F
orE
to respectively state if the robot is a friendly or enemy bot. Friendly bots will be ordered first within the input. - Coordinates – The second sub element will be a set of coordinates for the robot, within the coordinate format defined above.
-
Health – The third and final sub element is the robot health, which is an unsigned integer ranging from
1
to100
As an example F-12:6-100,F-13:12-20,E-9:5-100,E-9:12-90
would be a valid input that states the current arena state is:
- Friendly at x12 y6 with health 100
- Friendly at x13 y12 with health 20
- Enemy at x9 y5 with health 100
- Enemy at x9 y12 with health 90
Bot Output - STDOUT
The game will await for the user code to complete its execution, and the user code should return a string of instructions via stdout
, the instructions must define what interactions the player wishes to perform on the friendly bots during this turn.
The output must be provided within a comma ,
separated format, which is further separated by hyphens -
into two or three sub elements conditional on the instruction requested.
These sub-elements are:
- Coordinates - The first sub element will be a set of coordinates for the friendly robot, which this instruction relates to. The coordinates are the placement of the bot at the start of the turn before any actions during the turn, that is exactly as provided in the stdin input.
-
Action – The second element will define the action that is to take place, with the possible actions defined below, and detailed further within the game rules.
- Attack - Encoded as
A
(Requires a direction element) - Move - Encoded as
M
(Requires a direction element) - Defend - Encoded as
D
- Self Destruct - Encoded as
S
- Attack - Encoded as
-
Direction – Some actions (such as move or attack) are directional, therefore where a direction is required the third element will be included to provide this detail, the optional directions are:
- North / Up – Encoded as
N
orU
- East / Right – Encoded as
E
orR
- South / Down – Encoded as
S
orD
- West / Left – Encoded as
W
orL
- North / Up – Encoded as
As an example 12:7-A-S,10:5-M-E,10:12-D
would be a valid output that requests:
- Friendly at x12 y7 should attack, in a south direction, therefore x12 y6
- Friendly at x10 y5 should move, in an east direction, tehrfore x11 y5
- Friendly at x10 y12 should defend