项目作者: ZhiqingXiao

项目描述 :
Extension of OpenAI Gym that implements multiple two-player zero-sum 2-dimension board games
高级语言: Python
项目地址: git://github.com/ZhiqingXiao/boardgame2.git
创建时间: 2019-04-05T01:48:03Z
项目社区:https://github.com/ZhiqingXiao/boardgame2

开源协议:

下载


boardgame2

boardgame2 is an extension of OpenAI Gym that implements multiple two-player zero-sum 2-dimension board games, such as TicTacToe, Gomuko, and Reversi.

Environments

  • Reversi-v0
  • KInARow-v0, as well as Gomuku-v0 and TicTacToe-v0
  • Go-v0 (Experimental, not fully implemented)

Install

  1. pip install --upgrade boardgame2

We support Windows, macOS, Linux, and other operating systems.

Usage

See API docs for all classes and functions.

Create a Game

  1. import gym
  2. import boardgame2
  3. env = gym.make('TicTacToe-v0') # 3x3, 3-in-a-row
  4. env = gym.make('Gomuku-v0') # 15x15, 5-in-a-row
  5. env = gym.make('KInARow-v0', board_shape=5, target_length=4) # 5x5, 4-in-a-row
  6. env = gym.make('KInARow-v0', board_shape=(3, 5), target_length=4) # 3x5, 4-in-a-row
  7. env = gym.make('Reversi-v0') # 8x8
  8. env = gym.make('Reversi-v0', board_shape=6) # 6x6
  9. env = gym.make('Go-v0') # 19x19
  10. env = gym.make('Go-v0', board_shape=15) # 15x15

Play a Game

  1. import gym
  2. import boardgame2
  3. env = gym.make('TicTacToe-v0')
  4. print('observation space = {}'.format(env.observation_space))
  5. print('action space = {}'.format(env.action_space))
  6. observation, info = env.reset()
  7. while True:
  8. action = env.action_space.sample()
  9. observation, reward, termination, truncation, info = env.step(action)
  10. if termination or truncation:
  11. break
  12. env.close()

BibTeX

This package has been published in the following book:

  1. @book{xiao2019,
  2. title = {Reinforcement Learning: Theory and {Python} Implementation},
  3. author = {Zhiqing Xiao}
  4. year = 2019,
  5. month = 8,
  6. publisher = {China Machine Press},
  7. }