Skip to main content

No project description provided

Project description

ci

mjx

Features

Mjx is a Japanese Mahjong (riichi Mahjong) simulator. Mjx works as a game server as Mjai, a popular Mahjong simulator, to evaluate Mahjong AIs but have additional features:

  • Fast (100x faster than Mjai)
  • Exact Tenhou compatibility (Mjx is validated with numerous Tenhou game logs)
  • Gym-like API
  • Easy distributed computing (available for large-scale RL and evaluation thanks to gRPC)
  • Mjai compatible (mjx_mjai_translater)
  • Beautiful visualization

mjx

Quick start

Google colab

Install

$ pip install mjx

Requirements. Mjx supports Python3.7 or later in Linux and macOS Intel (10.15 or later). Currently Windows and macOS Apple Silicon are NOT supported. Contributions for supporting Windows and macOS Apple Silicon are more than welcome!

Example

import mjx

agent = mjx.RandomAgent()
env = mjx.MjxEnv()
obs_dict = env.reset()
while not env.done():
  actions = {player_id: agent.act(obs)
    for player_id, obs in obs_dict.items()}
  obs_dict = env.step(actions)
returns = env.rewards()

Sever Usage

ServerClient
import random
import mjx

class RandomAgent(mjx.Agent):
  def __init__(self):
    super().__init__()

  # When you use neural network models
  # you may want to infer actions by batch
  def act_batch(self, observations):
    return [random.choice(obs.legal_actions()) 
            for obs in observations]


agent = RandomAgent()
# act_batch is called instead of act
agent.serve("127.0.0.1:8080", batch_size=8)
import mjx

host="127.0.0.1:8080"

mjx.run(
  {f"player_{i}": host for i in range(4)},
  num_games=1000,
  num_parallels=16
)

How to develop

We recommend you to develop Mjx inside a container. Easiest way is open this repository from VsCode. Feel free to mention to @sotetsuk if you have any questions.

License

MIT

Project details


Download files

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

Source Distribution

mjx-0.1.0.tar.gz (355.0 kB view hashes)

Uploaded Source

Built Distributions

mjx-0.1.0-cp39-cp39-manylinux2014_x86_64.whl (16.0 MB view hashes)

Uploaded CPython 3.9

mjx-0.1.0-cp39-cp39-manylinux2014_i686.whl (16.3 MB view hashes)

Uploaded CPython 3.9

mjx-0.1.0-cp39-cp39-macosx_10_15_x86_64.whl (13.0 MB view hashes)

Uploaded CPython 3.9 macOS 10.15+ x86-64

mjx-0.1.0-cp38-cp38-manylinux2014_x86_64.whl (16.0 MB view hashes)

Uploaded CPython 3.8

mjx-0.1.0-cp38-cp38-manylinux2014_i686.whl (16.3 MB view hashes)

Uploaded CPython 3.8

mjx-0.1.0-cp38-cp38-macosx_10_15_x86_64.whl (13.0 MB view hashes)

Uploaded CPython 3.8 macOS 10.15+ x86-64

mjx-0.1.0-cp37-cp37m-manylinux2014_x86_64.whl (16.0 MB view hashes)

Uploaded CPython 3.7m

mjx-0.1.0-cp37-cp37m-manylinux2014_i686.whl (16.3 MB view hashes)

Uploaded CPython 3.7m

mjx-0.1.0-cp37-cp37m-macosx_10_15_x86_64.whl (13.0 MB view hashes)

Uploaded CPython 3.7m macOS 10.15+ x86-64

Supported by

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