Skip to content

Commit 0aa0495

Browse files
committed
mofa working
1 parent 48de2cf commit 0aa0495

File tree

96 files changed

+1751
-3069
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+1751
-3069
lines changed

examples/mofa/.DS_Store

-6 KB
Binary file not shown.

examples/mofa/README.md

Lines changed: 2 additions & 152 deletions
Original file line numberDiff line numberDiff line change
@@ -1,152 +1,2 @@
1-
# 红色警戒AI智能体系统
2-
3-
基于MoFA框架的红色警戒AI智能体,实现自动游戏控制和策略决策。
4-
5-
## 环境要求
6-
7-
- Python >= 3.10
8-
- Rust 环境 (用于Dora运行时)
9-
- OpenRA游戏客户端
10-
- OpenAI API Key (或兼容的LLM服务)
11-
12-
## 安装步骤
13-
14-
### 1. 安装依赖环境
15-
16-
```bash
17-
# 安装Rust环境
18-
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
19-
20-
# 安装Dora运行时
21-
cargo install dora-cli
22-
23-
# 验证安装
24-
dora --version
25-
```
26-
27-
### 2. 安装MoFA框架
28-
29-
```bash
30-
# 进入mofa框架目录
31-
cd ~/mofa
32-
33-
# 安装MoFA框架
34-
pip install -e .
35-
```
36-
37-
### 3. 安装项目依赖
38-
39-
```bash
40-
# 在项目根目录
41-
cd ~/Hackathon2025/examples/mofa
42-
43-
# 安装各Agent依赖
44-
pip install -e ./agent-hub/openra-battlefield-reader
45-
pip install -e ./agent-hub/openra-battlefield-analyze
46-
pip install -e ./agent-hub/openra-execute
47-
pip install -e ./node-hub/terminal-input
48-
```
49-
50-
### 4. 配置环境变量
51-
52-
在项目根目录创建 `.env.secret` 文件:
53-
54-
```bash
55-
# OpenAI API配置
56-
LLM_API_KEY=your_openai_api_key_here
57-
LLM_API_BASE=https://api.openai.com/v1
58-
LLM_MODEL=
59-
60-
# OpenRA游戏路径
61-
OPENRA_PATH=/path/to/your/OpenRA/Copilot/openra_ai
62-
63-
# 游戏连接配置
64-
GAME_IP=localhost
65-
GAME_PORT=7445
66-
```
67-
68-
## 使用方法
69-
70-
### 1. 启动OpenRA游戏
71-
确保OpenRA游戏已启动且API服务可用
72-
73-
### 2. 启动数据流
74-
75-
```bash
76-
cd examples/openra-controller
77-
78-
# 启动Dora服务
79-
dora up
80-
81-
# 构建数据流
82-
dora build openra-controller.yml
83-
84-
# 运行数据流
85-
dora start openra-controller.yml
86-
```
87-
88-
### 3. 交互控制
89-
90-
在新终端中运行:
91-
92-
```bash
93-
terminal-input
94-
```
95-
96-
输入指令示例:
97-
- "多多造步兵"
98-
- "快速建造坦克"
99-
- "防守基地"
100-
- "攻击敌人"
101-
102-
## 项目架构
103-
104-
### 数据流组件
105-
106-
1. **terminal-input**: 用户输入节点,接收命令并显示结果
107-
2. **openra-battlefield-reader**: 战场状态读取器,分析用户意图并读取游戏状态
108-
3. **openra-battlefield-analyze**: AI分析器,使用LLM分析战场并制定策略
109-
4. **openra-execute**: 游戏执行器,将AI决策转换为游戏操作
110-
111-
### 数据流向
112-
113-
```
114-
用户输入 → 战场读取 → AI分析 → 游戏执行 → 结果返回
115-
```
116-
117-
### 核心文件
118-
119-
- `openra-controller.yml`: 数据流配置文件
120-
- `agent-hub/*/main.py`: 各组件主要逻辑
121-
- `examples/openra-controller/`: 运行示例和日志
122-
123-
## 常见问题
124-
125-
### 路径问题
126-
如果遇到导入错误,检查:
127-
1. MoFA框架是否正确安装
128-
2. OPENRA_PATH环境变量是否正确设置
129-
3. 各Agent是否正确安装
130-
131-
### 游戏连接问题
132-
确保:
133-
1. OpenRA游戏正在运行
134-
2. API服务端口7445可访问
135-
3. 游戏处于可控制状态
136-
137-
### AI分析失败
138-
检查:
139-
1. LLM_API_KEY是否正确配置
140-
2. API服务是否可用
141-
3. 网络连接是否正常
142-
143-
## 开发说明
144-
145-
### 添加新策略
146-
修改 `agent-hub/openra-battlefield-analyze/ai_analyzer.py`
147-
148-
### 修改执行逻辑
149-
修改 `agent-hub/openra-execute/game_executor.py`
150-
151-
### 调试模式
152-
在环境变量中设置 `WRITE_LOG=true` 启用详细日志
1+
# Hackathon2025
2+
红色警戒之人工智能崛起!!!第一届AI智能体红警游戏黑客松

examples/mofa/agent-hub/.DS_Store

-6 KB
Binary file not shown.
-6 KB
Binary file not shown.

examples/mofa/agent-hub/openra-battlefield-analyze/openra_battlefield_analyze/main.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22
import sys
3-
sys.path.append(os.getenv('OPENRA_PATH','/Users/chenzi/chenzi/project/github/OpenRA/Copilot/openra_ai'))
3+
sys.path.append(os.getenv('OPENRA_PATH','/Users/chenzi/project/github/OpenRA/Copilot/openra_ai'))
4+
sys.path.append(os.getenv('OPENRA_PATH','/Users/chenzi/project/github/OpenRA/Copilot/openra_ai/OpenRA_Copilot_Library'))
45
from mofa.agent_build.base.base_agent import MofaAgent, run_agent
56
from OpenRA_Copilot_Library import GameAPI, Location, TargetsQueryParam
67
current_dir = os.path.dirname(os.path.abspath(__file__))
-6 KB
Binary file not shown.

examples/mofa/agent-hub/openra-battlefield-reader/openra_battlefield_reader/main.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import json
22
import os
33
import sys
4-
sys.path.append(os.getenv('OPENRA_PATH','/Users/chenzi/chenzi/project/github/OpenRA/Copilot/openra_ai'))
4+
sys.path.append(os.getenv('OPENRA_PATH','/Users/chenzi/project/github/OpenRA/Copilot/openra_ai'))
5+
sys.path.append(os.getenv('OPENRA_PATH','/Users/chenzi/project/github/OpenRA/Copilot/openra_ai/OpenRA_Copilot_Library'))
56
current_dir = os.path.dirname(os.path.abspath(__file__))
67
sys.path.insert(0, current_dir)
78
from mofa.agent_build.base.base_agent import MofaAgent, run_agent

examples/mofa/agent-hub/openra-copilot-agent/README.md

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)