Skip to content

teyrebaz33/pokemon-agent

ย 
ย 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

2 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽฎ pokemon-agent

AI-powered Pokรฉmon gameplay agent with headless emulation, REST API, and live dashboard.

Let any AI agent โ€” Hermes Agent, Claude Code, Codex, or your own โ€” play Pokรฉmon games autonomously via a clean HTTP API. Runs headlessly on any server or terminal. No display, no GUI, no emulator window needed.

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   Your AI Agent      โ”‚  Any LLM-powered agent
โ”‚   (Hermes, Claude,   โ”‚  makes the decisions
โ”‚    Codex, custom)    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
          โ”‚ HTTP API
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   pokemon-agent      โ”‚  This package:
โ”‚   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚  - Headless emulator
โ”‚   โ”‚ Game Server    โ”‚ โ”‚  - Memory reader
โ”‚   โ”‚ (FastAPI)      โ”‚ โ”‚  - Game state parser
โ”‚   โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค โ”‚  - REST + WebSocket API
โ”‚   โ”‚ Emulator       โ”‚ โ”‚  - Optional dashboard
โ”‚   โ”‚ (PyBoy/PyGBA)  โ”‚ โ”‚
โ”‚   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Features

  • ๐Ÿ”Œ Headless emulation โ€” No display server, X11, or GUI needed. Pure in-process emulation.
  • ๐ŸŒ REST API โ€” GET /state, POST /action, GET /screenshot โ€” control the game over HTTP.
  • ๐Ÿ“ก WebSocket โ€” Real-time event streaming for live monitoring.
  • ๐Ÿง  Structured game state โ€” RAM is parsed into clean JSON: party, bag, badges, map, battle, dialog.
  • ๐ŸŽจ Live dashboard โ€” Optional web GUI to watch the AI play (Claude Plays Pokรฉmon style).
  • ๐ŸŽฎ Multi-game โ€” Supports Game Boy (Pokรฉmon Red/Blue) via PyBoy, GBA (FireRed) via PyGBA.
  • ๐Ÿค– Agent-agnostic โ€” Works with any AI agent, RL framework, or custom script.

Quick Start

Installation

# Core (emulator + API server)
pip install pokemon-agent pyboy

# With dashboard (optional web GUI)
pip install pokemon-agent[dashboard] pyboy

Note: You must provide your own ROM file. This package does not include any game ROMs.

Start the Server

pokemon-agent serve --rom path/to/pokemon_red.gb
โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
โ•‘       ๐ŸŽฎ Pokรฉmon Agent Server       โ•‘
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
  Game:       Pokemon Red
  ROM:        pokemon_red.gb
  API:        http://localhost:8765
  Dashboard:  http://localhost:8765/dashboard
  WebSocket:  ws://localhost:8765/ws

Play from Any Agent

# Get game state
curl http://localhost:8765/state | python -m json.tool

# Take a screenshot
curl http://localhost:8765/screenshot -o screen.png

# Send actions
curl -X POST http://localhost:8765/action \
  -H "Content-Type: application/json" \
  -d '{"actions": ["walk_up", "walk_up", "press_a"]}'

# Save/load state
curl -X POST http://localhost:8765/save -d '{"name": "before_brock"}'
curl -X POST http://localhost:8765/load -d '{"name": "before_brock"}'

Game State (JSON)

{
  "player": {
    "name": "ASH",
    "money": 3000,
    "badges": 1,
    "badges_list": ["Boulder"],
    "position": {"map_id": 1, "map_name": "PALLET TOWN", "x": 7, "y": 5},
    "facing": "down",
    "play_time": {"hours": 1, "minutes": 23, "seconds": 45}
  },
  "party": [
    {
      "nickname": "SQUIRTLE",
      "species": "Squirtle",
      "level": 12,
      "hp": 33,
      "max_hp": 33,
      "moves": ["Tackle", "Tail Whip", "Bubble"],
      "status": null,
      "types": ["Water"]
    }
  ],
  "bag": [{"item": "Potion", "quantity": 3}],
  "battle": null,
  "dialog": {"active": false, "text": null},
  "flags": {"has_pokedex": true, "badges_earned": ["Boulder"]},
  "metadata": {"game": "Pokemon Red", "frame_count": 12345}
}

Actions Reference

Action Description
press_a Press A button (10 frames press + 20 wait)
press_b Press B button
press_start Press Start button
press_select Press Select button
walk_up Walk one tile up (16 frames + 8 wait)
walk_down Walk one tile down
walk_left Walk one tile left
walk_right Walk one tile right
hold_a_30 Hold A for 30 frames
wait_60 Wait 60 frames (~1 second)
a_until_dialog_end Press A repeatedly until dialog closes

