Programming poke-env, a python library for creating showdown battle bots

Creating a bot to battle on showdown is a pain. You have to implement showdown's websocket protocol, parse messages and keep track of the state of everything that is happening.

With poke-env, all of the complicated stuff is taken care of. Creating a battling bot can be as simple as that:

class YourFirstAgent(Player):
----def choose_move(self, battle):
--------for move in battle.available_moves:
------------if move.base_power > 90:
----------------# A powerful move! Let's use it
----------------return self.create_order(move)

-----# No available move? Let's try to switch mons

--------for switch in battle.available_switches:
------------if switch.current_hp_fraction > battle.active_pokemon.current_hp_fraction:
----------------# This other pokemon has more HP left... Let's switch it in?
----------------return self.create_order(switch)

--------# Not sure what to do?
--------return self.choose_random_move(battle)

Interested in reinforcement learning? poke-env exposes an Open AI Gym API; you might also be interested by our example DQN agent.
Just want to create a simple bot and watch it play on the ladder? We have starter code to do just that.
We try to keep our documentation as complete and up-to-date as possible, and maintain a clear, simple and flexible API.

Interested? Getting started is a simple pip install poke-env away :)
We also maintain a showdown server fork optimized for training and testing bots without rate limiting. A random agent can play about 100 randombats games in ten seconds.

Click here to check out the project's documentation, including starting examples, server setup recommendation and API reference
Click here to take a look at the project's Github repo. Issues are welcome!
 
This looks fantastic! Great work to everyone involved in this!

In the gen 3 discord we have been toying with the idea of how an 'AlphaZero' esque bot would approach building and playing the game without any heuristics, the conventional wisdom, that we humans approach the game with. This is a fantastic step towards achieving this.

Provided i get some time free from real life obligations, and this is hopeful thinking, i might start giving this a shot. This looks a lot more accessible than anything that was previously available.

I'll also tag david stone here since I know he has been developing his own version of a RL bot, the Technical Machine.
 
Astamatitos thanks for your enthusiasm! Right now, most gen 7 and gen 8 formats are actively supported. I am not 100% sure what would happen if you tried to play gen 3 formats - it might work, but it's unsure.

If you want to get started on an RL approach, I recommend taking a look at this starter code example: it implements a simple reward and battle embedding mechanism that can be easily extended, and then trains a DQN agent. There are a couple people that have started testing training such agents with self-play, which is in essence Alpha Go Zero's approach.

david stone Indeed, parsing showdown's protocol is not an easy task. One of the goal of this project is to allow users not to worry about it: you do not have to do any parsing yourself! You can access information regarding the battle state using a simple API, eg. battle.available_switches, move.base_power, pokemon.types...
 
Version 0.3.4 is out! You can update via pip.

This release introduces the evaluate_player function, two baseline players (MaxBaseDamagePlayer and SimpleHeuristicsPlayer) and several helper methods (notably Player.damage_multiplier and Player.battle_against).

The main goal of the release is to provide a way to evaluate agent out-of-the box and in a comparable way, so that different bots and models from different authors can be compared reliably. The rest of the update are mainly small quality of life features.
 
Awesome - I'm starting to explore creating several bots for VGC! Will you plan to support damage calcs? (and battle simulations for tree exploration?) A package would be helpful and the most helpful would be native support for exploration speed
 
Hey silverfro,

Nice, I'd be curious to see your results!
Having some basic support for damage calcs is on the roadmap. It probably won't be a full-fledged solution, but a heuristic able to get 99% of the work done efficiently.

Regarding tree-exploration: this is something I'm considering, but as a second-order priority. Right now, I'm focusing on offering an interface for RL models; you can take a look at pmariglia work if tree-based models this is something you want to explore more.
 
Thanks, even heuristic damage calcs would be huge - I'm thinking of doing a combination of tree-exploration and RL -- using expectimax tree exploration with RL-learned values as the reward (for VGC).

I also found an edge-case in double_battle.available_moves where the current implementation doesn't handle the struggle use-case. Should I open a issue for it?
 

Users Who Are Viewing This Thread (Users: 1, Guests: 0)

Top