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

    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 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.3.tar.gz (2.3 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: chess_gym-0.0.3.tar.gz
  • Upload date:
  • Size: 2.3 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.3.tar.gz
Algorithm Hash digest
SHA256 8753d9bbbc87991346ec9ed3fec6aa494ac41071d5481559d988d4a0fe29faf6
MD5 f30447288133cdd4ddd957f89d360d46
BLAKE2b-256 c60362d390eee714ef601fec0bd5636c307e19122629ed78c666503f1d20a506

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 Sentry Error logging StatusPage Status page