宝可梦红 AI 智能体:自主游戏模拟器 - Openclaw Skills

作者:互联网

2026-03-26

其他

什么是 宝可梦红自主智能体?

该技能使 AI 智能体能够成为宝可梦红中的训练家,通过 PyBoy 模拟器直接与游戏交互。通过利用 Openclaw Skills,智能体可以处理实时截图、读取 RAM 状态并执行复杂的寻路动作。它无需中间脚本,允许智能体启动服务器、分析视觉领域并通过强大的 REST API 做出战略决策。

该系统专为高度自主性而设计,智能体负责整个游戏循环。它将计算机视觉(通过截图)与游戏内存中的原始数据提取相结合,确保智能体对其环境有完美的理解,从当前的 X/Y 坐标到队伍成员的具体生命值。

下载入口:https://github.com/openclaw/skills/tree/main/skills/drbarq/pokemon-red

安装与下载

1. ClawHub CLI

从源直接安装技能的最快方式。

npx clawhub@latest install pokemon-red

2. 手动安装

将技能文件夹复制到以下位置之一

全局模式 ~/.openclaw/skills/ 工作区 /skills/

优先级:工作区 > 本地 > 内置

3. 提示词安装

将此提示词复制到 OpenClaw 即可自动安装。

请帮我使用 Clawhub 安装 pokemon-red。如果尚未安装 Clawhub,请先安装(npm i -g clawhub)。

宝可梦红自主智能体 应用场景

  • 无需人工干预的自动刷级和宝可梦训练。
  • 使用自主寻路在关都地区导航以到达特定目的地。
  • 在复杂的、回合制的战斗环境中测试 AI 决策。
  • 构建多智能体竞争性宝可梦游戏系统,让智能体进行竞争或协作。
  • 创建自动速通尝试或任务完成日志。
宝可梦红自主智能体 工作原理
  1. 使用基于 Python 的 FastAPI 封装器和合法获取的 ROM 初始化模拟器服务器。
  2. 通过专用 HTTP 端点获取当前游戏状态和视觉截图,使智能体的内部模型与游戏同步。
  3. 决定是使用自动导航 API 进行长途旅行,还是使用手动按钮操作进行本地交互(如 NPC 或门)。
  4. 通过分析队伍状态并通过按钮 API 执行战斗指令来处理战斗。
  5. 跟踪任务进度并将教训保存到知识库中,以改进未来的游戏会话并防止卡住。
  6. 定期保存游戏状态以确保不同智能体回话之间的连续性。

宝可梦红自主智能体 配置指南

首先,克隆仓库并安装必要的 Python 依赖:

git clone https://github.com/drbarq/Pokemon-OpenClaw.git
cd Pokemon-OpenClaw
pip install pyboy pillow numpy fastapi uvicorn requests

确保您合法获取的 ROM 放置在 ./PokemonRed.gb。要启动供 Openclaw Skills 智能体交互的模拟器服务器,请运行:

python scripts/emulator_server.py --save ready --port 3456

宝可梦红自主智能体 数据架构与分类体系

该技能通过结构化 API 组织数据,提供原始和处理后的信息:

数据类别 端点 详情
游戏状态 /api/state 从 RAM 返回坐标、队伍状态、徽章和战斗标志。
视觉数据 /api/screenshot 提供当前帧的 PNG 以供视觉分析。
导航 /api/maps 为导航引擎列出带有可用寻路数据的地图。
知识 /api/knowledge 持久教训和任务目标的集合。
任务状态 /api/quest 跟踪当前进度和采取的具体历史行动。
name: pokemon-red
description: Play Pokemon Red autonomously via PyBoy emulator. The OpenClaw agent IS the player — starts the emulator server, sees screenshots, reads game state from RAM, and makes decisions via HTTP API. Use when an agent wants to play Pokemon Red, battle, explore, grind levels, or compete with other agents. Requires Python 3.10+, pyboy, and a legally obtained Pokemon Red ROM.

Pokemon Red — You Are the Trainer

You play Pokemon Red directly. No middleman script. You start the emulator server, hit its HTTP API for screenshots and state, look at the screen, decide what to do, and send commands back.

Setup (first time)

Clone the repo and install dependencies:

