Skip to main content
Archived

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

Chess Gym

PyPI download month PyPI - Status PyPI GitHub

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 chess_gym:
    git clone https://github.com/Ryan-Rudes/chess-gym.git
    cd chess-gym
    python setup.py install

    Or, you can use pip (you may view the package here):
    pip install chess-gym

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 chess_gym

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.5.post1.tar.gz (4.7 kB view details)

Uploaded Source

File details

Details for the file chess_gym-0.0.5.post1.tar.gz.

File metadata

  • Download URL: chess_gym-0.0.5.post1.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.3

File hashes

Hashes for chess_gym-0.0.5.post1.tar.gz
Algorithm Hash digest
SHA256 33521006eb117a7f7e8f44ae76d566693bffc18f97bffbd56efbe4962b5eaf9c
MD5 7e90d1e1b3a39e802ab51d46a739ad79
BLAKE2b-256 dc653b71b9f3ab935d2d83f36bd311ab8be0c7c370b635fae095bb7aa737d6c2

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.0.5.post1 This release

1 file

0.0.5

1 file

0.0.4

1 file

0.0.3

1 file

0.0.1

1 file

Supported by

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