Dashboard

Install with the dashboard extra to get a live web GUI:

pip install pokemon-agent[dashboard]

Then open http://localhost:8765/dashboard in your browser.

The dashboard shows:

  • Live game screenshot โ€” Updated each turn with decorative corner brackets
  • AI reasoning stream โ€” Watch the agent think in real-time
  • Team status โ€” All party Pokรฉmon with HP bars, types, levels
  • Badge progress โ€” Visual badge tracker
  • Action log โ€” Color-coded history of all actions and reasoning

Supported Games

Game Emulator Status Install
Pokรฉmon Red/Blue PyBoy โœ… Supported pip install pyboy
Pokรฉmon Yellow PyBoy โœ… Supported pip install pyboy
Pokรฉmon Gold/Silver PyBoy ๐Ÿ”œ Planned pip install pyboy
Pokรฉmon FireRed/LeafGreen PyGBA ๐Ÿ”œ Phase 2 pip install pygba
Pokรฉmon Ruby/Sapphire/Emerald PyGBA ๐Ÿ”œ Phase 2 pip install pygba

Use with Hermes Agent

Hermes Agent has a built-in pokemon-player skill:

You: "Play Pokรฉmon Red"
Hermes: *installs pokemon-agent, starts server, begins playing*

The skill teaches Hermes battle strategy, exploration patterns, team management, and how to use its persistent memory for tracking objectives across sessions.

API Reference

Endpoint Method Description
/ GET Server info
/state GET Full game state JSON
/screenshot GET Current frame (PNG)
/screenshot/base64 GET Current frame (base64 JSON)
/action POST Execute game actions
/save POST Save emulator state
/load POST Load emulator state
/saves GET List saved states
/minimap GET ASCII minimap
/health GET Health check
/ws WebSocket Live event stream
/dashboard GET Web dashboard (if installed)

Python API

You can also use pokemon-agent as a library:

from pokemon_agent.emulator import create_emulator
from pokemon_agent.memory.red import PokemonRedReader
from pokemon_agent.state.builder import build_game_state

# Load ROM headlessly
emu = create_emulator("pokemon_red.gb")

# Create memory reader
reader = PokemonRedReader(emu)

# Get structured game state
state = build_game_state(reader)
print(f"Player: {state['player']['name']}")
print(f"Badges: {state['player']['badges']}")
print(f"Party: {[p['species'] for p in state['party']]}")

# Send inputs
emu.press("a", frames=10)
emu.tick(20)

# Get screenshot
image = emu.get_screen()  # PIL Image
image.save("screenshot.png")

Architecture

pokemon_agent/
โ”œโ”€โ”€ __init__.py          # Package version
โ”œโ”€โ”€ cli.py               # CLI entry point (pokemon-agent command)
โ”œโ”€โ”€ server.py            # FastAPI game server (REST + WebSocket)
โ”œโ”€โ”€ emulator.py          # PyBoy/PyGBA wrapper (headless)
โ”œโ”€โ”€ pathfinding.py       # A* grid navigation
โ”œโ”€โ”€ memory/
โ”‚   โ”œโ”€โ”€ reader.py        # Abstract game memory reader
โ”‚   โ”œโ”€โ”€ red.py           # Pokรฉmon Red/Blue RAM parser
โ”‚   โ””โ”€โ”€ firered.py       # FireRed RAM parser (Phase 2)
โ”œโ”€โ”€ state/
โ”‚   โ””โ”€โ”€ builder.py       # Structured state builder
โ””โ”€โ”€ dashboard/           # Optional [dashboard] extra
    โ”œโ”€โ”€ mount.py         # FastAPI static mount
    โ”œโ”€โ”€ history.py       # JSONL event logger
    โ””โ”€โ”€ static/
        โ”œโ”€โ”€ index.html   # Dashboard page
        โ”œโ”€โ”€ style.css    # Dark cyberpunk theme
        โ””โ”€โ”€ app.js       # WebSocket client

Contributing

Contributions welcome! Areas where help is needed:

  • Pokรฉmon Gold/Silver/Crystal memory reader (memory/gold.py)
  • Pokรฉmon FireRed full memory reader with decryption (memory/firered.py)
  • Pokรฉmon Emerald memory reader (memory/emerald.py)
  • Battle AI improvements and type matchup optimization
  • Dashboard enhancements (progress tracking, key moments, replay)
  • Tests for memory readers and state builders

License

MIT โ€” see LICENSE.

Acknowledgments

About

AI-powered Pokemon gameplay agent with headless emulation, REST API, and live dashboard. Works with any LLM.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 71.7%
  • JavaScript 14.0%
  • CSS 9.1%
  • HTML 5.2%