Skip to content

Commit 426909b

Browse files
committed
add mofa mcp
1 parent bec513f commit 426909b

File tree

15 files changed

+823
-0
lines changed

15 files changed

+823
-0
lines changed
Binary file not shown.
Binary file not shown.
Binary file not shown.
190 Bytes
Binary file not shown.
13.5 KB
Binary file not shown.
33.8 KB
Binary file not shown.
Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
# MoFA 单节点 OpenRA Copilot
2+
3+
基于 MoFA 框架的单节点 OpenRA 游戏控制系统,使用与 MCP 版本完全相同的底层逻辑。
4+
5+
## 🎯 项目特点
6+
7+
- **单节点架构**:将复杂的多节点数据流简化为单个 Agent
8+
- **MCP 逻辑复用**:完全移植 MCP 版本的游戏工具集
9+
- **智能命令解析**:支持自然语言游戏控制
10+
- **简化部署**:相比原版 MoFA 实现更简洁
11+
12+
## 🏗️ 项目结构
13+
14+
```
15+
mofa-single-node/
16+
├── agent-hub/
17+
│ └── openra-copilot-agent/ # 单节点 Agent
18+
│ ├── openra_copilot_agent/
19+
│ │ ├── main.py # Agent 主逻辑
20+
│ │ ├── openra_tools.py # 游戏工具集(移植自 MCP)
21+
│ │ └── __init__.py
22+
│ ├── pyproject.toml
23+
│ └── README.md
24+
├── examples/
25+
│ └── openra-single-controller/ # 运行示例
26+
│ └── openra-single-controller.yml # 数据流配置
27+
└── README.md # 本文件
28+
```
29+
30+
## 📋 环境要求
31+
32+
- Python >= 3.10
33+
- Rust 环境(用于 Dora 运行时)
34+
- OpenRA 游戏客户端
35+
- MoFA 框架
36+
37+
## 🚀 快速开始
38+
39+
### 1. 安装依赖环境
40+
41+
```bash
42+
# 安装 Rust 环境
43+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
44+
45+
# 安装 Dora 运行时
46+
cargo install dora-cli
47+
48+
# 验证安装
49+
dora --version
50+
```
51+
52+
### 2. 安装 MoFA 框架
53+
54+
```bash
55+
# 进入 mofa 根目录
56+
cd ~/mofa
57+
58+
# 安装 MoFA 框架
59+
pip install -e .
60+
```
61+
62+
### 3. 安装项目依赖
63+
64+
```bash
65+
# 进入项目目录
66+
cd mofa-single-node
67+
68+
# 安装 Agent
69+
pip install -e ./agent-hub/openra-copilot-agent
70+
71+
# 安装终端输入节点(复用原有的)
72+
pip install -e ../mofa/node-hub/terminal-input
73+
```
74+
75+
### 4. 配置环境变量
76+
77+
创建 `.env.secret` 文件:
78+
79+
```bash
80+
# OpenRA 游戏路径
81+
OPENRA_PATH=/path/to/your/OpenRA/Copilot/openra_ai
82+
83+
# 游戏连接配置
84+
GAME_IP=localhost
85+
GAME_PORT=7445
86+
```
87+
88+
### 5. 启动系统
89+
90+
```bash
91+
# 启动 OpenRA 游戏(确保 API 服务可用)
92+
93+
# 进入运行目录
94+
cd examples/openra-single-controller
95+
96+
# 启动 Dora 服务
97+
dora up
98+
99+
# 构建数据流
100+
dora build openra-single-controller.yml
101+
102+
# 运行数据流
103+
dora start openra-single-controller.yml
104+
```
105+
106+
### 6. 开始游戏控制
107+
108+
在新终端中运行:
109+
110+
```bash
111+
terminal-input
112+
```
113+
114+
## 🎮 使用示例
115+
116+
支持智能自然语言命令:
117+
118+
```bash
119+
# 生产单位
120+
>>> 生产 5 个步兵
121+
✅ 开始生产 5 个 步兵,任务ID: 12345
122+
123+
# 建造建筑
124+
>>> 造电厂
125+
✅ 开始生产 1 个 电厂,任务ID: 12346
126+
127+
# 查询信息
128+
>>> 查询游戏状态
129+
✅ 执行结果:
130+
{
131+
"cash": 3000,
132+
"resources": 120,
133+
"power": 25,
134+
"visible_units": [...]
135+
}
136+
137+
# 查看帮助
138+
>>> help
139+
🎮 OpenRA Copilot Agent 可用命令:
140+
...
141+
```
142+
143+
## 🔧 与其他版本对比
144+
145+
| 特性 | MCP 版本 | 原版 MoFA | 单节点 MoFA |
146+
|------|----------|-----------|-------------|
147+
| **架构复杂度** | ⭐⭐ 简单 | ⭐⭐⭐⭐⭐ 复杂 | ⭐⭐⭐ 中等 |
148+
| **部署便利性** | ⭐⭐⭐⭐⭐ 最好 | ⭐⭐ 一般 | ⭐⭐⭐ 较好 |
149+
| **功能完整性** | ⭐⭐⭐⭐⭐ 完整 | ⭐⭐⭐ 基础 | ⭐⭐⭐⭐⭐ 完整 |
150+
| **扩展性** | ⭐⭐⭐⭐ 很好 | ⭐⭐⭐⭐ 很好 | ⭐⭐⭐⭐ 很好 |
151+
| **维护成本** | ⭐⭐⭐⭐⭐ 最低 | ⭐⭐ 高 | ⭐⭐⭐ 中等 |
152+
153+
## 🎯 设计优势
154+
155+
### 相比原版 MoFA 实现
156+
157+
1. **简化架构**:从 4 个节点简化为 2 个节点(终端输入 + 单个 Agent)
158+
2. **减少依赖**:不需要复杂的意图解析、战场读取、AI 分析等多个组件
159+
3. **统一逻辑**:所有游戏控制逻辑集中在一个 Agent 中,便于维护
160+
4. **完整功能**:复用 MCP 版本的完整工具集,功能更丰富
161+
162+
### 相比 MCP 版本
163+
164+
1. **框架优势**:利用 MoFA 的数据流管理和 Agent 生命周期
165+
2. **扩展性**:更容易添加新的数据流节点和 Agent 间通信
166+
3. **标准化**:符合 MoFA 框架的开发规范
167+
168+
## 🐛 故障排除
169+
170+
### OpenRA 连接问题
171+
```bash
172+
# 检查游戏是否运行
173+
netstat -an | grep 7445
174+
175+
# 检查 OPENRA_PATH 环境变量
176+
echo $OPENRA_PATH
177+
```
178+
179+
### Dora 相关问题
180+
```bash
181+
# 重新启动 Dora 服务
182+
dora down && dora up
183+
184+
# 查看日志
185+
dora logs
186+
```
187+
188+
### Agent 运行问题
189+
```bash
190+
# 查看 Agent 日志
191+
tail -f logs/agent.log
192+
193+
# 重新安装 Agent
194+
pip uninstall openra-copilot-agent
195+
pip install -e ./agent-hub/openra-copilot-agent
196+
```
197+
198+
## 💡 开发说明
199+
200+
### 添加新功能
201+
修改 `openra_copilot_agent/openra_tools.py` 添加新的游戏 API 封装
202+
203+
### 修改命令解析
204+
修改 `openra_copilot_agent/main.py` 中的智能命令解析逻辑
205+
206+
### 扩展数据流
207+
修改 `openra-single-controller.yml` 添加新的节点或连接
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# OpenRA Copilot Agent
2+
3+
单节点 OpenRA 游戏控制 Agent,集成了 MCP 版本的所有工具功能。
4+
5+
## 功能特点
6+
7+
-**单节点设计**:所有游戏控制逻辑集中在一个 Agent 中
8+
-**MCP 兼容**:使用与 MCP 版本完全相同的游戏 API 封装
9+
-**智能命令解析**:支持自然语言命令,如 "生产 5 个步兵"
10+
-**完整功能**:包含单位生产、移动、攻击、查询等所有功能
11+
12+
## 与 MCP 版本的对比
13+
14+
| 特性 | MCP 版本 | MoFA 单节点版本 |
15+
|------|----------|----------------|
16+
| 架构复杂度 | ⭐⭐ 简单 | ⭐⭐⭐ 中等 |
17+
| 部署便利性 | ⭐⭐⭐ 很好 | ⭐⭐ 一般 |
18+
| 扩展性 | ⭐⭐⭐ 很好 | ⭐⭐⭐ 很好 |
19+
| 调试难度 | ⭐ 容易 | ⭐⭐ 中等 |
20+
| 依赖复杂度 | ⭐ 最少 | ⭐⭐⭐ 较多 |
21+
22+
## 安装
23+
24+
```bash
25+
# 在项目根目录安装
26+
pip install -e .
27+
```
28+
29+
## 使用
30+
31+
作为 MoFA 数据流的一部分运行,详见项目根目录的使用说明。
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# OpenRA Copilot Agent for MoFA
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# OpenRA Copilot Agent Configuration
2+
# This file can be used for agent-specific configurations

0 commit comments

Comments
 (0)