Skip to main content

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

Project description

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, Chess, 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

:warning: 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 :white_check_mark: :white_check_mark:
Animal Shogi :white_check_mark: :white_check_mark:
Backgammon :white_check_mark: :white_check_mark:
Bridge Bidding :construction: :white_check_mark:
Chess :white_check_mark: :white_check_mark:
Connect Four :white_check_mark: :white_check_mark:
Go :white_check_mark: :white_check_mark:
Hex :white_check_mark: :white_check_mark:
Kuhn Poker :white_check_mark: :white_check_mark:
Leduc hold'em :white_check_mark: :white_check_mark:
Mahjong :construction: :construction:
MinAtar/Asterix :white_check_mark: :white_check_mark:
MinAtar/Breakout :white_check_mark: :white_check_mark:
MinAtar/Freeway :white_check_mark: :white_check_mark:
MinAtar/Seaquest :white_check_mark: :white_check_mark:
MinAtar/SpaceInvaders :white_check_mark: :white_check_mark:
Othello :white_check_mark: :white_check_mark:
Shogi :white_check_mark: :white_check_mark:
Sparrow Mahjong :white_check_mark: :white_check_mark:
Tic-tac-toe :white_check_mark: :white_check_mark:

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:

Citation

@article{koyamada2023pgx,
  title={Pgx: Hardware-accelerated parallel game simulation for reinforcement learning},
  author={Koyamada, Sotetsu and Okano, Shinri and Nishimori, Soichiro and Murata, Yu and Habara, Keigo and Kita, Haruka and Ishii, Shin},
  journal={arXiv preprint arXiv:2303.17503},
  year={2023}
}

LICENSE

Apache-2.0

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pgx-0.5.1.tar.gz (202.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pgx-0.5.1-py3-none-any.whl (282.7 kB view details)

Uploaded Python 3

File details

Details for the file pgx-0.5.1.tar.gz.

File metadata

  • Download URL: pgx-0.5.1.tar.gz
  • Upload date:
  • Size: 202.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.3

File hashes

Hashes for pgx-0.5.1.tar.gz
Algorithm Hash digest
SHA256 f317c00eb18330d0628423477cc719c523cb5d1e562f3bf0bf9375eeb7d7c60c
MD5 483d9becbcaa8a3a4c5e90d0f911e5f6
BLAKE2b-256 18794048d3476148853b4797d37a86ee4964943e2997c5aaebe9c1ecc9c0ab71

See more details on using hashes here.

File details

Details for the file pgx-0.5.1-py3-none-any.whl.

File metadata

  • Download URL: pgx-0.5.1-py3-none-any.whl
  • Upload date:
  • Size: 282.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.3

File hashes

Hashes for pgx-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3ad43f709366cc28ba6d45e64e7f0dd7e19e3fd528f604e606573e5f0c27987f
MD5 c03984dfea2d25ac7bfa696c57664d99
BLAKE2b-256 aa6e3f4b2bf9ebf44b7d2a21030b079b782d099277960c5becfb37348c7b8d13

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page