Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updates to documentation #45

Merged
merged 1 commit into from
Jun 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
98 changes: 56 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,68 @@
</a>
</p>

An interface for optimising pokemon teams using genetic algorithms!
An interface for optimising Pokémon teams using genetic algorithms!

## Installation

steps:

- clone the repo
- install the module in a virtual environment with `pip install -e .`
- initialise submodules with `git submodule update --init --recursive`
- if you're having problems, you can directly clone poke-env with
`git clone https://github.com/aoifehughes/poke-env.git`
- cd into `poke-env` and run `pip install -e .`
- cd back to the root directory and clone the `pokemon-showdown` repo with
`git clone https://github.com/smogon/pokemon-showdown`
- if you don't have node, install it with `brew install node` (mac) or
`sudo apt install nodejs` (linux)
- install with `npm install` in the `pokemon-showdown` directory
- start a local server with `node pokemon-showdown start --no-security` in the
`pokemon-showdown` directory
- to run a small demo, you should be able to just run `p2lab` from the command
line!

or via Docker:

`docker build -t p2:latest .` `docker run -it p2:latest`
`docker exec -it your_container_id /bin/bash`
- Clone required repos:

```bash
git clone [email protected]:alan-turing-institute/p2lab-pokemon.git
cd p2lab-pokemon
git submodule update --init --recursive
```

- Install p2lab and poke-env:

```bash
cd poke-env
pip install -e .
cd ..
pip install -e .
```

- Have node installed
- See: https://nodejs.dev/en/learn/how-to-install-nodejs/

## Running

To run locally start the pokemon showdown server:

```bash
cd pokemon-showdown
node pokemon-showdown start --no-security
```

In another terminal, from this project's root directory run:

```bash
p2lab <args>
```

### Additional arguments for p2lab

```bash
usage: p2lab [-h] [--generations GENERATIONS] [--teamsize TEAMSIZE] [--numteams NUMTEAMS] [--seed SEED] [--unique UNIQUE]

options:
-h, --help show this help message and exit
--generations GENERATIONS
Number of generations to iterate over
--teamsize TEAMSIZE Number of pokemon per team (max 6)
--numteams NUMTEAMS Number of teams i.e., individuals per generation
--seed SEED Random seed to use
--unique UNIQUE Determines if a team can have duplicate pokemon species
```

### Docker:

Alternatively, using docker: `docker build -t p2:latest .`
`docker run -it p2:latest` `docker exec -it your_container_id /bin/bash`

Run docker build with `--no-cache` to rebuild with newer versions of the repos.

## Components
## Components used

### Pokemon showdown engine:

Expand All @@ -44,25 +76,7 @@ Run docker build with `--no-cache` to rebuild with newer versions of the repos.
- Has instructions on setting up our own server (needed to run battles!)
- Also features command-line utilities for generating/validating new teams

### Pokemon battle bot by pmargilia (not used yet)

