FastChessEnv
A Chess Environment for Reinforcement Learning with Stockfish integration and OpenMP support.
Installation
Easy Local Installation
Run the installation script:
./install.sh
This will:
- Build the MisterQueen libraries
- Copy the libraries to the package directory
- Build the Python extension
- Install the package in development mode
Manual Installation
- Build the MisterQueen libraries:
./build_lib.sh
- Copy the libraries to the package directory:
python copy_libs.py
- Build the Python extension and install:
python build.py
pip install -e .
Remote Installation
You can install directly from the repository:
pip install git+https://github.com/yourusername/fastchessenv.git
Or with uv:
uv pip install git+https://github.com/yourusername/fastchessenv.git
Docker Installation
To build and run with Docker:
./docker_build.sh
docker run -it --rm fastchessenv:openmp
Testing
Run the tests to verify everything is working correctly:
python -m pytest
Usage
Basic Usage
import fastchessenv
# Create a chess environment with 4 parallel environments
env = fastchessenv.CChessEnv(4)
# Reset the environments
state, mask = env.reset()
# Make a move
move_arr = env.random() # Sample random moves
next_state, next_mask, reward, done = env.step(move_arr)
Using Stockfish for Opponent Moves
import fastchessenv
# Create a chess environment with Stockfish opponents
env = fastchessenv.SFCChessEnv(4, depth=3)
# Reset the environments
state, mask = env.reset()
# Make a move
move_arr = env.random() # Sample random moves
next_state, next_mask, reward, done = env.step(move_arr)
Using Random Opponent Moves
import fastchessenv
# Create a chess environment with random opponents
env = fastchessenv.RandomChessEnv(4)
# Reset the environments
state, mask = env.reset()
# Make a move
move_arr = env.random() # Sample random moves
next_state, next_mask, reward, done = env.step(move_arr)
OpenMP Support
FastChessEnv uses OpenMP for parallelization. See OPENMP.md for details on how to enable and configure OpenMP support.
Cross-Platform Support
FastChessEnv is designed to work across multiple platforms and architectures:
- macOS (Intel x86_64 and Apple Silicon arm64)
- Linux (x86_64 and aarch64)
The package includes platform-specific binary libraries that are automatically selected at runtime based on your system. If you're building from source, the build system will compile libraries optimized for your current platform.
Building for Multiple Platforms
This package includes Docker-based tools to build wheels for multiple platforms:
Using Docker for Cross-Platform Builds
# Build wheels for multiple platforms using Docker
./docker_build_wheels.sh
This script will:
- Build a source distribution
- Use Docker to build wheels for Linux x86_64
- Use Docker with buildx (if available) to build wheels for Linux aarch64/ARM64
- Build a wheel for your current macOS platform
All wheels will be stored in the wheelhouse directory, organized by platform.
Manual Multi-Platform Building
If you prefer to build manually, you'll need to:
- Build on each target platform (macOS arm64, macOS x86_64, Linux x86_64, Linux aarch64)
- Collect the wheels in one place
- Upload all wheels + the source distribution to PyPI
GitHub Actions
This repository includes GitHub Actions workflows that automatically build wheels for multiple platforms when a new release is created.
Requirements
- Python 3.6+
- cffi
- numpy
- chess
- Stockfish (optional, for SFCChessEnv)
- GCC with OpenMP support (for optimal performance)
Metadata
Release files for fastchessenv 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fastchessenv-0.1.1.tar.gz | 467.3 kB | Without provenance | Details for fastchessenv-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fastchessenv-0.1.1-cp313-cp313-macosx_11_0_arm64.whl | CPython 3.13 | CPython 3.13 | macOS 11.0+ ARM64 | Details for fastchessenv-0.1.1-cp313-cp313-macosx_11_0_arm64.whl |
Total release size: 743.6 kB
Release files / fastchessenv-0.1.1.tar.gz
| Download URL | fastchessenv-0.1.1.tar.gz |
|---|---|
| Size | 467.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
98a797b8449a697dff715a4fe8e105f3471804eabcb350aa7778734680a88311
|
|
BLAKE2b-256 checksum How to use checksums |
b1dc4c9f2862462533fd37921cd401bf35bd9d5426ee3417258f060fd59bdd86
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.3
|
Release files / fastchessenv-0.1.1-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | fastchessenv-0.1.1-cp313-cp313-macosx_11_0_arm64.whl |
|---|---|
| Size | 276.3 kB |
| Tags | CPython 3.13 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
53411a4deb62a33a02f29246e587ab9fca5da21485486e7c3f268d1a1721e5ef
|
|
BLAKE2b-256 checksum How to use checksums |
66b1d1a63da47a3851425cfcdc8c7a8d9f73ec73d8eda61376a0cc174d57c209
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.3
|
Security for fastchessenv 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.