Skip to main content
Archived

This project has been archived by its maintainers, and is no longer receiving any updates.

OpenAI Gym Chess

Gym Chess is an environment for reinforcement learning with the OpenAI gym module.

Screen-Shot-2020-10-27-at-2-30-21-PM

Installation

  1. Install OpenAI Gym and its dependencies.
    pip install gym

  2. Download and install gym-chess:
    git clone https://github.com/Ryan-Rudes/gym-chess.git
    cd gym-chess
    python setup.py install

Environments

Screen-Shot-2020-10-27-at-3-08-46-PM-copy

Example

You can use the standard Chess-v0 environment as so:

import gym
import gym_chess

env = gym.make("Chess-v0")
env.reset()

terminal = False

while not terminal:
  action = env.action_space.sample()
  observation, reward, terminal, info = env.step(action)
  env.render()
  
env.close()

There is also an environment for the Chess960 variant; its identifier is Chess960-v0

Further Info

This environment will return 0 reward until the game has reached a terminal state. In the case of a draw, it will still return 0 reward. Otherwise, the reward will be either 1 or -1, depending upon the winning player.

observation, reward, terminal, info = env.step(action)

Here, info will be a dictionary containing the following information pertaining to the board configuration and game state:

  • turn: The side to move (chess.WHITE or chess.BLACK).
  • castling_rights: Bitmask of the rooks with castling rights.
  • fullmove_number: Counts move pairs. Starts at 1 and is incremented after every move of the black side.
  • halfmove_clock: The number of half-moves since the last capture or pawn move.
  • promoted: A bitmask of pieces that have been promoted.
  • ep_square: The potential en passant square on the third or sixth rank or None.

Download files

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

Source Distribution

chess_gym-0.0.2.tar.gz (2.2 kB view details)

Uploaded Source

File details

Details for the file chess_gym-0.0.2.tar.gz.

File metadata

  • Download URL: chess_gym-0.0.2.tar.gz
  • Upload date:
  • Size: 2.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.7.6

File hashes

Hashes for chess_gym-0.0.2.tar.gz
Algorithm Hash digest
SHA256 8a4842e3a74cb47e536f5e7253e07b97d24bdcf72aa1beaddfadb74206336a60
MD5 ad2eff92dfd611fb2002a7e42d83a645
BLAKE2b-256 c182fd892f5bc133c118e131ca45f8df376551bac99c58790374c4132982428a

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