LLM-based Pokemon Showdown bot using Poke-Env. Supports local models via Ollama and cloud models via OpenRouter.
- Bot receives battle state (logs, active pokemon, team status, available actions)
- Sends state to LLM which returns reasoning + action
- Executes action via Poke-Env
- Python 3.12+
- UV package manager
- Node.js (for local Showdown server)
- Ollama (for local models) or OpenRouter API key (for cloud models)
git clone https://github.com/JotaDeRodriguez/CHATOT_LM
cd CHATOT_LM
uv syncFor local models:
ollama pull gemma3:12b
ollama pull qwen3:14bFor cloud models:
export OPENROUTER_API_KEY="your-api-key"Start Showdown server:
git clone https://github.com/smogon/pokemon-showdown.git
cd pokemon-showdown
npm install
node pokemon-showdown start --no-securitySingle battle:
uv run python main.pyBattle against the bot:
Uncomment line 104 in main.py:
await gemma_player.accept_challenges(opponent=None, n_challenges=1)Round robin tournament:
uv run python round_robin.pyCreating players:
Use factory methods to create AI players:
from ai_players import AIPlayer
from poke_env import AccountConfiguration
# Local Ollama models
local_player = AIPlayer.local(
model="gemma3:12b",
verbosity=True,
account_configuration=AccountConfiguration("bot_name", None),
battle_format="gen3ubers",
log_length=25, # default: 25 for local
team=your_team
)
# OpenRouter cloud models
cloud_player = AIPlayer.router(
model="anthropic/claude-3-5-sonnet",
verbosity=True,
account_configuration=AccountConfiguration("bot_name", None),
battle_format="gen3ubers",
log_length=100, # default: 100 for router
team=your_team
)Change battle format:
player = AIPlayer.local(model="gemma3:12b", battle_format="gen9ou", team=your_team)Adjust log length:
player = AIPlayer.local(model="gemma3:12b", log_length=50)Connection refused: Ensure Showdown server is running with --no-security
Model not found: Run ollama list or check OpenRouter model names
Invalid actions: Bot falls back to random moves when LLM output is invalid
- Poke-Env - Python interface for Pokemon Showdown
- Pokemon Showdown - Battle simulator