Battlecode 2018 Gameplay Specifications v1.2.0

Welcome to Battlecode 2018 - Escape to Mars! This is a high-level overview of this year's game. It is highly recommended to read this entire document before you begin writing bots.

Plot

Very recently, the galaxy-renowned robot historian BCH-1337 published eighteen volumes covering the happenings of 28th century Earth. These volumes, occupying 11 petabytes of data, tell the story of every bullet fired in robot combat. He points out a discovery of startling ramifications: that all these bullets were fired on Earth. Both of the major political parties (the Research Engineering Division (Red) and the Branched Logistics Union of Electronicists (Blue)) quickly realized the implication that bullets could also be fired on other planets.

Now the race is on to depart the aging planet Earth, to colonize the next best planet, Mars. Indeed, BCH-1337 issued a prediction that no robot worth its silicon can doubt: that the Earth itself will be rendered utterly uninhabitable to robots in a short time. The story of armed conflict between Red and Blue, spanning two planets, is being written now!

Objective and Game Format

In Escape to Mars, players write code to control robots, factories, and rockets, collectively referred to as “units”.

The game is turn-based, and takes place over 1000 rounds, starting with round 1. A round consists of four turns: one from each team on each planet. During a player's turn, a single program runs player code to manipulate the units on that planet. The program is limited by computation time. (See “Timing Overview”.)

The victor in the game is the last alive - a team wins the game if the opponent has no units left. If, after 1000 rounds, neither team is eliminated, then the game is determined by the following tiebreakers, in this order:

  1. Highest combined value of all living units
  2. Most Karbonite
  3. Random number generator

An exception is made if both teams are completely destroyed by the flood on round 750. In this situation, the game will end after all units are destroyed, but the tiebreakers are evaluated as if before all units are destroyed. That is, a team’s combined living unit value, for the purposes of the first tiebreaker, will include units destroyed by the flood.

Escape to Mars is played in matches - sets of 3 games, each with 1000 rounds, where the first team to win 2 games wins the match.

Resources Overview

Each team has a single resource, Karbonite, available to use to perform particular game actions. Resources are shared across all units of a given team - any object that adds resources adds it to the player's resource pool immediately, and any object that uses resources deducts from that pool. Karbonite is used to create units.

Each team gains 10 Karbonite per round, decreased by 1 Karbonite per 40 Karbonite in their stockpile to a minimum of 0. Both teams start the game with 100 Karbonite. Karbonite can be mined from deposits on Earth and Mars.

Map Overview

In Escape to Mars, all game events occur in discrete 2 dimensional grids called maps. A map consists of a rectangular space of size ranging from 20x20 to 50x50. Each point has x and y coordinates representing its location. The bottom left corner (origin) always has the coordinates (0, 0). Coordinates increase to the North (up) and the East (right).

Every game has 2 maps, Earth and Mars. Each map defines locations of resources, passable terrain, and starting units. A square on the map is called passable if a unit can occupy that square when no other unit is occupying that square. All units occupy exactly 1 square, and each square is occupied by at most one unit.

Both planets have Karbonite deposits. Karbonite deposits can exist on any type of terrain, and are passable. Workers (See “Robots”) that are on or adjacent to the square can harvest up to a limited amount of Karbonite from the deposit each turn. Deposits have a limited amount of Karbonite, from which the amount of Karbonite collected is deducted. If a blueprint is laid or a rocket lands on a Karbonite deposit, the deposits at that location disappear from the map.

At any time, the player can obtain a complete map of terrain of either planet. This does NOT include the locations of allies and enemies - it only includes initial Karbonite deposit locations, impassable terrain, and the initial locations of units.

Each team starts with 1 to 3 Workers on Earth.

In order to prevent maps from favoring one player over another, Earth is always symmetric by either a rotation or reflection. Mars has no such restrictions.

Earth Overview