[pmargilia/showdown](https://github.com/pmariglia/showdown)

- Can interface into a server
- Can both launch and accept battle challenges --> we can make the bots battle!
- Already calculates wins/losses in its code (but we need to figure out the best
way to get that info)
- Can be run locally or in a docker container

### Poke-env

- Wicked fast at simulating battles via pokemon showdown engine
- A potential replacement for the battle bot by pmargilia
- https://poke-env.readthedocs.io/en/stable/getting_started.html

### Genetic algorithm library: TBD

### This library, `p2lab`:

- Aiming to be a python module to steer a bunch of bots into battling, collect
the results, then run a genetic algorithm step!
2 changes: 1 addition & 1 deletion poke-env
Submodule poke-env updated 96 files
+1 −2 .pre-commit-config.yaml
+1 −0 conftest.py
+1 −0 diagnostic_tools/anything_goes_gen_7_random_battles_and_teams.py
+1 −0 diagnostic_tools/anything_goes_gen_8_random_battles_and_teams.py
+1 −0 diagnostic_tools/anything_goes_gen_8_random_double_battles_and_teams.py
+5 −1 diagnostic_tools/anything_goes_gen_9_random_battles_and_teams.py
+1 −0 diagnostic_tools/gen8_random_battles.py
+1 −0 diagnostic_tools/parse-game-messages.py
+1 −0 diagnostic_tools/store-game-messages.py
+1 −0 docs/source/conf.py
+1 −0 examples/connecting_an_agent_to_showdown.py
+1 −0 examples/cross_evaluate_random_players.py
+1 −0 examples/custom_teambuilder.py
+1 −0 examples/experimental-self-play.py
+1 −0 examples/gen7/cross_evaluate_random_players.py
+1 −0 examples/gen7/custom_teambuilder.py
+1 −0 examples/gen7/max_damage_player.py
+1 −0 examples/gen7/ou_max_player.py
+1 −0 examples/gen7/rl_with_open_ai_gym_wrapper.py
+1 −0 examples/max_damage_player.py
+1 −0 examples/openai_example.py
+2 −1 examples/ou_max_player.py
+1 −2 examples/requirements.txt
+1 −0 examples/rl_with_new_open_ai_gym_wrapper.py
+1 −0 examples/rl_with_open_ai_gym_wrapper.py
+1 −0 integration_tests/test_concurrency_control.py
+1 −0 integration_tests/test_double_battles.py
+1 −0 integration_tests/test_env_player.py
+1 −0 integration_tests/test_laddering.py
+1 −0 integration_tests/test_simple_cross_evaluation.py
+1 −0 integration_tests/test_using_teams.py
+1 −0 scripts/data_script_utils.py
+1 −0 scripts/update_learnset.py
+1 −0 scripts/update_moves.py
+1 −0 scripts/update_pokedex.py
+1 −0 setup.py
+1 −0 src/poke_env/__init__.py
+1 −0 src/poke_env/data/__init__.py
+7 −1 src/poke_env/data/gen_data.py
+1 −0 src/poke_env/data/normalize.py
+1 −0 src/poke_env/data/replay_template.py
+1 −0 src/poke_env/environment/__init__.py
+1 −0 src/poke_env/environment/abstract_battle.py
+1 −0 src/poke_env/environment/battle.py
+1 −0 src/poke_env/environment/double_battle.py
+1 −0 src/poke_env/environment/effect.py
+1 −0 src/poke_env/environment/field.py
+1 −0 src/poke_env/environment/move.py
+1 −0 src/poke_env/environment/move_category.py
+1 −0 src/poke_env/environment/pokemon.py
+1 −0 src/poke_env/environment/pokemon_gender.py
+1 −0 src/poke_env/environment/pokemon_type.py
+1 −0 src/poke_env/environment/side_condition.py
+1 −0 src/poke_env/environment/status.py
+1 −0 src/poke_env/environment/weather.py
+1 −0 src/poke_env/environment/z_crystal.py
+1 −0 src/poke_env/exceptions.py
+1 −0 src/poke_env/player/__init__.py
+1 −0 src/poke_env/player/baselines.py
+1 −0 src/poke_env/player/battle_order.py
+1 −0 src/poke_env/player/env_player.py
+1 −0 src/poke_env/player/internals.py
+1 −0 src/poke_env/player/openai_api.py
+1 −0 src/poke_env/player/player.py
+1 −0 src/poke_env/player/player_network_interface.py
+1 −0 src/poke_env/player/random_player.py
+1 −0 src/poke_env/player/utils.py
+1 −0 src/poke_env/player_configuration.py
+1 −0 src/poke_env/server_configuration.py
+1 −0 src/poke_env/stats.py
+1 −0 src/poke_env/teambuilder/__init__.py
+1 −0 src/poke_env/teambuilder/constant_teambuilder.py
+1 −0 src/poke_env/teambuilder/teambuilder.py
+1 −0 src/poke_env/teambuilder/teambuilder_pokemon.py
+1 −0 unit_tests/environment/test_battle.py
+1 −0 unit_tests/environment/test_double_battle.py
+1 −0 unit_tests/environment/test_dynamax.py
+1 −0 unit_tests/environment/test_enumerations.py
+1 −0 unit_tests/environment/test_move.py
+1 −0 unit_tests/environment/test_past_gen_data.py
+1 −0 unit_tests/environment/test_pokemon.py
+1 −0 unit_tests/environment/test_pokemon_type.py
+1 −0 unit_tests/player/test_baselines.py
+1 −0 unit_tests/player/test_battle_orders.py
+1 −0 unit_tests/player/test_env_player.py
+1 −0 unit_tests/player/test_laddering.py
+1 −0 unit_tests/player/test_openai.py
+1 −0 unit_tests/player/test_player_default_configuration.py
+1 −0 unit_tests/player/test_player_evaluation.py
+1 −0 unit_tests/player/test_player_misc.py
+1 −0 unit_tests/player/test_player_network_interface.py
+1 −0 unit_tests/teambuilder/test_constant_teambuilder.py
+1 −0 unit_tests/teambuilder/test_teambuilder.py
+1 −0 unit_tests/teambuilder/test_teambuilder_pokemon.py
+1 −0 unit_tests/test_data.py
+1 −0 unit_tests/test_utils.py
26 changes: 21 additions & 5 deletions src/p2lab/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,27 @@ async def main_loop(num_teams, team_size, num_generations, unique):

def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument("-g", help="Number of generations", type=int, default=10)
parser.add_argument("-t", help="Team size", type=int, default=2)
parser.add_argument("-n", help="Number of teams", type=int, default=30)
parser.add_argument("-s", help="Random seed", type=int, default=None)
parser.add_argument("-u", help="Unique teams", default=True)
parser.add_argument(
"--generations",
help="Number of generations to iterate over",
type=int,
default=10,
)
parser.add_argument(
"--teamsize", help="Number of pokemon per team (max 6)", type=int, default=2
)
parser.add_argument(
"--numteams",
help="Number of teams i.e., individuals per generation",
type=int,
default=30,
)
parser.add_argument("--seed", help="Random seed to use ", type=int, default=None)
parser.add_argument(
"--unique",
help="Determines if a team can have duplicate pokemon species",
default=True,
)
return vars(parser.parse_args())


Expand Down