Skip to main content

Action Space

Each step, the agent sends an AgentAction containing a list of Command messages.

Command Structure

message Command {
ActionType action = 1;
uint32 actor_id = 2; // Subject actor
uint32 target_actor_id = 3; // Target actor
int32 target_x = 4; // Target cell X
int32 target_y = 5; // Target cell Y
string item_type = 6; // Item to build/train
bool queued = 7; // Queue after current activity
}

Action Types

IDActionParametersDescription
0NO_OPDo nothing
1MOVEactor_id, target_x/y, queuedMove unit to cell
2ATTACK_MOVEactor_id, target_x/y, queuedMove and attack enemies along the way
3ATTACKactor_id, target_actor_idAttack a specific target
4STOPactor_idStop current activity
5HARVESTactor_id, target_x/ySend harvester to resource field
6BUILDitem_typeStart building production
7TRAINitem_typeStart unit production
8DEPLOYactor_idDeploy MCV / unpack
9SELLactor_idSell building for refund
10REPAIRactor_idToggle building repair
11PLACE_BUILDINGtarget_x/yPlace a completed building
12CANCEL_PRODUCTIONitem_typeCancel queued production
13SET_RALLY_POINTactor_id, target_x/ySet production rally point
14GUARDactor_id, target_actor_idGuard another unit/building
15SET_STANCEactor_id, target_xSet stance (0–3)
16ENTER_TRANSPORTactor_id, target_actor_idLoad into transport
17UNLOADactor_idUnload all passengers
18POWER_DOWNactor_idToggle building power
19SET_PRIMARYactor_idSet primary production building
20SURRENDERResign the game

Python Usage

from openra_env.models import ActionType, CommandModel, OpenRAAction

# Move a unit
move_cmd = CommandModel(
action=ActionType.MOVE,
actor_id=unit.actor_id,
target_x=50,
target_y=30,
)

# Train infantry
train_cmd = CommandModel(
action=ActionType.TRAIN,
item_type="e1",
)

# Build a power plant
build_cmd = CommandModel(
action=ActionType.BUILD,
item_type="powr",
)

# Send multiple commands in one step
action = OpenRAAction(commands=[move_cmd, train_cmd, build_cmd])
obs = await env.step(action)

Stance Values

ValueNameBehavior
0HoldFireNever auto-attack
1ReturnFireOnly attack if attacked first
2DefendAttack enemies that enter range
3AttackAnythingAggressively pursue all enemies

Tips

  • Check available_production before issuing BUILD or TRAIN commands — the server validates availability.
  • Building placement requires a completed building in the production queue. Use PLACE_BUILDING with cell coordinates.
  • Queue commands with queued=true to chain actions without interrupting the current activity.
  • Faction matters: Allied barracks is tent, Soviet is barr. Check available_production to determine your faction's buildings.