Earth consists of passable squares, passable Karbonite deposits, and impassable water squares. The number of Karbonite deposits on Earth is limited, and Earth will never replenish Karbonite over the course of the game. The starting amount of Karbonite on a square on Earth is in the range [0, 50].

At the start of round 750, Earth suffers a massive flood that destroys everything on the planet. (Note that if a player has not colonized Mars at this time, and their opponent has, the Earth-bound team immediately lose, as they will possess no more units.)

Mars Overview

Mars consists of passable squares, passable Karbonite deposits, and impassable rocky outcrops. The starting amount of Karbonite on a square on Mars is in the range [0, 50]. Mars is also frequently bombarded by asteroids, which leave behind comparatively rich Karbonite deposits. Mars is the only planet that has a renewable amount of Karbonite.

At any time, at most a single small asteroid strikes the surface at a single square. Asteroids carry amounts of Karbonite in the range [20, 200]. A Karbonite deposit forms at the location of the asteroid strike. If the location is occupied by a unit, the Karbonite settles neatly underneath the unit.

The complete asteroid weather pattern is known to both teams at the start of the game.

Units Overview

There are two types of units: robots and structures. Robots are mobile units that fight, move to adjacent squares, and collect resources from the map. There are two types of structures: rockets and factories. Rockets can transport robots to Mars. Factories are static units that produce robots. The game actions that units can take are determined by their type.

Unlike previous years, units themselves do not run any code. Rather, a player program on each planet runs code to manipulate the units on that planet. Each program has a time limit that limits the amount of computation it has, and each unit has cooldowns that limit the rate of actions it can perform (See “Timing Overview”).

When a robot is spawned, it is assigned a unique integer ID. When the health of a unit is reduced to 0, the unit is immediately removed from the game.

Robots

There are 5 types of robots in Escape to Mars. All robots have the ability to move through passable terrain on their planet. Robots can take further game actions depending on their type. See “Robot Specifics” for greater details.

Active abilities have their own cooldowns and ranges, in addition to those of normal attacks. All robots start with an ability cooldown of 10. Ranges are given in squared units. For example, a robot with attack range 16 can hit a target 4 tiles to the right.

(*) - indicates advanced mechanic, see Robot Specifics.

Robot

Worker

Knight

Ranger

Mage

Healer

Factory Cost

50 (*60 if replicated)

40

40

40

40

Max health

100

250

200

80

100

Damage

0

80

30

60 (*damage is also dealt to adjacent squares)

-10 (*Healers must heal() to deal “attack”)

Attack range

0

2

50 (*cannot attack within range 10)

30

30

Vision range

50

50

70

30

50

Movement Cooldown

20

15

30

20

25

Attack Cooldown

100

20

20

20

10

Passive Abilities*