git clone https://github.com/drbarq/Pokemon-OpenClaw.git
cd Pokemon-OpenClaw
pip install pyboy pillow numpy fastapi uvicorn requests
# Place your legally obtained ROM at ./PokemonRed.gb

Set POKEMON_DIR to wherever you cloned the repo (default: ~/Code/pokemon-openclaw).

Start a Session

# Start emulator server (background process)
cd $POKEMON_DIR && python scripts/emulator_server.py --save ready --port 3456

Turn Loop

Every turn, do these in order:

1. Get state + screenshot

curl -s http://localhost:3456/api/state
curl -s http://localhost:3456/api/screenshot -o /tmp/pokemon_current.png

Then use the image tool to look at the screenshot. Always look before acting.

2. Decide: Navigate or Manual?

Use navigate for travel — it BLOCKS until you arrive, hit a battle, or get stuck:

curl -s -X POST http://localhost:3456/api/navigate r
  -H 'Content-Type: application/json' r
  -d '{"destination": "Viridian City"}'

Navigate returns one of:

  • "status": "arrived" — you're there! Continue quest.
  • "status": "battle" — wild encounter interrupted. Fight it, then navigate again.
  • "status": "stuck" — couldn't reach destination. Try manual buttons or different route.
  • "status": "error" — unknown destination or no path. Check destinations list.

The response always includes full game state, so you know exactly where you are.

Important: Navigate blocks — set a long timeout (60-120s) on the curl call.

Check available destinations first:

curl -s http://localhost:3456/api/destinations

Check which maps have pathfinding data:

curl -s http://localhost:3456/api/maps

Fall back to manual buttons only when:

  • Navigate returns "stuck" or "error"
  • You're inside a building doing specific interactions
  • You're in dialogue or a menu

3. Manual controls (when needed)

# Move / interact
curl -s -X POST http://localhost:3456/api/press r
  -H 'Content-Type: application/json' r
  -d '{"buttons": ["up","up","a"], "reasoning": "Walking to door"}'

Valid buttons: up, down, left, right, a, b, start, select. Send 1-5 per turn.

4. Battle (when in_battle is true in state)

  • Fight: Press a to open fight menu, a again for FIGHT, navigate to move, a to confirm, then mash a through animations
  • Run: Press a, then down, right, a to select RUN, mash a through text
  • Check state after — if still in_battle, go again

5. Quest tracking

curl -s http://localhost:3456/api/quest                    # Current objective
curl -s -X POST http://localhost:3456/api/quest/complete r
  -H 'Content-Type: application/json' r
  -d '{"lesson": "Door is at x=12"}'                      # Advance step + save lesson

6. Save frequently

curl -s -X POST http://localhost:3456/api/command r
  -H 'Content-Type: application/json' r
  -d '{"command": "save", "name": "checkpoint_viridian"}'

Key Endpoints

Endpoint Method Purpose
/api/state GET Game state from RAM (position, party, badges, battle)
/api/screenshot GET PNG screenshot of game screen
/api/navigate POST Pathfind to named destination
/api/destinations GET List all navigation destinations
/api/maps GET Which maps have pathfinding data
/api/press POST Send button presses
/api/quest GET Current quest and step
/api/quest/complete POST Mark step done, optionally save a lesson
/api/knowledge GET All lessons learned
/api/knowledge/lesson POST Add a new lesson
/api/command POST Save/load/speed commands

Strategy Priority

  1. Navigate first. For any travel, use /api/navigate. It blocks until arrival or battle — no polling needed.
  2. Handle battles immediately. If navigate returns "status": "battle", fight (mash A), then navigate again to the same destination.
  3. Check quest. Always know your current objective. Don't wander.
  4. HP management. Below 30% → consider healing. Below 15% → definitely heal. Navigate to nearest pokecenter.
  5. Ignore text_active. The text detection flag is broken (always true). Don't spam B to dismiss phantom text.
  6. Save often. Every 10 turns or after any milestone.

Session Pattern

A sub-agent session should:

  1. Start emulator server (if not already running)
  2. Check quest status and destinations
  3. Play 20-50 turns (navigate + manual as needed)
  4. Save state before exiting
  5. Report progress (location, level, quest step, any highlights)

Keep notes in /tmp/pokemon_notepad.txt for continuity within a session.

For Full Game Strategy

See references/game_instructions.md for Pokemon Red basics: movement, buildings, doors, battles, type matchups, healing, and the quest system.