This is a league based challenge.

For this challenge, multiple versions of the same game are available. Once you have proven your skills on this first version, you will access a higher league and extra rules will be unlocked.

  The Goal

To win the match, you will have to manage your troops to defeat all the enemy soldiers.

  Rules

TotalBotWar is a 1 vs 1, pseudo-real-time, multi-action game, partially inspired in the real-time battles of the Total War games series (https://www.totalwar.com/). In our game, both players start with the same number of military units and they have to use strategies to defeat the other player destroying the most of his/her units. The winner is the player who first destroys all the opponent’s units or the one with more units alive on the battlefield when the maximum number of turns is reached. The maximum number of turns is 400.


The battlefield has 1920 columns and 1080 rows.


In each turn, the player can perform an action for each own unit. To play actions for a death unit is not illegal, but it has not to effect. An action consists of moving a unit a particular number of pixels in both directions. The movement can take several turns to be completed. If in a turn, the player does not indicate an action for a particular unit, it continues moving following the previous action performed on this unit.


An action has the following format: UnitID DeltaX DeltaY, where:


  • Unit ID is the unique ID of the unit.
  • DeltaX is the number of pixels we want to move the troop on the X axis.
  • DeltaY  is the number of pixels we want to move the troop on the Y axis.


The final target coordinates of the unit is calculated as the sum of the actual coordinates of the unit and the shift specified at [DeltaX, DeltaY].


For instance, some actions that can be played are:


  • 1 100 50: Unit 1 will move 100 pixels to the right and 50 to the top of the battlefield.
  • 3 -100 -10: Unit 3 will move 100 pixels to the left and 10 to the bottom of the battlefield.
  • 5  0  0: Unit 5 will stop.


Note that DeltaX and DeltaY are not the global coordinates where we want to move the unit. Unlike, they are how many pixels we want to move the unit concerning the actual coordinates of the unit.


Also note that it is assumed that the player army is always the one located in the bottom area of the battlefield whereas the opponent’s army is the one located on top one. 


In each turn, the player can perform more than one action. They must be separated by a semicolon. For instance, to perform the three previously showed actions in the same turn, the player must provide the following multi-action: “1 100 50; 3 -100 -10; 5 0 0”.


The input from the system provides information about the player’s units and opponent’s ones. First, the system provides the total number of units for each player’s unit. Then, the system provides the following information for each unit, first for player’s ones and after the opponent’s ones:


  • ID: Unique id of the unit.

  • Location: X, Y coordinates indicating the actual position of the unit on the battlefield.
  • Direction: A number indicating where the unit is looking for. It can be NORTHWEST (0), NORTH (1), NORTHEAST (2), EAST (3), SOUTHEAST (4), SOUTH (5), SOUTHWEST (6) and WEST (7).
  • Life: Amount of life points. The unit is death when its life reaches 0.
  • Type: Unit type. It can be: soldiers with swords (0), spearman (1), cavalry (2) or archers (3).
  • Moving: The unit is not moving (1) or it is moving (0).
  • Target: Location where the unit is going to stop.

        

For opponent’s units, the system does not provide the target. 


Note that both players have always the same number of units. 


A unit can be idle (not doing anything), moving, fighting or death. Archers can also be throwing arrows.


A unit continues moving until it collides with an opponent or the limit of the battlefield is reached. On the first case, both stop and start to fight one versus the other. The result of the fight depends on the stats of each unit. When a unit gets 0 life points, it is considered as death. On the second case, the unit stops.


Unit combat follows a “Rock paper scissors” scheme, where the sword beats the spear, the spear beats the horse and the horse beats the sword. The archer attacks units that are at a distance less than 450 points from their position, but are very weak at hand-to-hand combat. Friend units can also be damaged by friend arrows if they are fighting versus an opponent unit that it is receiving arrows. Archers always attack to the opponent unit with the smallest UnitId inside the attacking range.


The game is divided into three leagues, adding complexity when the leagues advance. 


The first league has just four units: a swordsman, a spearman, an archer and a cavalry. 


The second one has 9 different units. The first 9 turns are the draft, where the player selects, at each turn, one unit to be used and the absolute position to locate it in the battlefield. There is no restrictions in the army configuration. For instance, the player can select 9 archer units if he/she wants. To tell the system which unit we want to use, an action can be used with the following format: 


“TYPE X Y”


where, TYPE is the type of unit to be used: Soldiers with swords (0), spearman (1), cavalry (2) or archers (3), and X and Y are the absolute coordinates where the unit will be deployed on the battlefield.


Two units can not be located at the same area. If the player try to locate an unit in an already occupied area, the system try to locate it in the neighbour area of the existing one.


The third league introduces the figure of the general and admit 30 units. The first 30 turns are for the draft. A general is a special unit that can be used to improve the stats (by 1.25) of the units close to it (close means into a radius of 300 pixels). But, if the general is dead, all the units of the army will be decreased their stats (by 0.75). The general is always the first unit specified in the draft. 


Each unit has associated a stat vector which models its behaviour. The components of the stats vector are: life, defence, attack, charge resistance, charge force, speed and resistance from far attacks. In addition, the archers have two more stats: how far they can throw arrows and how damage they do with these arrows.


By default, this stats are as follows for each unit type:



Sword

Spears

Calvary

Archer

Life

250

250

200

100

Defence

10

20

12

5

Attack

20

15

12

10

Charge resistance

25

125

15

0

Charge force

5

10

100

5

Speed

15

10

40

15

Resistance from far attacks

10

30

30

10

Arrow distance

-

-

-

450

Arrow damage

-

-

-

20

  Game Input

Input for one game turn
First input: 1 integer numberUnits (how many troops are on each side at the beginning).
Second input: 1 integer allyUnitId (the unit identifier).
Third input: 1 integer allyUnitPosX (the unit's X position).
Fourth input: 1 integer allyUnitPosY (the unit's Y position).
Fifth input: 1 integer allyUnitDirection (where direction the unit is looking at).
Sixth input: 1 integer allyUnitLife (the unit's life).
Seventh input: 1 integer allyUnitType (which kind of troop is this unit).
Eight input: 1 integer allyUnitMoving (indicates if the unit is moving (1) or not (0)).
Nineth input: 1 integer allyUnitFinalXPosition (where the unit is going in the X axis).
Tenth input: 1 integer allyUnitFinalYPosition (where the unit is going in the Y axis).
Eleventh input: 1 integer enemyUnitId (the unit identifier).
Twelfth input: 1 integer enemyUnitPosX (the unit's X position).
Thirteenth input: 1 integer enemyUnitPosY (the unit's Y position).
Fourteenth input: 1 integer enemyUnitDirection (where direction the unit is looking at).
Fifteenth input: 1 integer enemyUnitLife (the unit's life).
Sixteenth input: 1 integer enemyUnitType (which kind of troop is this unit).
Seventeenth input: 1 integer enemyUnitMoving (indicates if the unit is moving (1) or not (0)).
Output for one game turn
Line 1: 3 space separated integers id, movement in X axis and movement in Y axis.

You can send more than one order (without limit) in one turn separating them with ";", for example "2 0 300 ; 4 100 0".

If you don't want to move any troops, the first integer should be 0, for example "0 0 0" or "0 200 50".