Giter Club home page Giter Club logo

pokemonshowdown-ai's Introduction

Pokemon Showdown AI

Build codecov

Reinforcement learning project for Pokemon Showdown. Currently only supports the Gen-4 random battle format.

This project has three parts:

  • PsBot framework for creating a general Pokemon Showdown bot and setting up the battle interface.
  • Battle state tracker and PS protocol parser.
  • Neural network training script.
2022-08-14_demo.mp4

Me (left) vs a model (right) that was trained over ~16k games against itself

Build Instructions

Make sure you have at least Node v18 (LTS) and Miniconda 3 installed. Should work on Linux and likely also Windows WSL2.

# Download the repository.
git clone https://github.com/taylorhansen/pokemonshowdown-ai
cd pokemonshowdown-ai

# Checkout submodules.
git submodule init
git submodule update

# Setup Python/TensorFlow.
conda env create --name psai --file environment.yml
conda activate psai

# Setup TS.
npm install
npm run build

Testing

# Run formatter.
npm run format
isort src test
black src test

# Run linter.
npm run lint
pylint src test
mypy src test

# Run tests.
npm test
python -m test.unit

Training

# Edit hyperparmeters as needed.
cp config/train_example.yml config/train.yml

python -m src.py.train

Trains the neural network through self-play. This requires a powerful computer and/or GPU, and may take several hours depending on how it's configured.

Training logs are saved to ./experiments/ by default.

Metrics such as loss and evaluation scores can be viewed using TensorBoard.

pip install tensorboard
tensorboard --logdir experiments

Running

# Edit config as needed.
cp config/psbot_example.yml config/psbot.yml

npm run psbot

Connects to the PS server specified in the config and starts accepting battle challenges in the gen4randombattle format, which is the only format that this project supports for now. By default it loads the model from ./experiments/train/model (assuming a training run was completed) and connects to a locally-hosted PS instance (see guide on how to set one up). This allows the trained model to take on human challengers or any other outside bots.

License

See LICENSE.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.