Overview
Thesimulate-battle command runs Pokemon Showdown’s battle simulator, allowing you to simulate battles programmatically by sending commands via stdin and receiving battle output via stdout.
- Building battle bots and AI agents
- Testing battle mechanics
- Running automated battle simulations
- Integrating Pokemon Showdown battles into other applications
Command Options
Thesimulate-battle command supports several flags:
| Flag | Short | Description |
|---|---|---|
--debug | -D | Enable debug mode for detailed error information |
--replay | -R | Generate replay data alongside battle output |
--spectate | -S | Generate spectator-compatible output (includes replay data) |
Example Usage
Battle Stream Protocol
The simulator uses a stream-based protocol where you write commands to stdin and read responses from stdout.All input messages must start with
>. Lines not starting with > are treated as comments and ignored.In standard IO, each message should end with \n.Starting a Battle
Send start command
Begin by sending a The options object must include:
>start command with battle options:formatid- Format ID (required)seed- Array of four numbers for RNG (optional)p1,p2,p3,p4- Player options (optional)
Configure players
Send player information for each player:
Teams must be in packed format or JSON format. For random formats, you can omit the team or set it to
null to auto-generate a random team.Complete Battle Example
Here’s a full example of a Gen 7 Random Battle:With Custom Teams
Input Commands Reference
Start Battle
formatid(string) - The format ID (e.g.,"gen9ou","gen8randombattle")
seed(number[4]) - RNG seed for reproducible battlesp1,p2,p3,p4(object) - Player options (can also be set separately)
Configure Player
PLAYERID is p1, p2, p3, or p4.
PLAYEROPTIONS (JSON object):
name(string) - Player name (defaults to “Player 1”, “Player 2”, etc.)avatar(string) - Player avatar (defaults to "")team(string|array) - Team in packed format or JSON format
Player Choices
move N- Use move in slot N (1-4)move N mega- Use move N and Mega Evolvemove N zmove- Use move N as a Z-Movemove N dynamax- Use move N and Dynamaxmove N terastallize- Use move N and Terastallizeswitch N- Switch to Pokemon in slot N (1-6)team NNNNNN- Select team order during team preview (6 digits, 1-6)default- Make a random legal choiceundo- Undo the last choice (if allowed)
Reading Output
The simulator sends back messages delimited by\n\n (double newline) in standard IO.
Message Types
Update Message
Side Update Message
Split Message
Within update messages, you may see split messages:- SECRET - Detailed information for the specific player (e.g., exact HP values)
- PUBLIC - Public information suitable for opponents and spectators
End Message
Using from Other Languages
Since the simulator uses standard IO, you can interact with it from any programming language:Reproducible Battles
You can create reproducible battles by providing a seed:Error Handling
By default, errors are caught and logged to the battle output. Use
--debug flag to enable detailed error information and stack traces.Related Documentation
Simulator Protocol
Complete protocol documentation for battle messages and choices
Team Formats
Learn about packed format and team structure
Team Commands
Generate and validate teams for battles
Node.js API
Use the battle simulator directly in Node.js
