Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
72d9c69
gen 1/2 moves/abilities manual data json overrides
jakegrigsby Jun 3, 2025
dd9a03d
re-add Pokemon previous move
jakegrigsby Jun 3, 2025
f244a28
pokemon first_turn False after moved
jakegrigsby Jun 3, 2025
f0ae238
additional AbstractBattle ignores
jakegrigsby Jun 3, 2025
86aeb8d
route '-activate ability:' messages away from adding 'effects'
jakegrigsby Jun 3, 2025
4383e41
add note to check guardwap swapboost later; protect against missing c…
jakegrigsby Jun 3, 2025
afce101
expand Effects list; light screen occasionally shows up as an effect …
jakegrigsby Jun 3, 2025
c2c6db1
force Pokemon current_hp_fraction to float
jakegrigsby Jun 3, 2025
c861c0a
try to catch SideCondition messages with inconsistent spacing
jakegrigsby Jun 3, 2025
80d0ff2
backwards port: Leave battle room when finished
jakegrigsby Jun 3, 2025
b889b1d
from future: Fix Reflect Type/Heart Swap errors; from memtamon: add g…
jakegrigsby Jun 3, 2025
10e7a7b
minor black changes to player top-level docstrings
jakegrigsby Jun 3, 2025
6659312
from past: return battle deepcopy so (last_battle, battle) reward com…
jakegrigsby Jun 3, 2025
f4fa97d
experimental: recover some of deepcopy lost time by dodging deepcopy …
jakegrigsby Jun 3, 2025
5f62d89
strip out observation system that can be done in a wrapper on the RL …
jakegrigsby Jun 4, 2025
5956447
from past: cut observations out of abstract battle because it slows d…
jakegrigsby Jun 4, 2025
533b686
black module docstrings
jakegrigsby Jun 4, 2025
0405fbb
Battle deepcopy for (last_state, state) is now fast enough to justify…
jakegrigsby Jun 4, 2025
59badd6
patch effect messages in from_data too
jakegrigsby Jun 4, 2025
d5e65ac
from metamon: 'recharge' move entry needs priority key
jakegrigsby Jun 4, 2025
77b91ad
handle common gen1 partial trapping unhandled move message
jakegrigsby Jun 4, 2025
af550d3
scale back scope of changes to this fork: manual merge effect and sid…
jakegrigsby Jun 5, 2025
1b540a9
draft: switch to a custom player in openaigym env
jakegrigsby Jun 6, 2025
842830f
from metamon: leave AbstractBattle set to version from paper's fork. …
jakegrigsby Jun 6, 2025
0975d17
add empty flags to recharge entry
jakegrigsby Jun 9, 2025
4856ea4
from future: handle new Showdown protocol->request order
jakegrigsby Jun 9, 2025
7d618d6
remove move discovery assert that fails for valid reasons
jakegrigsby Jun 9, 2025
13350d2
Update README.md
jakegrigsby Jun 9, 2025
9de24ee
Update README.md
jakegrigsby Jun 9, 2025
f096f8a
Update pyproject.toml
jakegrigsby Jun 10, 2025
629a3d4
add snowscape weather
jakegrigsby Jun 25, 2025
793b749
from future: fix port of sim/request order to work with teampreview
jakegrigsby Jun 25, 2025
cc45463
from future: defend against -prepare ... [premajor]
jakegrigsby Jun 25, 2025
deeb44f
mark new version
jakegrigsby Jul 5, 2025
36c3c6b
Merge pull request #4 from UT-Austin-RPL/mm_adds_gen9
jakegrigsby Jul 5, 2025
5b5c168
revival blessing
jakegrigsby Jul 6, 2025
d6d34fd
Merge pull request #5 from UT-Austin-RPL/mm_adds_gen9
jakegrigsby Jul 6, 2025
7c6b83b
add basic sleep_between throttle for player laddering
jakegrigsby Jul 10, 2025
d6e3d8f
Merge pull request #6 from UT-Austin-RPL/mm_adds_gen9
jakegrigsby Jul 10, 2025
701216c
basic throttle pt
jakegrigsby Jul 11, 2025
cde9ac9
improve n_won_battles crash during long-term self-play
jakegrigsby Jul 17, 2025
fb6e188
Merge pull request #7 from UT-Austin-RPL/mm_adds_gen9
jakegrigsby Jul 17, 2025
3b11ebf
Update README.md
jakegrigsby Jul 25, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 7 additions & 89 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,93 +1,11 @@
# The pokemon showdown Python environment
>[!IMPORTANT]
> This is a fork of [poke-env](https://github.com/hsahovic/poke-env) that installs with [`metamon`](https://github.com/UT-Austin-RPL/metamon). It attempts to extend the lifespan of poke-env as it was during Metamon's development:
> 1. Maintains the original gymnasium interface that existed until v0.8.3. `OpenAIGymEnv` (+ ability to swap in custom Players). Rewards functions that take `last_battle` and `current_battle` as input (+ a speed boost). Removes "observation" system that slows fps and is already handled by Metamon.
> 2. Preserves minor early-generation battle details as they were when Metamon's original models were trained.
> 3. Tries to bring key fixes/improvements since v0.8.3 that are unrelated to gymnasium.
>
> Please see the main repo [here](https://github.com/hsahovic/poke-env) for any other use case. I only plan to update this to fix breaking changes to the Showdown sim/request message API. Any improvements to early-generation state tracking/sim protocol are now done in metamon.

[![PyPI version fury.io](https://badge.fury.io/py/poke-env.svg)](https://pypi.python.org/pypi/poke-env/)
[![PyPI pyversions](https://img.shields.io/pypi/pyversions/poke-env.svg)](https://pypi.python.org/pypi/poke-env/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Documentation Status](https://readthedocs.org/projects/poke-env/badge/?version=stable)](https://poke-env.readthedocs.io/en/stable/?badge=stable)
[![codecov](https://codecov.io/gh/hsahovic/poke-env/branch/master/graph/badge.svg)](https://codecov.io/gh/hsahovic/poke-env)

A Python interface to create battling pokemon agents. `poke-env` offers an easy-to-use interface for creating rule-based or training Reinforcement Learning bots to battle on [pokemon showdown](https://pokemonshowdown.com/).

![A simple agent in action](rl-gif.gif)

## Getting started

Agents are instance of python classes inheriting from `Player`. Here is what your first agent could look like:

```python
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 switch then!
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)
```

To get started, take a look at [our documentation](https://poke-env.readthedocs.io/en/stable/)!


## Documentation and examples

Documentation, detailed examples and starting code can be found [on readthedocs](https://poke-env.readthedocs.io/en/stable/).


## Installation

This project requires python >= 3.9 and a [Pokemon Showdown](https://github.com/Zarel/Pokemon-Showdown) server.

```
pip install poke-env
```

You can use [smogon's server](https://play.pokemonshowdown.com/) to try out your agents against humans, but having a development server is strongly recommended. In particular, it is recommended to use the `--no-security` flag to run a local server with most rate limiting and throttling turned off. Please refer to [the docs](https://poke-env.readthedocs.io/en/stable/getting_started.html#configuring-a-showdown-server) for detailed setup instructions.


```
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
```

## Development version

You can also clone the latest master version with:

```
git clone https://github.com/hsahovic/poke-env.git
```

Dependencies and development dependencies can then be installed with:

```
pip install -r requirements.txt
pip install -r requirements-dev.txt
```

## Acknowledgements

This project is a follow-up of a group project from an artifical intelligence class at [Ecole Polytechnique](https://www.polytechnique.edu/).

You can find the original repository [here](https://github.com/hsahovic/inf581-project). It is partially inspired by the [showdown-battle-bot project](https://github.com/Synedh/showdown-battle-bot). Of course, none of these would have been possible without [Pokemon Showdown](https://github.com/Zarel/Pokemon-Showdown).

Team data comes from [Smogon forums' RMT section](https://www.smogon.com/).

## Data

Data files are adapted version of the `js` data files of [Pokemon Showdown](https://github.com/Zarel/Pokemon-Showdown).

## License
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

## Citing `poke-env`

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "poke_env"
version = "0.8.3"
version = "0.8.3.2"
description = "A python interface for training Reinforcement Learning bots to battle on pokemon showdown."
readme = "README.md"
requires-python = ">=3.9.0"
Expand Down
16 changes: 15 additions & 1 deletion src/poke_env/data/gen_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,15 @@ def load_moves(self, gen: int) -> Dict[str, Any]:
with open(
os.path.join(self._static_files_root, "moves", f"gen{gen}moves.json")
) as f:
return orjson.loads(f.read())
data = orjson.loads(f.read())

# manually fix data entries gathered from Showdown data files
if gen == 1:
data["recover"]["heal"] = [1, 2]
data["softboiled"]["heal"] = [1, 2]
# TODO: check vicegrip / visegrip

return data

def load_natures(self) -> Dict[str, Dict[str, Union[int, float]]]:
with open(os.path.join(self._static_files_root, "natures.json")) as f:
Expand Down Expand Up @@ -64,6 +72,12 @@ def load_pokedex(self, gen: int) -> Dict[str, Any]:
dex.update(other_forms_dex)

for name, value in dex.items():
if gen <= 2 and "abilities" in value:
# remove abilities from gen 1-2. Gens before abilities
# existed will often list an "ability" called "No Ability".
# Because it is the only option, `Pokemon` will assume it
# is active at the start of the battle.
value["abilities"] = {"0": "No Ability"}
if "baseSpecies" in value:
value["species"] = value["baseSpecies"]
else:
Expand Down
6 changes: 0 additions & 6 deletions src/poke_env/environment/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
field,
move,
move_category,
observation,
observed_pokemon,
pokemon,
pokemon_gender,
pokemon_type,
Expand All @@ -24,8 +22,6 @@
from poke_env.environment.field import Field
from poke_env.environment.move import SPECIAL_MOVES, EmptyMove, Move
from poke_env.environment.move_category import MoveCategory
from poke_env.environment.observation import Observation
from poke_env.environment.observed_pokemon import ObservedPokemon
from poke_env.environment.pokemon import Pokemon
from poke_env.environment.pokemon_gender import PokemonGender
from poke_env.environment.pokemon_type import PokemonType
Expand All @@ -44,8 +40,6 @@
"Field",
"Move",
"MoveCategory",
"Observation",
"ObservedPokemon",
"Pokemon",
"PokemonGender",
"PokemonType",
Expand Down
Loading