Skip to content
Santi Ontañón Villar edited this page Feb 19, 2018 · 6 revisions

Basics

The game map is a rectangular grid, of arbitrary size. Recommended sizes are between 4x4 to 16x16. Larger maps than that might be too complex for the built-in AIs to handle, but in principle, you could define a map as large as needed (and some papers have used maps as large as 128x128).

Each cell in the map can be an empty square or a wall. Walls cannot be destroyed in any way.

Many parts of the code are hardcoded to support only 2 player games.

Each player controls a set of units, and can create more by spending resources. There is only one kind of resource in microRTS, that can be considered as money.

There are several basic types of units: resources, buildings and moving units (the exact set of unit types available in a given game is specified in the UnitTypeTable class). Units have the following attributes:

  • position: the x,y coordinate
  • hit points: an integer number of hit points, when it reaches 0, the unit disappears
  • resources: some units can carry resources. When resources are carried back to a "base", the player owning that base can use those resources for creating new units.

In case a partially-observable game is run, unit types also have a "sightRadius" variable that controls how far can each unit see. Players can only see what their units see.

Actions

Units can perform the following actions:

  • None: the unit remains still for a certain number of cycles (specified as a parameter).
  • Move: move one cell up, left, down or right. Parameters:
    • Direction: up, left, down or right.
  • Attack_Location: attack a unit within range. The result is that the target unit loses hit points. Parameters:
    • x,y coordinates of the attack location
  • Harvest: collect resources form a resource source. Parameters:
    • Direction: up, left, down or right. (direction of where the resource source is)
  • Return: deposit the resources the unit is carrying into a base. Parameters:
    • Direction: up, left, down or right. (direction of where the base is)
  • Produce: create a new unit. Parameters:
    • Direction: up, left, down, right. (direction where the new unit will appear)
    • Type: Base, Barracks, Worker, Light, Heavy. (the type of unit to produce)

Each different unit type can execute only a subset of these actions.

Each unit can only execute one action at a time. When an action is issued to a unit, the action is carried out until the end, and cannot be canceled. All units need to be executing an action at all times. When an action finishes, the AI is responsible for issuing another action, otherwise a game cycle cannot be simulated. If the AI doesn't want a unit to execute an action in a particular game cycle, then it has to issue the None action.

The Attack_Location action damages the target unit in the very last cycle of the attack. So, if a unit starts attacking, and the target unit moves away before the attack is over, there will be no damage (since the target unit is not there any more).

If two units try to move into the same cell, at the same time (moves are effective in the very last time step of the move action), this is considered a "conflict" and needs to be resolved. When instantiating the UnitTypeTable class (that determines many aspects of the game rules), you can set different conflict resolution strategies:

  • MOVE_CONFLICT_RESOLUTION_CANCEL_BOTH: both actions are canceled (replaced by None)
  • MOVE_CONFLICT_RESOLUTION_CANCEL_RANDOM: one of the two actions is canceled at random (Important note:: this makes the game non-deterministic!)
  • MOVE_CONFLICT_RESOLUTION_CANCEL_ALTERNATING: one of the two actions is canceled following a deterministic alternating policy (which keeps the game deterministic).

A class called BranchingFactorCalculator in the ai package can be used to calculate the exact branching factor (number of player actions that a player can execute) in a given state.

Unit Types

Unit types can be defined through the UnitType class. However, I recommend using the predefined set of units (defined in the UnitTypeTable class as the VERSION_ORIGINAL or VERSION_ORIGINAL_FINETUNED versions, and specially VERSION_ORIGINAL_FINETUNED, which is better balanced), since this allows for easy comparison of results among different publications. The default units (in VERSION_ORIGINAL) are:

  • Resource: the source of resources, doesn't belong to any player, and cannot execute any actions. It only has one parameter: resources left. When the number of resources left reaches 0, the unit disappears.
  • Base: have 10 hit points, cost 10 resources to build, and take 250 time units to be built. They can only execute one action, produce. And they can only produce Workers.
  • Barracks: have 4 hit points, cost 5 resources to build, and take 200 time units to be built. They can only execute one action, produce. And they can produce Light unit, Heavy units or Ranged units.
  • Worker: have 1 hit point, cost 1 resource to build, and take 50 time units to be built. Workers can carry one resource. They can move (10 units of time per move), attack (5 units of time per attack, and cause 1 damage), and harvest (20 units of time), and return (10 units of time). Workers can only attack, harvest or return to units that are in the cell immediately up, left, right or down.
  • Light: have 4 hit points, cost 2 resources to build, and take 80 time units to be built. Light units can move (8 units of time per move) and attack (5 units of time per attack, and cause 2 damage).
  • Heavy: have 4 hit points, cost 2 resources to build, and take 120 time units to be built. Heavy units can move (12 units of time per move) and attack (5 units of time per attack, and cause 4 damage).
  • Ranged: have 1 hit points, cost 2 resources to build, and take 100 time units to be built. Ranged units can move (12 units of time per move) and attack location (5 units of time per attack, and cause 1 damage) that is at distance 3 or less.

An alternative definition for these units (for a more balanced gameplay) can be used by using VERSION_ORIGINAL_FINETUNED in UnitTypeTable.

Clone this wiki locally