None :(

Defense

Far-sighted

Explosive shot

Positively Charged

Active Abilities*

Replicate

Javelin

Snipe

Blink

Overcharge

Active Ability Cooldown*

500

100

200

250

100

Active Ability Range*

2

10

Infinity

8

30

Left to right: Worker, Knight, Ranger, Healer, Mage.

Structures

There are 2 types of structures: Rockets and Factories.

To spawn a structure in the game, a Worker must blueprint the structure on an occupiable square adjacent to the Worker. This action deducts the cost of the blueprint from the team's resource pool. The blueprint starts with 1/4 the maximum health of the structure. The Worker then builds the blueprint, increasing the blueprint’s health by a fixed amount each turn until it reaches its maximum health. Then the blueprint becomes a structure, and the structure can be used.

Both structures have a garrison, which is a holding space for up to 8 robots. (Research may increase the capacity of the garrison.) Robots are loaded into a rocket’s garrison by the rocket, which requires the robots to be ready to move. Robots are loaded into a Factory’s garrison automatically after the Factory has produced the robot. Rockets and factories both unload a robot from their garrison by placing the robot in an occupiable square adjacent to the structure. Loading and unloaded are both treated like a robot’s standard move action.

Structures cannot be blueprinted or built on Mars.

Factory.

Research Overview

Research upgrades and unlocks capabilities of different units. Each upgrade takes a fixed number of rounds to complete. Only one upgrade can be researched at any given time.

Research is queued to a team production queue, and is automatically applied to all current and future units owned by that team when complete. The queue can be reset at any time. If the current upgrade is cancelled and started again, the number of rounds left resets to its original amount. This queue and the effects of all completed upgrades are shared between planets.

Research upgrades take the form of branches - performing a research upgrade makes it possible to research further related upgrades, which are typically more expensive. See “Research Specifics” for the specifics on research.

Communications and Vision

Communication is implemented by team-shared integer arrays across time and space. Each team has 2 such arrays of length 100, one for each planet. A player can write to the team-shared array of the planet that it is currently on. If the player reads data from the other planet, it reads whatever value was in the array at the end of the round 50 rounds before the round of the attempt. This is due to physical limitations of how long it takes information to travel between planets.

The player gets shared vision of the map of the planet it is on. Thus the player can sense the health and location of any units on that terrain, that lie within the sensing radius of one of its robots. Visibility updates at the end of a player’s turn.

The player can globally (even across planets) sense whether a given square is on the map, and whether a given square contains passable terrain. Units in space, the state of research, and the team’s Karbonite are also shared across planets.

Note: If an isolated Factory unloads a unit in an adjacent square, since the Factory only has vision range 2, the unit cannot interact with most nearby squares until the following round.

Robot Specifics

Workers

The foundation of your civilization is Workers. In addition to movement, Workers can take one of the following game actions each turn:

In addition, Workers have an active ability that work depending on its ability cooldown, just like other units with active abilities.

Knights

Knights are a melee unit produced at factories. They are somewhat lackluster on their own, but are tanky and resistant to attacks.

Rangers

Rangers are a ranged unit produced at factories. They are a good all-around combat unit, able to attack from a medium distance, deal medium damage, and have moderate health. They can perform the following game actions:

Mages

Mages are a specialist ranged unit produced at factories. They are particularly adept at dealing damage to large areas, but are extremely fragile.


Healers

Healers are a support unit that help an army stay fighting for as long as possible. They cannot directly attack other units, but can instead heal a given unit up to its maximum health. This heal functions similarly to a regular attack, targeting a square within its “attack” range, and triggering the robot’s “attack” cooldown.

Structure Specifics

Rockets

(Requires: Rocketry)

Unit

Rocket

Cost

150

Max health

200

Vision range

2

The only unit that can move between planets is a Rocket. While robots are in a rocket’s garrison, they cannot perform any actions. The rocket has two main abilities:

There is a time delay for a rocket to travel between planets. While the rocket is traveling, it is considered to be in space, and the units it carries are considered to be in a garrison. The duration of flight is determined by a sinusoidal function y=a*sin(bx)+c where the x-axis is the round number of takeoff and the y-axis is the flight duration. This function represents the variability in the time to get from Earth to Mars or back during different times of their orbit. The time delay is guaranteed to be in the range [50, 200], inclusive.

The complete orbit pattern is available from the start. The rockets currently in space are visible at all times to the team the rockets belong to.

Rockets are one-use only, meaning they can only successfully launch once in their lifetime. A rocket is only removed from the map once it has lost all its health, or disintegrated. If a rocket is destroyed, all the robots inside the rocket are destroyed with it.

Factories

Unit

Factory

Cost

200

Max health

300

Vision range

2

Factories can perform game actions, but cannot move. They produce the robots used to fight the enemy. A Factory does not have a queue, and can produce a single robot at a time. To produce a robot, the player requests the robot type from the Factory, paying the resource cost upfront. The Factory then takes 15 rounds to build the robot. Finally, the robot automatically spawns in the garrison of the Factory.

Research Specifics

Each unit (except the Factory) has an associated research branch. Completing an upgrade in a research branch unlocks the upgrade at the next level in the branch. Some buffs are passive, affecting units on your team permanently with alterations to stats. Other upgrades are active, unlocking abilities of units.

The Worker’s Tree

Level

Cost (Rounds)

Description

1

25

Gimme some of that Black Stuff: Workers may harvest an additional 1 Karbonite from a deposit at a time.

2

75

Time is of the Essence: Workers add 1 more health when repairing or constructing a building.

3

75

Time is of the Essence II: Workers add another 1 more health (2 more total) when repairing or constructing a building.

4

75

Time is of the Essence III: Workers add another 3 more health (5 more total) when repairing or constructing a building.

The Knight’s Tree

Level

Cost (Rounds)

Description

1

25

Armor: Decreases the strength of an attack on a Knight by an additional 5HP.

2

75

Even More Armor: Decreases the strength of an attack on a Knight by another 5HP (10HP more total).

3

100

Javelin: Unlocks “Javelin” for Knights.

The Ranger’s Tree

Level

Cost (Rounds)

Description

1

25

Get in Fast: Decreases a Ranger’s movement cooldown by 5.

2

100

Scopes: Increases a Ranger’s vision range by 30.

3

200

Snipe: Unlocks "Snipe" for Rangers.

The Mage’s Tree

Level

Cost (Rounds)

Description

1

25

Glass Cannon: Increases standard attack damage by 15HP.

2

75

Glass Cannon II: Increases standard attack damage by another 15HP (30HP more total).

3

100

Glass Cannon III: Increases standard attack damage by another 15HP (45HP more total).

4

75

Blink: Unlocks “Blink” for Mages.

The Healer’s Tree

Level

Cost (Rounds)

Description

1

25

Spirit Water: Increases Healer’s healing ability by 2HP.

2

100

Spirit Water II: Increases Healer’s healing ability by an another 5HP (7HP more total).

3

100

Overcharge: Unlocks “Overcharge” for Healers.

The Rocket’s Tree  

Level

Cost (Rounds)

Description

1

50

Rocketry: Unlocks rocket technology. Workers can now blueprint and build rockets.

2

100

Rocket Boosters: Reduces rocket travel time by 20 rounds compared to the travel time determined by the orbit of the planets.

3

100

Increased Capacity: Allows rockets to garrison 4 more units per rocket.

Timing Overview

We’re using time instead of bytecode this year to limit player programs. Each planet for each player gets an initial pool of 10 seconds, and after each round receives an additional 50ms. Timing limits are not dependent on the number of bots you control.  When a planet of yours exhausts its timing pool, your bot will simply do nothing.

Machine Specs

Scrimmage and tournament matches are run on an n1-standard Google Cloud instance, about 2.5 GHz equivalent.

Cooldowns and Heat

The smallest unit of time in Battlecode is 1 turn. However, not every game action can be performed every turn. In these cases, game actions have a cooldown - a number of turns which one must wait after using a game action to use that action again. Specifically, robots have a movement cooldown as well as an attack cooldown, each of which correspond to an internal heat. Robots can move only when their movement heat is less than 10, and they can only attack when their attack heat is less than 10. Both heats decrement by 10 at the start of every round, to a minimum of 0. When a robot moves, its movement heat is incremented by its movement cooldown, and likewise for when a robot attacks.

Advanced Details

Location Representation

Because there are multiple planets in the world, and units are not necessarily on the map at all times, locations are represented in a more abstract way than in past years. There are two object classes which are used to represent locations: MapLocation and Location.

A MapLocation represents a concrete space on a given planet. It has x and y coordinates, in addition to the planet itself, as attributes.

A Location represents the location of a robot. Whenever a robot is on a map, this object maps directly to a MapLocation object. However, this is not always the case! A Location may also represent a point in space (as in the case of a rocket traveling to Mars), or a space in a structure’s garrison. Methods can be used to determine, more concretely, what a Location represents.

Glossary

Disclaimer: The game specs are subject to change based on balancing needs and executive decisions.