The complete API reference

The Standard Library

class Direction(enum)
North, South, East, West
opposite: Direction
to_coords: Coords

Convert to a coordinate pair like (1, 0) or (0, -1)

rotate_cw: Direction
rotate_ccw: Direction
class Coords
x: int
y: int
__init__(x: int, y: int)
distance_to(other: Coords) → float
walking_distance_to(other: Coords) → int
direction_to(other: Coords)Direction
__add__(other: Union[Coords, Direction])Coords
__sub__(other: Union[Coords, Direction])Coords
__mul__(other: int)Coords

Languages without operator overloading have similarly named functions: add, sub, mul.

class Team(enum)
Red, Blue
opposite: Team
class ObjType(enum)
Unit, Terrain
class Obj

Anything that can exist within a grid tile.

id: str
coords: Coords
obj_type: ObjType
team: Optional[Team]
health: Optional[int]

These are null if this object is not a unit.

class State

Root class for all game state.

turn: int
our_team: Team
other_team: Team
obj_by_id(id) → Optional[Obj]
ids_by_team(team) → List[str]
objs_by_team(team) → List[Obj]
id_by_coords(coords) → Optional[str]
obj_by_coords(coords) → Optional[Obj]
class ActionType(enum)

You should never have to worry about this class if you use the Action static methods.

Attack, Move
class Action
__init__(type: ActionType, direction: Direction)
static move(direction: Direction)Action
static attack(direction: Direction)Action
class Debug

A class for debugging through the webapp GUI. Available through the global debug variable.

log(key: str, val: Any) → None

Calling this function with a key value pair will create a robot-specific information table. You can inspect it by selecting robots in the map.

inspect(unit: Obj) → None

Highlight a unit in the map. Useful for locating a specific robot (whether ally or enemy).

MAP_SIZE: int

User-defined functions

robot(state: State, unit: Obj)Action

The main robot function. You must define it.

Parameters
  • state (State) – The State instance for this battle.

  • unit (Obj) – The Obj instance for this specific unit.

Returns

An action, obtained using one of the static methods of the Action class.

init_turn(state: State) → None

An optional initialization function called at the beginning of every turn. Use it to initialize global state.

Python Details

  • Stdlib source here.

  • You can import most of the Python standard library modules.

  • Install the robot-rumble-stdlib package to get autocompletion for your robot. Just put from rumblelib import * at the top of your file. example

Javascript Details

  • Stdlib source here. Every identifier is in camelCase.

  • Javascript “enums” are implemented using the method proposed by 2ality. In a nutshell, this method leverages static class members to create a Java-like Enum superclass. In practice, the result should feel no different from the Python enums.

  • console.log is the only available console method.

  • You cannot use import/require.

  • Lodash is available under the global _ variable. Every module is available but String.

  • There isn’t yet a package with typescript types on npm, but in the meantime you can use this great boilerplate.

  • Implemented with the QuickJS project.