Skip to content

feat: Pokemon Battle World Agent + world manifest protocol#68

Open
Jing-yilin wants to merge 2 commits intomainfrom
feature/pokemon-world
Open

feat: Pokemon Battle World Agent + world manifest protocol#68
Jing-yilin wants to merge 2 commits intomainfrom
feature/pokemon-world

Conversation

@Jing-yilin
Copy link
Contributor

Summary

Implements #67 — adds a world manifest protocol and the first game world: a Pokemon Battle Arena.

World Manifest Protocol

When an agent sends world.join, the response now includes a manifest field describing:

  • World name, description, and objectives
  • Available actions with parameter formats
  • State fields the agent will receive

This allows AI agents to understand how to play in any world without external docs.

Pokemon Battle World Agent (world/pokemon.mjs)

A standalone DAP World Agent running a turn-based Pokemon battle engine:

  • Engine: @pkmn/sim (MIT license) — same engine as Pokemon Showdown
  • Format: Gen 1 Random Battle, 3 Pokemon per team
  • Mode: Agent vs built-in RandomAI (single-player)
  • Actions: move (slot 1-4) and switch (slot 1-6)
  • State: Structured JSON with active Pokemon, HP, moves, team, battle log

Testing

cd world && npm install
WORLD_ID=pokemon-arena DATA_DIR=/tmp/pokemon PEER_PORT=9099 node pokemon.mjs
# In another terminal, send signed world.join/world.action messages

Verified locally: full battle from join → 15 turns → battle over with winner.

Closes #67

- Add manifest field to world.join response in server.mjs (rules, actions, state_fields)
- Create pokemon.mjs: turn-based Pokemon battle world using @pkmn/sim
  - 1v1 battles with random Gen 1 teams (3 Pokemon each)
  - Agent vs built-in RandomAI
  - Actions: move (slot 1-4), switch (slot 1-6)
  - Returns structured battle state (active Pokemon, HP, moves, team, log)
  - Full manifest describing rules, actions, objectives on join
- Add @pkmn/sim, @pkmn/randoms, @pkmn/data dependencies to world/package.json

Closes #67
- Add web/pokemon.html, pokemon-client.js, pokemon-style.css
- Uses @pkmn/img for official Pokemon Showdown Gen 1 sprites
- Battle scene with front/back sprites, HP bars, move buttons
- Switch UI when Pokemon faints, team panel with icons
- Battle log with color-coded entries (damage, faint, critical)
- Keyboard shortcuts (1-4 for moves)
- Add /play/join, /play/action, /play/new REST endpoints to pokemon.mjs
- Serve frontend at /pokemon on the world agent port
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Pokemon Battle World Agent + world manifest protocol

1 participant