This section guides you through installing
poke-env and setting up a Pokémon Showdown server.
Ensure Python 3.8 or later is installed. Dependencies listed here will be installed automatically.
pip install poke-env
Configuring a Pokémon Showdown Server
poke-env can interact with a public server, hosting a private server is advisable for training agents due to performance and rate limitations on the public server.
Install Node.js v10+.
Clone the Pokémon Showdown repository and set it up:
git clone https://github.com/smogon/pokemon-showdown.git cd pokemon-showdown npm install cp config/config-example.js config/config.js node pokemon-showdown start --no-security
--no-security flag disables crucial security features, use with caution. This flag facilitates AI training by removing rate limiting and authentication requirements.
poke-env are instances of the
Player class. Explore the following examples to get started:
Basic agent: Cross Evaluating Random Players
Advanced agent: Creating a simple max damage player
Custom team builder: Creating a custom teambuilder
Configuring Showdown Players
Player instances require player configurations tied to Showdown accounts. Auto-generated configurations suffice for servers without authentication. For authenticated servers or custom configurations, utilize the
account_configuration argument with
from poke_env import AccountConfiguration # No authentication required my_account_config = AccountConfiguration("my_username", None) player = Player(account_configuration=my_account_config) # Authentication required my_account_config = AccountConfiguration("my_username", "super-secret-password") player = Player(account_configuration=my_account_config, server_configuration=...) # Auto-generated configuration for local use player = Player()
Connecting Bots to Showdown
Player instances require a account configuration to connect to a Pokémon Showdown server. You can configure the connection to local servers, the official Showdown server, or other custom servers.
Player instances use
LocalhostServerConfiguration, targeting the default local server endpoint.
Official Showdown Server
To connect to the official Pokémon Showdown server using
ShowdownServerConfiguration, a player configuration with a password is required.
from poke_env import Player, ShowdownServerConfiguration, AccountConfiguration account_config = AccountConfiguration("my_username", "super-secret-password") player = Player(server_configuration=ShowdownServerConfiguration, account_configuration=account_config)
For custom servers, create a
ServerConfiguration object with the server URL and authentication endpoint.
from poke_env import Player, ServerConfiguration custom_config = ServerConfiguration("my.custom.host:5432", "authentication-endpoint.com/action.php?") player = Player(server_configuration=custom_config)