GithubHelp home page GithubHelp logo

fuyw / pgx Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sotetsuk/pgx

0.0 0.0 0.0 50.19 MB

A collection of highly-parallel RL game environments written in JAX

License: Apache License 2.0

Shell 0.02% Python 97.96% Rust 0.13% Makefile 0.01% Jupyter Notebook 1.89%

pgx's Introduction

ci

A collection of GPU/TPU-accelerated parallel game simulators for reinforcement learning (RL)

Why Pgx?

Brax, a JAX-native physics engine, provides extremely high-speed parallel simulation for RL in continuous state space. Then, what about RL in discrete state spaces like Chess, Shogi, and Go? Pgx provides a wide variety of JAX-native game simulators! Highlighted features include:

  • JAX-native. All step functions are JIT-able
  • Super fast in parallel execution on accelerators
  • Various game support including Backgammon, Shogi, and Go
  • Beautiful visualization in SVG format

Install

pip install pgx

Usage

Open In Colab

import jax
import pgx

env = pgx.make("go-19x19")
init = jax.jit(jax.vmap(env.init))  # vectorize and JIT-compile
step = jax.jit(jax.vmap(env.step))

batch_size = 1024
keys = jax.random.split(jax.random.PRNGKey(42), batch_size)
state = init(keys)  # vectorized states
while not state.terminated.all():
    action = model(state.current_player, state.observation, state.legal_action_mask)
    state = step(state, action)  # state.reward (2,)

Supported games and road map

⚠️ Pgx is currently in the beta version. Therefore, API is subject to change without notice. We aim to release v1.0.0 in April 2023. Opinions and comments are more than welcome!

Use pgx.available_games() to see the list of currently available games.

Game Environment Visualization
2048
Animal Shogi
Backgammon
Bridge Bidding 🚧
Chess 🚧
Connect Four
Go
Hex
Kuhn Poker
Leduc hold'em
Mahjong 🚧 🚧
MinAtar/Asterix
MinAtar/Breakout
MinAtar/Freeway
MinAtar/Seaquest
MinAtar/SpaceInvaders
Othello
Shogi
Sparrow Mahjong
Tic-tac-toe

See also

Pgx is intended to complement these JAX-native environments with (classic) board game suits:

Combining Pgx with these JAX-native algorithms/implementations might be an interesting direction:

LICENSE

Apache-2.0

pgx's People

Contributors

clement-bonnet avatar habara-k avatar harukaki avatar nissymori avatar okanoshinri avatar sotetsuk avatar youyou-ku avatar

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.