跳到主要内容

动作空间

每一步,智能体发送一个包含 Command 消息列表的 AgentAction

命令结构

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
}

动作类型

IDAction参数说明
0NO_OP无操作
1MOVEactor_id, target_x/y, queued移动单位至指定格
2ATTACK_MOVEactor_id, target_x/y, queued移动并沿途攻击敌军
3ATTACKactor_id, target_actor_id攻击指定目标
4STOPactor_id停止当前活动
5HARVESTactor_id, target_x/y派遣矿车前往资源区
6BUILDitem_type开始建筑生产
7TRAINitem_type开始训练单位
8DEPLOYactor_id展开 MCV / 解包
9SELLactor_id出售建筑获取退款
10REPAIRactor_id切换建筑维修状态
11PLACE_BUILDINGtarget_x/y放置已完成的建筑
12CANCEL_PRODUCTIONitem_type取消排队中的生产
13SET_RALLY_POINTactor_id, target_x/y设置生产集结点
14GUARDactor_id, target_actor_id护卫另一个单位/建筑
15SET_STANCEactor_id, target_x设置姿态(0–3)
16ENTER_TRANSPORTactor_id, target_actor_id登入运输载具
17UNLOADactor_id卸下所有乘员
18POWER_DOWNactor_id切换建筑电力开关
19SET_PRIMARYactor_id设为主要生产建筑
20SURRENDER投降认输

Python 用法

from openra_env.models import ActionType, CommandModel, OpenRAAction

# 移动单位
move_cmd = CommandModel(
action=ActionType.MOVE,
actor_id=unit.actor_id,
target_x=50,
target_y=30,
)

# 训练步兵
train_cmd = CommandModel(
action=ActionType.TRAIN,
item_type="e1",
)

# 建造发电厂
build_cmd = CommandModel(
action=ActionType.BUILD,
item_type="powr",
)

# 在一步中发送多条命令
action = OpenRAAction(commands=[move_cmd, train_cmd, build_cmd])
obs = await env.step(action)

姿态值

名称行为
0HoldFire永不自动开火
1ReturnFire仅在被攻击时还击
2Defend攻击进入射程内的敌人
3AttackAnything积极追击所有敌军

作战要诀

  • 检查 available_production 后再下达 BUILD 或 TRAIN 命令——服务器会验证可用性。
  • 建筑放置需要生产队列中有已完成的建筑。使用 PLACE_BUILDING 并指定格坐标。
  • 队列命令:设置 queued=true 可将动作排队执行,不会打断当前活动。
  • 阵营有别:盟军兵营是 tent,苏军兵营是 barr。通过 available_production 确认你所属阵营的建筑列表。